Search in sources :

Example 71 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class ClusterStateManager method lockClusterStateOnAllMembers.

private void lockClusterStateOnAllMembers(ClusterStateChange stateChange, NodeEngineImpl nodeEngine, long leaseTime, String txnId, Collection<Member> members, int partitionStateVersion) {
    Collection<Future> futures = new ArrayList<Future>(members.size());
    final Address thisAddress = node.getThisAddress();
    for (Member member : members) {
        Operation op = new LockClusterStateOperation(stateChange, thisAddress, txnId, leaseTime, partitionStateVersion);
        Future future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, member.getAddress());
        futures.add(future);
    }
    StateManagerExceptionHandler exceptionHandler = new StateManagerExceptionHandler(logger);
    waitWithDeadline(futures, leaseTime, TimeUnit.MILLISECONDS, exceptionHandler);
    exceptionHandler.rethrowIfFailed();
}
Also used : LockClusterStateOperation(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOperation) Address(com.hazelcast.nio.Address) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) LockClusterStateOperation(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOperation) Operation(com.hazelcast.spi.Operation) Member(com.hazelcast.core.Member)

Example 72 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class PostJoinOperation method run.

@Override
public void run() throws Exception {
    if (operations != null && operations.length > 0) {
        for (final Operation op : operations) {
            op.beforeRun();
            op.run();
            op.afterRun();
        }
    }
}
Also used : Operation(com.hazelcast.spi.Operation) UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation)

Example 73 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class FinalizeJoinOperation method sendPostJoinOperations.

private void sendPostJoinOperations() {
    final ClusterServiceImpl clusterService = getService();
    final NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    // Post join operations must be lock free; means no locks at all;
    // no partition locks, no key-based locks, no service level locks!
    final Operation[] postJoinOperations = nodeEngine.getPostJoinOperations();
    final OperationService operationService = nodeEngine.getOperationService();
    if (postJoinOperations != null && postJoinOperations.length > 0) {
        final Collection<Member> members = clusterService.getMembers();
        for (Member member : members) {
            if (!member.localMember()) {
                PostJoinOperation operation = new PostJoinOperation(postJoinOperations);
                operationService.createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, operation, member.getAddress()).setTryCount(POST_JOIN_TRY_COUNT).invoke();
            }
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Operation(com.hazelcast.spi.Operation) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 74 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class MemberMapMetaDataFetcher method scanMembers.

@Override
protected List<InternalCompletableFuture> scanMembers(List<String> names) {
    Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
    List<InternalCompletableFuture> futures = new ArrayList<InternalCompletableFuture>(members.size());
    for (Member member : members) {
        Operation operation = new MapGetInvalidationMetaDataOperation(names);
        Address address = member.getAddress();
        try {
            futures.add(operationService.invokeOnTarget(SERVICE_NAME, operation, address));
        } catch (Exception e) {
            if (logger.isWarningEnabled()) {
                logger.warning("Cant fetch invalidation meta-data from address + " + address + " + [" + e.getMessage() + "]");
            }
        }
    }
    return futures;
}
Also used : Address(com.hazelcast.nio.Address) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) ArrayList(java.util.ArrayList) Operation(com.hazelcast.spi.Operation) MapGetInvalidationMetaDataOperation(com.hazelcast.map.impl.operation.MapGetInvalidationMetaDataOperation) MapGetInvalidationMetaDataOperation(com.hazelcast.map.impl.operation.MapGetInvalidationMetaDataOperation) Member(com.hazelcast.core.Member) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 75 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class PartitionIteratingOperation method executePartitionAwareOperations.

private void executePartitionAwareOperations(PartitionAwareOperationFactory givenFactory) {
    PartitionAwareOperationFactory factory = givenFactory.createFactoryOnRunner(getNodeEngine());
    NodeEngine nodeEngine = getNodeEngine();
    int[] operationFactoryPartitions = factory.getPartitions();
    partitions = operationFactoryPartitions == null ? partitions : operationFactoryPartitions;
    OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions);
    OperationService operationService = nodeEngine.getOperationService();
    Object service = getServiceName() == null ? null : getService();
    for (int partitionId : partitions) {
        Operation op = factory.createPartitionOperation(partitionId).setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(getReplicaIndex()).setOperationResponseHandler(responseHandler).setServiceName(getServiceName()).setService(service).setCallerUuid(extractCallerUuid());
        OperationAccessor.setCallerAddress(op, getCallerAddress());
        operationService.execute(op);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Aggregations

Operation (com.hazelcast.spi.Operation)94 OperationService (com.hazelcast.spi.OperationService)14 Member (com.hazelcast.core.Member)13 Address (com.hazelcast.nio.Address)11 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)8 ArrayList (java.util.ArrayList)8 ILogger (com.hazelcast.logging.ILogger)7 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)7 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 AcquireOperation (com.hazelcast.concurrent.semaphore.operations.AcquireOperation)6 AvailableOperation (com.hazelcast.concurrent.semaphore.operations.AvailableOperation)6 DrainOperation (com.hazelcast.concurrent.semaphore.operations.DrainOperation)6 InitOperation (com.hazelcast.concurrent.semaphore.operations.InitOperation)6 ReduceOperation (com.hazelcast.concurrent.semaphore.operations.ReduceOperation)6 ReleaseOperation (com.hazelcast.concurrent.semaphore.operations.ReleaseOperation)6 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)6 NodeEngine (com.hazelcast.spi.NodeEngine)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6