Search in sources :

Example 76 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapSubmitToKeyMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    EntryProcessor processor = serializationService.toObject(parameters.entryProcessor);
    MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
    MapOperation op = operationProvider.createEntryOperation(parameters.name, parameters.key, processor);
    op.setThreadId(parameters.threadId);
    return op;
}
Also used : EntryProcessor(com.hazelcast.map.EntryProcessor) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 77 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapTryPutMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
    MapOperation op = operationProvider.createTryPutOperation(parameters.name, parameters.key, parameters.value, parameters.timeout);
    op.setThreadId(parameters.threadId);
    return op;
}
Also used : MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 78 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class MapPutTransientMessageTask method prepareOperation.

@Override
protected Operation prepareOperation() {
    MapOperation op = newOperation(parameters.name, parameters.key, parameters.value, parameters.ttl);
    op.setThreadId(parameters.threadId);
    return op;
}
Also used : MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 79 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class HazelcastTestSupport method readFromMapBackup.

protected Object readFromMapBackup(HazelcastInstance instance, String mapName, Object key, int replicaIndex) {
    try {
        NodeEngine nodeEngine = Accessors.getNode(instance).getNodeEngine();
        SerializationService ss = Accessors.getNode(instance).getSerializationService();
        int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
        MapOperation get = getMapOperationProvider(instance, mapName).createGetOperation(mapName, ss.toData(key));
        get.setPartitionId(partitionId);
        get.setReplicaIndex(replicaIndex);
        return Accessors.getNode(instance).getNodeEngine().getOperationService().invokeOnPartition(get).get();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) SerializationService(com.hazelcast.internal.serialization.SerializationService) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) AssumptionViolatedException(org.junit.AssumptionViolatedException) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 80 with MapOperation

use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.

the class AbstractWanCustomPublisherMapTest method runMergeOpForWAN.

private void runMergeOpForWAN(boolean enableWANReplicationEvent) {
    // init hazelcast instances
    String mapName = "merge_operation_generates_wan_replication_event";
    initInstancesAndMap(mapName);
    // get internal services to use in this test
    HazelcastInstance node = instance1;
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(node);
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    OperationServiceImpl operationService = nodeEngineImpl.getOperationService();
    SerializationService serializationService = nodeEngineImpl.getSerializationService();
    MapService mapService = nodeEngineImpl.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    // prepare and send one merge operation
    Data data = serializationService.toData(1);
    MapOperation op;
    SimpleEntryView<Data, Data> entryView = new SimpleEntryView<Data, Data>().withKey(data).withValue(data);
    MapMergeTypes<Object, Object> mergingEntry = createMergingEntry(serializationService, entryView);
    SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object> mergePolicy = new com.hazelcast.spi.merge.PassThroughMergePolicy<>();
    op = operationProvider.createMergeOperation(mapName, mergingEntry, mergePolicy, !enableWANReplicationEvent);
    operationService.createInvocationBuilder(MapService.SERVICE_NAME, op, partitionService.getPartitionId(data)).invoke();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapOperation(com.hazelcast.map.impl.operation.MapOperation) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) MapService(com.hazelcast.map.impl.MapService) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Aggregations

MapOperation (com.hazelcast.map.impl.operation.MapOperation)80 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)25 Data (com.hazelcast.internal.serialization.Data)23 Future (java.util.concurrent.Future)16 Data (com.hazelcast.nio.serialization.Data)6 ArrayList (java.util.ArrayList)5 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)4 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 MapService (com.hazelcast.map.impl.MapService)3 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)3 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)3 AbstractDistributedObject (com.hazelcast.spi.impl.AbstractDistributedObject)3 InitializingObject (com.hazelcast.spi.impl.InitializingObject)3 InternalCompletableFuture.newCompletedFuture (com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture)3 InvocationFuture (com.hazelcast.spi.impl.operationservice.impl.InvocationFuture)3 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)3 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 EntryView (com.hazelcast.core.EntryView)2 EntryProcessor (com.hazelcast.map.EntryProcessor)2