@Override public void run() throws Exception { System.out.println("Executing " + objectId + ".inc() on: " + getNodeEngine().getThisAddress()); CounterService service = getService(); CounterService.Container container = service.containers[getPartitionId()]; Map<String, Integer> valuesMap = container.values; Integer counter = valuesMap.get(objectId); counter += amount; valuesMap.put(objectId, counter); returnValue = counter; }
private String getStateMessage() { return "on partitionId=" + partitionId + " on " + mapServiceContext.getNodeEngine().getThisAddress() + " loadedOnCreate=" + loadedOnCreate + " loadedOnPreMigration=" + loadedOnPreMigration + " isLoaded=" + isLoaded(); }
private BitSet getLocalPartitionIds() { int partitionCount = partitionService.getPartitionCount(); BitSet partitionIds = new BitSet(partitionCount); BitSetUtils.setBits(partitionIds, partitionService.getMemberPartitions(nodeEngine.getThisAddress())); return partitionIds; }
private List<Integer> getOwnedPartitions() { IPartitionService partitionService = getNodeEngine().getPartitionService(); Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap(); List<Integer> ownedPartitions = memberPartitionsMap.get(getNodeEngine().getThisAddress()); return ownedPartitions == null ? Collections.<Integer>emptyList() : ownedPartitions; }
private List<Integer> getOwnedPartitions() { IPartitionService partitionService = getNodeEngine().getPartitionService(); Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap(); List<Integer> ownedPartitions = memberPartitionsMap.get(getNodeEngine().getThisAddress()); return ownedPartitions == null ? Collections.<Integer>emptyList() : ownedPartitions; }
private List<Integer> getOwnedPartitions() { IPartitionService partitionService = getNodeEngine().getPartitionService(); Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap(); List<Integer> ownedPartitions = memberPartitionsMap.get(getNodeEngine().getThisAddress()); return ownedPartitions == null ? Collections.<Integer>emptyList() : ownedPartitions; }
@Override public void run() throws Exception { CounterService service = getService(); System.out.println("Executing " + objectId + ".inc() on: " + getNodeEngine().getThisAddress()); Container container = service.containers[getPartitionId()]; returnValue = container.inc(objectId, amount); }
@Override public void run() { System.out.println("Executing " + objectId + ".inc() on: " + getNodeEngine().getThisAddress()); CounterService service = getService(); Container container = service.containers[getPartitionId()]; returnValue = container.inc(objectId, amount); }
private List<Future<Result>> dispatchFullQueryOnLocalMemberOnQueryThread(Query query) { Operation operation = mapServiceContext.getMapOperationProvider(query.getMapName()).createQueryOperation(query); Future<Result> result = operationService.invokeOnTarget( MapService.SERVICE_NAME, operation, nodeEngine.getThisAddress()); return singletonList(result); }
private boolean isPrimary() { final Address owner = nodeEngine.getPartitionService().getPartition(partitionId, false).getOwnerOrNull(); final Address thisAddress = nodeEngine.getThisAddress(); return owner != null && owner.equals(thisAddress); }
@Override protected InvocationBuilder createInvocationBuilder(Operation op) { OperationService operationService = getNodeEngine().getOperationService(); return operationService.createInvocationBuilder(SERVICE_NAME, op, getNodeEngine().getThisAddress()); }
public void process(EntryTaskScheduler<Object, Object> scheduler, Collection<ScheduledEntry<Object, Object>> entries) { EvictionOperation evictionOperation = new EvictionOperation(store, entries); evictionOperation.setPartitionId(partitionId); nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, evictionOperation, nodeEngine.getThisAddress()); } }
protected boolean isOwnerOrBackup(int partitionId) { final NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); final IPartitionService partitionService = nodeEngine.getPartitionService(); final IPartition partition = partitionService.getPartition(partitionId, false); final Address thisAddress = nodeEngine.getThisAddress(); return partition.isOwnerOrBackup(thisAddress); } }
public String addEventListener(EventListener entryListener, EventFilter eventFilter, String mapName) { if (nodeEngine.getLocalMember().isLiteMember()) { throw new ReplicatedMapCantBeCreatedOnLiteMemberException(nodeEngine.getThisAddress()); } EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, mapName, eventFilter, entryListener); return registration.getId(); }
private boolean isOwner() { final NodeEngine nodeEngine = getNodeEngine(); final Address owner = nodeEngine.getPartitionService().getPartitionOwner(getPartitionId()); return nodeEngine.getThisAddress().equals(owner); }
private void invoke(boolean isRemove, Address address, String name, Data key, Data value, long ttl, VersionResponsePair response) { OperationService operationService = nodeEngine.getOperationService(); ReplicateUpdateOperation updateOperation = new ReplicateUpdateOperation(name, key, value, ttl, response, isRemove, nodeEngine.getThisAddress()); updateOperation.setPartitionId(partitionId); updateOperation.setValidateTarget(false); operationService.invokeOnTarget(SERVICE_NAME, updateOperation, address); }
private void cleanUpLock(OperationService operationService, String uuid, int partitionId, LockStoreImpl lockStore) { Collection<LockResource> locks = lockStore.getLocks(); for (LockResource lock : locks) { Data key = lock.getKey(); if (uuid.equals(lock.getOwner()) && !lock.isTransactional()) { UnlockOperation op = createLockCleanupOperation(partitionId, lockStore.getNamespace(), key, uuid); // op will be executed on partition thread locally. Invocation is to handle retries. operationService.invokeOnTarget(SERVICE_NAME, op, nodeEngine.getThisAddress()); } lockStore.cleanWaitersAndSignalsFor(key, uuid); } }
/** Verifies that the sent partition state version matches the local version or this node is master. */ private void verifyPartitionStateVersion() { InternalPartitionService partitionService = getService(); int localPartitionStateVersion = partitionService.getPartitionStateVersion(); if (partitionStateVersion != localPartitionStateVersion) { if (getNodeEngine().getThisAddress().equals(migrationInfo.getMaster())) { return; } // this is expected when cluster member list changes during migration throw new PartitionStateVersionMismatchException(partitionStateVersion, localPartitionStateVersion); } }
public void publishEvent(ItemEventType eventType, Data data) { EventService eventService = getNodeEngine().getEventService(); Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name); Address thisAddress = getNodeEngine().getThisAddress(); for (EventRegistration registration : registrations) { QueueEventFilter filter = (QueueEventFilter) registration.getFilter(); QueueEvent event = new QueueEvent(name, filter.isIncludeValue() ? data : null, eventType, thisAddress); eventService.publishEvent(getServiceName(), registration, event, name.hashCode()); } }
@Override public void run() throws Exception { service = getService(); ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId()); Object removed = store.remove(key); oldValue = getNodeEngine().toData(removed); response = new VersionResponsePair(removed, store.getVersion()); Address thisAddress = getNodeEngine().getThisAddress(); if (!getCallerAddress().equals(thisAddress)) { sendUpdateCallerOperation(true); } }