Search in sources :

Example 11 with OperationService

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

the class CacheDestroyOperation method destroyCacheOnAllMembers.

private void destroyCacheOnAllMembers(String name, String callerUuid) {
    NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    for (Member member : members) {
        if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
            CacheDestroyOperation op = new CacheDestroyOperation(name, true);
            operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 12 with OperationService

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

the class CollectionService method rollbackTransaction.

@Override
public void rollbackTransaction(String transactionId) {
    final Set<String> collectionNames = getContainerMap().keySet();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();
    for (String name : collectionNames) {
        int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
        Operation operation = new CollectionTransactionRollbackOperation(name, transactionId).setPartitionId(partitionId).setService(this).setNodeEngine(nodeEngine);
        operationService.execute(operation);
    }
}
Also used : CollectionTransactionRollbackOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTransactionRollbackOperation) IPartitionService(com.hazelcast.spi.partition.IPartitionService) OperationService(com.hazelcast.spi.OperationService) CollectionTransactionRollbackOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTransactionRollbackOperation) Operation(com.hazelcast.spi.Operation) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 13 with OperationService

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

the class DurableExecutorServiceProxy method shutdown.

@Override
public void shutdown() {
    NodeEngine nodeEngine = getNodeEngine();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> calls = new LinkedList<Future>();
    for (Member member : members) {
        if (member.localMember()) {
            getService().shutdownExecutor(name);
        } else {
            ShutdownOperation op = new ShutdownOperation(name);
            Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
            calls.add(f);
        }
    }
    waitWithDeadline(calls, 1, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) DurableExecutorServiceFuture(com.hazelcast.durableexecutor.DurableExecutorServiceFuture) DelegatingFuture(com.hazelcast.util.executor.DelegatingFuture) Future(java.util.concurrent.Future) CompletedFuture(com.hazelcast.util.executor.CompletedFuture) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Example 14 with OperationService

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

the class AbstractJoiner method startClusterMerge.

protected void startClusterMerge(final Address targetAddress) {
    ClusterServiceImpl clusterService = node.clusterService;
    if (!prepareClusterState(clusterService)) {
        return;
    }
    OperationService operationService = node.nodeEngine.getOperationService();
    Collection<Member> memberList = clusterService.getMembers();
    Collection<Future> futures = new ArrayList<Future>(memberList.size());
    for (Member member : memberList) {
        if (!member.localMember()) {
            Operation op = new MergeClustersOperation(targetAddress);
            Future<Object> future = operationService.invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, member.getAddress());
            futures.add(future);
        }
    }
    waitWithDeadline(futures, SPLIT_BRAIN_MERGE_TIMEOUT_SECONDS, TimeUnit.SECONDS, splitBrainMergeExceptionHandler);
    Operation mergeClustersOperation = new MergeClustersOperation(targetAddress);
    mergeClustersOperation.setNodeEngine(node.nodeEngine).setService(clusterService).setOperationResponseHandler(createEmptyResponseHandler());
    operationService.run(mergeClustersOperation);
}
Also used : ArrayList(java.util.ArrayList) MergeClustersOperation(com.hazelcast.internal.cluster.impl.operations.MergeClustersOperation) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.OperationService) SplitBrainMergeValidationOperation(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation) MemberRemoveOperation(com.hazelcast.internal.cluster.impl.operations.MemberRemoveOperation) MergeClustersOperation(com.hazelcast.internal.cluster.impl.operations.MergeClustersOperation) Operation(com.hazelcast.spi.Operation) Member(com.hazelcast.core.Member)

Example 15 with OperationService

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

the class ClusterJoinManager method ensureValidConfiguration.

private boolean ensureValidConfiguration(JoinMessage joinMessage) {
    Address address = joinMessage.getAddress();
    try {
        if (isValidJoinMessage(joinMessage)) {
            return true;
        }
        logger.warning(format("Received an invalid join request from %s, cause: clusters part of different cluster-groups", address));
        nodeEngine.getOperationService().send(new GroupMismatchOperation(), address);
    } catch (ConfigMismatchException e) {
        logger.warning(format("Received an invalid join request from %s, cause: %s", address, e.getMessage()));
        OperationService operationService = nodeEngine.getOperationService();
        operationService.send(new ConfigMismatchOperation(e.getMessage()), address);
    }
    return false;
}
Also used : Address(com.hazelcast.nio.Address) ConfigMismatchOperation(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation) OperationService(com.hazelcast.spi.OperationService) GroupMismatchOperation(com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation)

Aggregations

OperationService (com.hazelcast.spi.OperationService)135 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)48 ParallelTest (com.hazelcast.test.annotation.ParallelTest)46 HazelcastInstance (com.hazelcast.core.HazelcastInstance)45 Operation (com.hazelcast.spi.Operation)39 NodeEngine (com.hazelcast.spi.NodeEngine)30 Address (com.hazelcast.nio.Address)26 Future (java.util.concurrent.Future)26 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)24 Config (com.hazelcast.config.Config)21 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)21 Member (com.hazelcast.core.Member)19 Data (com.hazelcast.nio.serialization.Data)14 ArrayList (java.util.ArrayList)11 Node (com.hazelcast.instance.Node)7 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)7 ExecutionException (java.util.concurrent.ExecutionException)7 TimeoutException (java.util.concurrent.TimeoutException)7 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)6