Search in sources :

Example 41 with NodeEngine

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

the class ObjectMultiMapProxy method addEntryListener.

@Override
public String addEntryListener(EntryListener<K, V> listener, K key, boolean includeValue) {
    final NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    return getService().addListener(name, listener, dataKey, includeValue, false);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Data(com.hazelcast.nio.serialization.Data)

Example 42 with NodeEngine

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

the class TransactionalMultiMapProxySupport method nextId.

private long nextId(Data key) {
    final NodeEngine nodeEngine = getNodeEngine();
    TxnGenerateRecordIdOperation operation = new TxnGenerateRecordIdOperation(name, key);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
        final OperationService operationService = nodeEngine.getOperationService();
        Future<Long> f = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
        return f.get();
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService)

Example 43 with NodeEngine

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

the class TransactionalMultiMapProxySupport method lockAndGet.

private MultiMapResponse lockAndGet(Data key, long timeout, long ttl) {
    final NodeEngine nodeEngine = getNodeEngine();
    boolean blockReads = tx.getTransactionType() == TransactionType.ONE_PHASE;
    TxnLockAndGetOperation operation = new TxnLockAndGetOperation(name, key, timeout, ttl, getThreadId(), blockReads);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
        final OperationService operationService = nodeEngine.getOperationService();
        Future<MultiMapResponse> f = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
        return f.get();
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) OperationService(com.hazelcast.spi.OperationService)

Example 44 with NodeEngine

use of com.hazelcast.spi.NodeEngine 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<Future>();
    for (Member member : members) {
        if (member.localMember()) {
            getService().shutdownExecutor(name);
        } else {
            Operation op = new ShutdownOperation(name);
            calls.add(operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress()));
        }
    }
    waitWithDeadline(calls, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Future(java.util.concurrent.Future) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.OperationService) GetAllScheduledOnMemberOperation(com.hazelcast.scheduledexecutor.impl.operations.GetAllScheduledOnMemberOperation) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) Operation(com.hazelcast.spi.Operation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Example 45 with NodeEngine

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

the class PartitionIteratingOperation method executeOperations.

private void executeOperations() {
    NodeEngine nodeEngine = getNodeEngine();
    OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions);
    OperationService operationService = nodeEngine.getOperationService();
    Object service = getServiceName() == null ? null : getService();
    for (int partitionId : partitions) {
        Operation operation = operationFactory.createOperation().setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(getReplicaIndex()).setOperationResponseHandler(responseHandler).setServiceName(getServiceName()).setService(service).setCallerUuid(extractCallerUuid());
        OperationAccessor.setCallerAddress(operation, getCallerAddress());
        operationService.execute(operation);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)157 Data (com.hazelcast.nio.serialization.Data)50 OperationService (com.hazelcast.spi.OperationService)30 Address (com.hazelcast.nio.Address)20 ILogger (com.hazelcast.logging.ILogger)14 Operation (com.hazelcast.spi.Operation)14 Member (com.hazelcast.core.Member)12 Future (java.util.concurrent.Future)12 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)11 IPartitionService (com.hazelcast.spi.partition.IPartitionService)11 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)10 Test (org.junit.Test)10 InitializingObject (com.hazelcast.spi.InitializingObject)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)7 Config (com.hazelcast.config.Config)6 ArrayList (java.util.ArrayList)6