Search in sources :

Example 56 with Member

use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.

the class InternalPartitionServiceImpl method checkClusterPartitionRuntimeStates.

void checkClusterPartitionRuntimeStates() {
    if (!partitionStateManager.isInitialized()) {
        return;
    }
    if (!isLocalMemberMaster()) {
        return;
    }
    if (!areMigrationTasksAllowed()) {
        // migration is disabled because of a member leave, wait till enabled!
        return;
    }
    long stamp = getPartitionStateStamp();
    if (logger.isFineEnabled()) {
        logger.fine("Checking partition state, stamp: " + stamp);
    }
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = node.clusterService.getMembers();
    for (Member member : members) {
        if (!member.localMember()) {
            PartitionStateCheckOperation op = new PartitionStateCheckOperation(stamp);
            InvocationFuture<Boolean> future = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
            future.whenCompleteAsync((response, throwable) -> {
                if (throwable == null) {
                    if (!Boolean.TRUE.equals(response)) {
                        logger.fine(member + " has a stale partition state. Will send the most recent partition state now.");
                        sendPartitionRuntimeState(member.getAddress());
                    }
                } else {
                    logger.fine("Failure while checking partition state on " + member, throwable);
                    sendPartitionRuntimeState(member.getAddress());
                }
            });
        }
    }
}
Also used : PartitionStateCheckOperation(com.hazelcast.internal.partition.operation.PartitionStateCheckOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Member(com.hazelcast.cluster.Member)

Example 57 with Member

use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.

the class PartitionServiceProxy method isClusterSafe.

@Override
public boolean isClusterSafe() {
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    if (members == null || members.isEmpty()) {
        return true;
    }
    final Collection<Future<Boolean>> futures = new ArrayList<>(members.size());
    for (Member member : members) {
        final Address target = member.getAddress();
        final Operation operation = new SafeStateCheckOperation();
        final Future<Boolean> future = nodeEngine.getOperationService().invokeOnTarget(InternalPartitionService.SERVICE_NAME, operation, target);
        futures.add(future);
    }
    // todo this max wait is appropriate?
    final int maxWaitTime = getMaxWaitTime();
    Collection<Boolean> results = FutureUtil.returnWithDeadline(futures, maxWaitTime, TimeUnit.SECONDS, exceptionHandler);
    if (results.size() != futures.size()) {
        return false;
    }
    for (Boolean result : results) {
        if (!result) {
            return false;
        }
    }
    return true;
}
Also used : Address(com.hazelcast.cluster.Address) SafeStateCheckOperation(com.hazelcast.internal.partition.operation.SafeStateCheckOperation) ArrayList(java.util.ArrayList) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) Future(java.util.concurrent.Future) Operation(com.hazelcast.spi.impl.operationservice.Operation) SafeStateCheckOperation(com.hazelcast.internal.partition.operation.SafeStateCheckOperation) Member(com.hazelcast.cluster.Member)

Example 58 with Member

use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchMapPartitionLostEventData.

private void dispatchMapPartitionLostEventData(MapPartitionEventData eventData, ListenerAdapter listener) {
    Member member = getMember(eventData);
    MapPartitionLostEvent event = createMapPartitionLostEventData(eventData, member);
    callListener(listener, event);
}
Also used : MapPartitionLostEvent(com.hazelcast.map.MapPartitionLostEvent) Member(com.hazelcast.cluster.Member)

Example 59 with Member

use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchMapEventData.

private void dispatchMapEventData(MapEventData mapEventData, ListenerAdapter listener) {
    Member member = getMember(mapEventData);
    MapEvent event = createMapEvent(mapEventData, member);
    callListener(listener, event);
}
Also used : EventPublisherHelper.createIMapEvent(com.hazelcast.map.impl.querycache.subscriber.EventPublisherHelper.createIMapEvent) BatchIMapEvent(com.hazelcast.map.impl.querycache.event.BatchIMapEvent) IMapEvent(com.hazelcast.map.IMapEvent) SingleIMapEvent(com.hazelcast.map.impl.querycache.event.SingleIMapEvent) MapEvent(com.hazelcast.map.MapEvent) Member(com.hazelcast.cluster.Member)

Example 60 with Member

use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.

the class NodeQueryCacheEndToEndConstructor method madePublishable.

private void madePublishable(String mapName, String cacheId) {
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    Collection<Member> memberList = context.getMemberList();
    List<Future> futures = new ArrayList<>(memberList.size());
    for (Member member : memberList) {
        Operation operation = new MadePublishableOperation(mapName, cacheId);
        Future future = invokerWrapper.invokeOnTarget(operation, member);
        futures.add(future);
    }
    waitWithDeadline(futures, OPERATION_WAIT_TIMEOUT_MINUTES, MINUTES);
}
Also used : MadePublishableOperation(com.hazelcast.map.impl.querycache.subscriber.operation.MadePublishableOperation) InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) MadePublishableOperation(com.hazelcast.map.impl.querycache.subscriber.operation.MadePublishableOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Aggregations

Member (com.hazelcast.cluster.Member)429 Test (org.junit.Test)210 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)164 HazelcastInstance (com.hazelcast.core.HazelcastInstance)116 IExecutorService (com.hazelcast.core.IExecutorService)73 Address (com.hazelcast.cluster.Address)62 ArrayList (java.util.ArrayList)55 Future (java.util.concurrent.Future)53 UUID (java.util.UUID)43 Config (com.hazelcast.config.Config)42 CountDownLatch (java.util.concurrent.CountDownLatch)38 Map (java.util.Map)33 HashMap (java.util.HashMap)31 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)28 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)25 List (java.util.List)25 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)24 Operation (com.hazelcast.spi.impl.operationservice.Operation)24 IMap (com.hazelcast.map.IMap)23