Search in sources :

Example 1 with MapOperation

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

the class MapReplicationSupportingService method handleRemove.

private void handleRemove(MapReplicationRemove replicationRemove) {
    String mapName = replicationRemove.getMapName();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    MapOperation operation = operationProvider.createRemoveOperation(replicationRemove.getMapName(), replicationRemove.getKey(), true);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(replicationRemove.getKey());
        Future f = nodeEngine.getOperationService().invokeOnPartition(SERVICE_NAME, operation, partitionId);
        f.get();
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 2 with MapOperation

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

the class MapProxySupport method removeAsyncInternal.

protected InternalCompletableFuture<Data> removeAsyncInternal(Data key) {
    int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
    MapOperation operation = operationProvider.createRemoveOperation(name, key, false);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        long startTime = System.currentTimeMillis();
        InternalCompletableFuture<Data> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
        if (statisticsEnabled) {
            future.andThen(new IncrementStatsExecutionCallback<Data>(operation, startTime));
        }
        return future;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 3 with MapOperation

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

the class MapProxySupport method executeOnKeyInternal.

public Data executeOnKeyInternal(Data key, EntryProcessor entryProcessor) {
    int partitionId = partitionService.getPartitionId(key);
    MapOperation operation = operationProvider.createEntryOperation(name, key, entryProcessor);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        Future future = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).invoke();
        return (Data) future.get();
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 4 with MapOperation

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

the class MapProxySupport method setInternal.

//warning: When UpdateEvent is fired it does *NOT* contain oldValue.
//see this: https://github.com/hazelcast/hazelcast/pull/6088#issuecomment-136025968
protected void setInternal(Data key, Data value, long ttl, TimeUnit timeunit) {
    MapOperation operation = operationProvider.createSetOperation(name, key, value, timeunit.toMillis(ttl));
    invokeOperation(key, operation);
}
Also used : MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 5 with MapOperation

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

the class MapProxySupport method getAsyncInternal.

protected InternalCompletableFuture<Data> getAsyncInternal(Data key) {
    int partitionId = partitionService.getPartitionId(key);
    MapOperation operation = operationProvider.createGetOperation(name, key);
    try {
        long startTime = System.currentTimeMillis();
        InternalCompletableFuture<Data> future = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).invoke();
        if (statisticsEnabled) {
            future.andThen(new IncrementStatsExecutionCallback<Data>(operation, startTime));
        }
        return future;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

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