Search in sources :

Example 56 with Operation

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

the class OperationParkerImpl method shutdown.

public void shutdown() {
    logger.finest("Stopping tasks...");
    expirationTaskFuture.cancel(true);
    expirationExecutor.shutdown();
    final Object response = new HazelcastInstanceNotActiveException();
    final Address thisAddress = nodeEngine.getThisAddress();
    for (Queue<ParkedOperation> parkQueue : parkQueueMap.values()) {
        for (ParkedOperation parkedOperation : parkQueue) {
            if (!parkedOperation.isValid()) {
                continue;
            }
            Operation op = parkedOperation.getOperation();
            // only for local invocations, remote ones will be expired via #onMemberLeft()
            if (thisAddress.equals(op.getCallerAddress())) {
                try {
                    OperationResponseHandler responseHandler = op.getOperationResponseHandler();
                    responseHandler.sendResponse(op, response);
                } catch (Exception e) {
                    logger.finest("While sending HazelcastInstanceNotActiveException response...", e);
                }
            }
        }
        parkQueue.clear();
    }
    parkQueueMap.clear();
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) Address(com.hazelcast.nio.Address) BlockingOperation(com.hazelcast.spi.BlockingOperation) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException)

Example 57 with Operation

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

the class NodeStateTest method shouldReject_NormalOperationExecution_whilePassive.

@Test
public void shouldReject_NormalOperationExecution_whilePassive() throws Exception {
    InvocationTask task = new InvocationTask() {

        @Override
        public void invoke(NodeEngine nodeEngine) throws Exception {
            final CountDownLatch latch = new CountDownLatch(1);
            Operation op = new DummyOperation() {

                @Override
                public void onExecutionFailure(Throwable e) {
                    latch.countDown();
                }

                @Override
                public boolean returnsResponse() {
                    return false;
                }
            };
            nodeEngine.getOperationService().run(op);
            assertOpenEventually(latch);
        }
    };
    testInvocation_whilePassive(task);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Operation(com.hazelcast.spi.Operation) CountDownLatch(java.util.concurrent.CountDownLatch) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 58 with Operation

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

the class AbstractCacheProxy method getAsync.

@Override
public InternalCompletableFuture<V> getAsync(K key, ExpiryPolicy expiryPolicy) {
    ensureOpen();
    validateNotNull(key);
    Data keyData = serializationService.toData(key);
    Operation op = operationProvider.createGetOperation(keyData, expiryPolicy);
    return invoke(op, keyData, false);
}
Also used : Data(com.hazelcast.nio.serialization.Data) Operation(com.hazelcast.spi.Operation)

Example 59 with Operation

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

the class ReplicatedMapProxy method createPutAllOperationFuture.

private Future createPutAllOperationFuture(String name, ReplicatedMapEntries entrySet, int partitionId) {
    OperationService operationService = nodeEngine.getOperationService();
    Operation op = new PutAllOperation(name, entrySet);
    return operationService.invokeOnPartition(SERVICE_NAME, op, partitionId);
}
Also used : PutAllOperation(com.hazelcast.replicatedmap.impl.operation.PutAllOperation) OperationService(com.hazelcast.spi.OperationService) PutAllOperation(com.hazelcast.replicatedmap.impl.operation.PutAllOperation) RequestMapDataOperation(com.hazelcast.replicatedmap.impl.operation.RequestMapDataOperation) Operation(com.hazelcast.spi.Operation) RemoveOperation(com.hazelcast.replicatedmap.impl.operation.RemoveOperation) PutOperation(com.hazelcast.replicatedmap.impl.operation.PutOperation)

Example 60 with Operation

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

the class QueueService method rollbackTransaction.

@Override
public void rollbackTransaction(String transactionId) {
    final Set<String> queueNames = containerMap.keySet();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    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.execute(operation);
    }
}
Also used : QueueTransactionRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.QueueTransactionRollbackOperation) IPartitionService(com.hazelcast.spi.partition.IPartitionService) OperationService(com.hazelcast.spi.OperationService) QueueTransactionRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.QueueTransactionRollbackOperation) Operation(com.hazelcast.spi.Operation) QueueReplicationOperation(com.hazelcast.collection.impl.queue.operations.QueueReplicationOperation) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

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