Search in sources :

Example 41 with NodeEngine

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

the class BasicRecordStoreLoader method sendOperation.

/**
 * Invokes an operation to put the provided key-value pairs to the partition
 * record store.
 *
 * @param loadingSequence the list of serialised key-value-(expirationTime)
 *                        sequences
 * @return the future representing the pending completion of the put operation
 */
private Future<?> sendOperation(List<Data> loadingSequence) {
    OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    Operation operation = createOperation(loadingSequence);
    operation.setNodeEngine(nodeEngine);
    operation.setPartitionId(partitionId);
    OperationAccessor.setCallerAddress(operation, nodeEngine.getThisAddress());
    operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
    operation.setServiceName(MapService.SERVICE_NAME);
    return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)

Example 42 with NodeEngine

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

the class MultiMapProxySupport method invoke.

private <T> T invoke(Operation operation, Data dataKey) {
    NodeEngine nodeEngine = getNodeEngine();
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey);
        Object result;
        if (config.isStatisticsEnabled()) {
            long startTimeNanos = Timer.nanos();
            Future future;
            future = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
            result = future.get();
            incrementOperationStats(startTimeNanos, name, operation);
        } else {
            Future future = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
            result = future.get();
        }
        return nodeEngine.toObject(result);
    } catch (Throwable throwable) {
        throw ExceptionUtil.rethrow(throwable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) CompletableFuture(java.util.concurrent.CompletableFuture) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject)

Example 43 with NodeEngine

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

the class MultiMapPartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    NodeEngine nodeEngine = service.getNodeEngine();
    LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        DistributedObjectNamespace namespace = new DistributedObjectNamespace(MultiMapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) DistributedObjectNamespace(com.hazelcast.internal.services.DistributedObjectNamespace) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService)

Example 44 with NodeEngine

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

the class MultiMapProxySupport method keySetInternal.

protected Set<Data> keySetInternal() {
    NodeEngine nodeEngine = getNodeEngine();
    try {
        Map<Integer, Object> results = nodeEngine.getOperationService().invokeOnAllPartitions(MultiMapService.SERVICE_NAME, new MultiMapOperationFactory(name, OperationFactoryType.KEY_SET));
        Set<Data> keySet = new HashSet<>();
        for (Object result : results.values()) {
            if (result == null) {
                continue;
            }
            MultiMapResponse response = nodeEngine.toObject(result);
            if (response.getCollection() != null) {
                keySet.addAll(response.getCollection());
            }
        }
        return keySet;
    } catch (Throwable throwable) {
        throw ExceptionUtil.rethrow(throwable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MultiMapOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapOperationFactory) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) Data(com.hazelcast.internal.serialization.Data) HashSet(java.util.HashSet)

Example 45 with NodeEngine

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

the class RequestMapDataOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    Address callerAddress = getCallerAddress();
    int partitionId = getPartitionId();
    NodeEngine nodeEngine = getNodeEngine();
    if (logger.isFineEnabled()) {
        logger.fine("Caller " + callerAddress + " requested copy of replicated map '" + name + "' (partitionId " + partitionId + ") from " + nodeEngine.getThisAddress());
    }
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(partitionId);
    ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
    store.setLoaded(true);
    if (nodeEngine.getThisAddress().equals(callerAddress)) {
        return;
    }
    long version = store.getVersion();
    Set<RecordMigrationInfo> recordSet = getRecordSet(store);
    Operation op = new SyncReplicatedMapDataOperation(name, recordSet, version).setPartitionId(partitionId).setValidateTarget(false);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
Also used : Address(com.hazelcast.cluster.Address) PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Operation(com.hazelcast.spi.impl.operationservice.Operation) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) NodeEngine(com.hazelcast.spi.impl.NodeEngine) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9