@Nonnull public static List<Address> getRemoteMembers(@Nonnull NodeEngine engine) { final Member localMember = engine.getLocalMember(); return engine.getClusterService().getMembers().stream() .filter(m -> !m.equals(localMember)) .map(Member::getAddress) .collect(toList()); }
/** * Dispatches an event-data to {@link com.hazelcast.map.QueryCache QueryCache} listeners on this local * node. * * @param eventData {@link EventData} to be dispatched * @param listener the listener which the event will be dispatched from */ private void dispatchLocalEventData(EventData eventData, ListenerAdapter listener) { IMapEvent event = createIMapEvent(eventData, null, nodeEngine.getLocalMember(), serializationService); listener.onEvent(event); }
/** * Dispatches an event-data to {@link com.hazelcast.map.QueryCache QueryCache} listeners on this local * node. * * @param eventData {@link EventData} to be dispatched * @param listener the listener which the event will be dispatched from */ private void dispatchLocalEventData(EventData eventData, ListenerAdapter listener) { IMapEvent event = createIMapEvent(eventData, null, nodeEngine.getLocalMember(), serializationService); listener.onEvent(event); }
@Override public void destroyDistributedObject(String objectName) { if (nodeEngine.getLocalMember().isLiteMember()) { return; } for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) { partitionContainers[i].destroy(objectName); } quorumConfigCache.remove(objectName); }
public boolean removeEventListener(String mapName, String registrationId) { if (nodeEngine.getLocalMember().isLiteMember()) { throw new ReplicatedMapCantBeCreatedOnLiteMemberException(nodeEngine.getThisAddress()); } if (registrationId == null) { throw new IllegalArgumentException("registrationId cannot be null"); } return eventService.deregisterListener(SERVICE_NAME, mapName, registrationId); }
/** * @see com.hazelcast.map.impl.MapRemoteService#destroyDistributedObject(String) */ @Override public boolean destroyNearCache(String mapName) { invalidator.destroy(mapName, nodeEngine.getLocalMember().getUuid()); return super.destroyNearCache(mapName); }
/** * Schedules a {@link CRDTMigrationTask} with a delay of {@code delaySeconds} * seconds. */ void scheduleMigrationTask(long delaySeconds) { if (nodeEngine.getLocalMember().isLiteMember()) { return; } nodeEngine.getExecutionService().schedule(CRDT_REPLICATION_MIGRATION_EXECUTOR, new CRDTMigrationTask(nodeEngine, this), delaySeconds, TimeUnit.SECONDS); }
/** * Schedules a {@link CRDTMigrationTask} with a delay of {@code delaySeconds} * seconds. */ void scheduleMigrationTask(long delaySeconds) { if (nodeEngine.getLocalMember().isLiteMember()) { return; } nodeEngine.getExecutionService().schedule(CRDT_REPLICATION_MIGRATION_EXECUTOR, new CRDTMigrationTask(nodeEngine, this), delaySeconds, TimeUnit.SECONDS); }
@Override void executeBeforeMigrations() throws Exception { NodeEngine nodeEngine = getNodeEngine(); PartitionReplica source = migrationInfo.getSource(); boolean ownerMigration = source != null && source.isIdentical(nodeEngine.getLocalMember()); if (!ownerMigration) { return; } super.executeBeforeMigrations(); }
public ReplicatedRecordStore getReplicatedRecordStore(String name, boolean create, int partitionId) { if (nodeEngine.getLocalMember().isLiteMember()) { throw new ReplicatedMapCantBeCreatedOnLiteMemberException(nodeEngine.getThisAddress()); } PartitionContainer partitionContainer = partitionContainers[partitionId]; if (create) { return partitionContainer.getOrCreateRecordStore(name); } return partitionContainer.getRecordStore(name); }
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(); }
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(); }
public XATransaction(NodeEngine nodeEngine, Xid xid, String txOwnerUuid, int timeout, boolean originatedFromClient) { this.nodeEngine = nodeEngine; this.transactionLog = new TransactionLog(); this.timeoutMillis = SECONDS.toMillis(timeout); this.txnId = UuidUtil.newUnsecureUuidString(); this.xid = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); this.txOwnerUuid = txOwnerUuid == null ? nodeEngine.getLocalMember().getUuid() : txOwnerUuid; ILogger logger = nodeEngine.getLogger(getClass()); this.commitExceptionHandler = logAllExceptions(logger, "Error during commit!", Level.WARNING); this.rollbackExceptionHandler = logAllExceptions(logger, "Error during rollback!", Level.WARNING); this.originatedFromClient = originatedFromClient; }
/** Sends a {@link MigrationEvent} to registered listeners with status {@code status}. */ void sendMigrationEvent(final MigrationStatus status) { final int partitionId = getPartitionId(); final NodeEngine nodeEngine = getNodeEngine(); final Member localMember = nodeEngine.getLocalMember(); final MigrationEvent event = new MigrationEvent(partitionId, null, localMember, status); final EventService eventService = nodeEngine.getEventService(); final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC); eventService.publishEvent(SERVICE_NAME, registrations, event, partitionId); }
@Override public ExceptionAction onInvocationException(Throwable throwable) { if (throwable instanceof CacheNotExistsException) { ICacheService cacheService = getService(); if (cacheService.getCacheConfig(name) != null) { getLogger().finest("Retry Cache Operation from node " + getNodeEngine().getLocalMember()); return ExceptionAction.RETRY_INVOCATION; } } return super.onInvocationException(throwable); }
@Override public ExceptionAction onInvocationException(Throwable throwable) { if (throwable instanceof CacheNotExistsException) { ICacheService cacheService = getService(); if (cacheService.getCacheConfig(name) != null) { getLogger().finest("Retry Cache Operation from node " + getNodeEngine().getLocalMember()); return ExceptionAction.RETRY_INVOCATION; } } return super.onInvocationException(throwable); }
/** Verifies that this node is the owner of the partition. */ private void verifyPartitionOwner() { InternalPartition partition = getPartition(); PartitionReplica owner = partition.getOwnerReplicaOrNull(); if (owner == null) { throw new RetryableHazelcastException("Cannot migrate at the moment! Owner of the partition is null => " + migrationInfo); } if (!owner.isIdentical(getNodeEngine().getLocalMember())) { throw new RetryableHazelcastException("Owner of partition is not this node! => " + toString()); } }
@Override protected Operation newPrimaryExpiryOp(int expirationPercentage, CachePartitionSegment container) { return new CacheClearExpiredOperation(expirationPercentage) .setNodeEngine(nodeEngine) .setCallerUuid(nodeEngine.getLocalMember().getUuid()) .setPartitionId(container.getPartitionId()) .setValidateTarget(false) .setServiceName(SERVICE_NAME); }
@Override protected Operation newPrimaryExpiryOp(int expirationPercentage, PartitionContainer container) { int partitionId = container.getPartitionId(); return new ClearExpiredOperation(expirationPercentage) .setNodeEngine(nodeEngine) .setCallerUuid(nodeEngine.getLocalMember().getUuid()) .setPartitionId(partitionId) .setValidateTarget(false) .setServiceName(SERVICE_NAME); }
private RepairingTask createRepairingInvalidationTask() { ExecutionService executionService = nodeEngine.getExecutionService(); ClusterService clusterService = nodeEngine.getClusterService(); OperationService operationService = nodeEngine.getOperationService(); HazelcastProperties properties = nodeEngine.getProperties(); ILogger metadataFetcherLogger = nodeEngine.getLogger(MemberMapInvalidationMetaDataFetcher.class); InvalidationMetaDataFetcher invalidationMetaDataFetcher = new MemberMapInvalidationMetaDataFetcher(clusterService, operationService, metadataFetcherLogger); ILogger repairingTaskLogger = nodeEngine.getLogger(RepairingTask.class); String localUuid = nodeEngine.getLocalMember().getUuid(); return new RepairingTask(properties, invalidationMetaDataFetcher, executionService.getGlobalTaskScheduler(), serializationService, partitionService, localUuid, repairingTaskLogger); }