Search in sources :

Example 16 with OperationService

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

the class ReplicatedMapProxy method requestDataForPartition.

private void requestDataForPartition(int partitionId) {
    RequestMapDataOperation requestMapDataOperation = new RequestMapDataOperation(name);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, requestMapDataOperation, partitionId).setTryCount(ReplicatedMapService.INVOCATION_TRY_COUNT).invoke();
}
Also used : RequestMapDataOperation(com.hazelcast.replicatedmap.impl.operation.RequestMapDataOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 17 with OperationService

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

the class ScheduledExecutorServiceProxy method shutdown.

@Override
public void shutdown() {
    NodeEngine nodeEngine = getNodeEngine();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> calls = new LinkedList<>();
    for (Member member : members) {
        Operation op = new ShutdownOperation(name);
        calls.add(operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress()));
    }
    waitWithDeadline(calls, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Future(java.util.concurrent.Future) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) GetAllScheduledOnMemberOperation(com.hazelcast.scheduledexecutor.impl.operations.GetAllScheduledOnMemberOperation) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Example 18 with OperationService

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

the class WaitSet method unpark.

// Runs in partition-thread, and therefor we can assume we have exclusive access to the WaitNotifyKey
// (since each WaitNotifyKey is mapped to a single partition). So a park will not be concurrently
// executed with an unpark for the same key.
public void unpark(Notifier notifier, WaitNotifyKey key) {
    WaitSetEntry entry = queue.peek();
    while (entry != null) {
        Operation op = entry.getOperation();
        if (notifier == op) {
            throw new IllegalStateException("Found cyclic wait-notify! -> " + notifier);
        }
        if (entry.isValid()) {
            if (entry.isExpired()) {
                // expired
                entry.onExpire();
            } else if (entry.isCancelled()) {
                entry.onCancel();
            } else {
                if (entry.shouldWait()) {
                    return;
                }
                OperationService operationService = nodeEngine.getOperationService();
                operationService.run(op);
            }
            entry.setValid(false);
        }
        // consume
        queue.poll();
        entry = queue.peek();
        // We can safely remove this queue from registration map here.
        if (entry == null) {
            waitSetMap.remove(key);
        }
    }
}
Also used : BlockingOperation(com.hazelcast.spi.impl.operationservice.BlockingOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 19 with OperationService

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

the class TransactionImpl method replicateTxnLog.

private void replicateTxnLog() {
    if (skipBackupLogReplication()) {
        return;
    }
    OperationService operationService = nodeEngine.getOperationService();
    ClusterService clusterService = nodeEngine.getClusterService();
    List<Future> futures = new ArrayList<Future>(backupAddresses.length);
    for (Address backupAddress : backupAddresses) {
        if (clusterService.getMember(backupAddress) != null) {
            Operation op = createReplicateTxBackupLogOperation();
            Future f = operationService.invokeOnTarget(SERVICE_NAME, op, backupAddress);
            futures.add(f);
        }
    }
    waitWithDeadline(futures, timeoutMillis, MILLISECONDS, replicationTxExceptionHandler);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) PurgeTxBackupLogOperation(com.hazelcast.transaction.impl.operations.PurgeTxBackupLogOperation) ReplicateTxBackupLogOperation(com.hazelcast.transaction.impl.operations.ReplicateTxBackupLogOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) RollbackTxBackupLogOperation(com.hazelcast.transaction.impl.operations.RollbackTxBackupLogOperation) CreateTxBackupLogOperation(com.hazelcast.transaction.impl.operations.CreateTxBackupLogOperation)

Example 20 with OperationService

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

the class TransactionImpl method rollbackBackupLogs.

private void rollbackBackupLogs() {
    if (!backupLogsCreated) {
        return;
    }
    OperationService operationService = nodeEngine.getOperationService();
    ClusterService clusterService = nodeEngine.getClusterService();
    List<Future> futures = new ArrayList<Future>(backupAddresses.length);
    for (Address backupAddress : backupAddresses) {
        if (clusterService.getMember(backupAddress) != null) {
            Future f = operationService.invokeOnTarget(SERVICE_NAME, createRollbackTxBackupLogOperation(), backupAddress);
            futures.add(f);
        }
    }
    waitWithDeadline(futures, timeoutMillis, MILLISECONDS, rollbackTxExceptionHandler);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6