Search in sources :

Example 81 with Operation

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

the class QueueService method rollbackTransaction.

@Override
public void rollbackTransaction(UUID transactionId) {
    final Set<String> queueNames = containerMap.keySet();
    OperationService operationService = nodeEngine.getOperationService();
    for (String name : queueNames) {
        int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
        Operation operation = new QueueTransactionRollbackOperation(name, transactionId).setPartitionId(partitionId).setService(this).setNodeEngine(nodeEngine);
        operationService.invokeOnPartition(operation);
    }
}
Also used : QueueTransactionRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.QueueTransactionRollbackOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) QueueTransactionRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.QueueTransactionRollbackOperation) QueueMergeOperation(com.hazelcast.collection.impl.queue.operations.QueueMergeOperation) QueueReplicationOperation(com.hazelcast.collection.impl.queue.operations.QueueReplicationOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint)

Example 82 with Operation

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

the class FinalizeJoinOp method sendPostJoinOperationsBackToMaster.

private void sendPostJoinOperationsBackToMaster() {
    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!
    Collection<Operation> postJoinOperations = nodeEngine.getPostJoinOperations();
    if (postJoinOperations != null && !postJoinOperations.isEmpty()) {
        final OperationService operationService = nodeEngine.getOperationService();
        // send post join operations to master and it will broadcast it to all members
        Address masterAddress = clusterService.getMasterAddress();
        OnJoinOp operation = new OnJoinOp(postJoinOperations);
        operationService.invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, operation, masterAddress);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.cluster.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 83 with Operation

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

the class OnJoinOp method run.

@Override
public void run() throws Exception {
    if (!operations.isEmpty()) {
        SecurityConfig securityConfig = getNodeEngine().getConfig().getSecurityConfig();
        boolean runPermissionUpdates = securityConfig.getOnJoinPermissionOperation() == OnJoinPermissionOperationName.RECEIVE;
        for (Operation op : operations) {
            if ((op instanceof UpdatePermissionConfigOperation) && !runPermissionUpdates) {
                continue;
            }
            try {
                // not running via OperationService since we don't want any restrictions like cluster state check etc.
                runDirect(op);
            } catch (Exception e) {
                getLogger().warning("Error while running post-join operation: " + op, e);
            }
        }
        final ClusterService clusterService = getService();
        // if executed on master, broadcast to all other members except sender (joining member)
        if (clusterService.isMaster()) {
            final OperationService operationService = getNodeEngine().getOperationService();
            for (Member member : clusterService.getMembers()) {
                if (!member.localMember() && !member.getUuid().equals(getCallerUuid())) {
                    OnJoinOp operation = new OnJoinOp(operations);
                    operationService.invokeOnTarget(getServiceName(), operation, member.getAddress());
                }
            }
        }
    }
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) SecurityConfig(com.hazelcast.config.SecurityConfig) UpdatePermissionConfigOperation(com.hazelcast.internal.management.operation.UpdatePermissionConfigOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) UpdatePermissionConfigOperation(com.hazelcast.internal.management.operation.UpdatePermissionConfigOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member) IOException(java.io.IOException)

Example 84 with Operation

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

the class OnJoinOp method beforeRun.

@Override
public void beforeRun() throws Exception {
    if (!operations.isEmpty()) {
        NodeEngine nodeEngine = getNodeEngine();
        OperationResponseHandler responseHandler = createErrorLoggingResponseHandler(getLogger());
        for (Operation op : operations) {
            op.setNodeEngine(nodeEngine);
            op.setOperationResponseHandler(responseHandler);
            OperationAccessor.setCallerAddress(op, getCallerAddress());
            OperationAccessor.setConnection(op, getConnection());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Operation(com.hazelcast.spi.impl.operationservice.Operation) UpdatePermissionConfigOperation(com.hazelcast.internal.management.operation.UpdatePermissionConfigOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) OperationResponseHandler(com.hazelcast.spi.impl.operationservice.OperationResponseHandler)

Example 85 with Operation

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

the class AbstractMultiTargetMessageTask method processInternal.

@Override
protected CompletableFuture<Object> processInternal() {
    Supplier<Operation> operationSupplier = createOperationSupplier();
    Collection<Member> targets = getTargets();
    CompletableFuture<Object> finalResult = new CompletableFuture<>();
    if (targets.isEmpty()) {
        finalResult.complete(EMPTY_MAP);
        return finalResult;
    }
    final OperationServiceImpl operationService = nodeEngine.getOperationService();
    MultiTargetCallback callback = new MultiTargetCallback(targets, finalResult);
    for (Member target : targets) {
        Operation op = operationSupplier.get();
        op.setCallerUuid(endpoint.getUuid());
        InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, target.getAddress()).setResultDeserialized(false);
        InvocationFuture<Object> invocationFuture = builder.invoke();
        invocationFuture.whenCompleteAsync(new SingleTargetCallback(target, callback), CALLER_RUNS);
    }
    return finalResult;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Operation(com.hazelcast.spi.impl.operationservice.Operation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) Member(com.hazelcast.cluster.Member) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)271 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)79 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)56 Address (com.hazelcast.cluster.Address)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)25 Data (com.hazelcast.internal.serialization.Data)24 Future (java.util.concurrent.Future)24 Member (com.hazelcast.cluster.Member)22 ArrayList (java.util.ArrayList)21 NodeEngine (com.hazelcast.spi.impl.NodeEngine)18 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)17 AssertTask (com.hazelcast.test.AssertTask)15 ILogger (com.hazelcast.logging.ILogger)14 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Config (com.hazelcast.config.Config)12 CompletableFuture (java.util.concurrent.CompletableFuture)12