Search in sources :

Example 41 with MapOperation

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

the class TransactionalMapProxySupport method containsKeyInternal.

public boolean containsKeyInternal(Data key) {
    MapOperation operation = operationProvider.createContainsKeyOperation(name, key);
    operation.setThreadId(ThreadUtil.getThreadId());
    int partitionId = partitionService.getPartitionId(key);
    try {
        Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
        return (Boolean) future.get();
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 42 with MapOperation

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

the class MapProxySupport method putTransientInternal.

protected void putTransientInternal(Data key, Data value, long ttl, TimeUnit timeunit) {
    MapOperation operation = operationProvider.createPutTransientOperation(name, key, value, getTimeInMillis(ttl, timeunit));
    invokeOperation(key, operation);
}
Also used : MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 43 with MapOperation

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

the class MapProxySupport method getInternal.

protected Object getInternal(Data key) {
    // todo action for read-backup true is not well tested.
    if (getMapConfig().isReadBackupData()) {
        Object fromBackup = readBackupDataOrNull(key);
        if (fromBackup != null) {
            return fromBackup;
        }
    }
    MapOperation operation = operationProvider.createGetOperation(name, key);
    operation.setThreadId(ThreadUtil.getThreadId());
    return invokeOperation(key, operation);
}
Also used : AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 44 with MapOperation

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

the class MapKeyLoader method sendBatch.

private List<Future> sendBatch(Map<Integer, List<Data>> batch, boolean replaceExistingValues) {
    Set<Entry<Integer, List<Data>>> entries = batch.entrySet();
    List<Future> futures = new ArrayList<Future>(entries.size());
    for (Entry<Integer, List<Data>> e : entries) {
        int partitionId = e.getKey();
        List<Data> keys = e.getValue();
        MapOperation op = operationProvider.createLoadAllOperation(mapName, keys, replaceExistingValues);
        InternalCompletableFuture<Object> future = opService.invokeOnPartition(SERVICE_NAME, op, partitionId);
        futures.add(future);
    }
    return futures;
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Entry(java.util.Map.Entry) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Future(java.util.concurrent.Future) AbstractCompletableFuture(com.hazelcast.spi.impl.AbstractCompletableFuture) ArrayList(java.util.ArrayList) List(java.util.List)

Example 45 with MapOperation

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

the class MapReplicationSupportingService method handleUpdate.

private void handleUpdate(MapReplicationUpdate replicationUpdate) {
    EntryView entryView = replicationUpdate.getEntryView();
    MapMergePolicy mergePolicy = replicationUpdate.getMergePolicy();
    String mapName = replicationUpdate.getMapName();
    MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    Data dataKey = mapServiceContext.toData(entryView.getKey(), mapContainer.getPartitioningStrategy());
    MapOperation operation = operationProvider.createMergeOperation(mapName, dataKey, entryView, mergePolicy, true);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(entryView.getKey());
        Future f = nodeEngine.getOperationService().invokeOnPartition(SERVICE_NAME, operation, partitionId);
        f.get();
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) Future(java.util.concurrent.Future) Data(com.hazelcast.nio.serialization.Data) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapMergePolicy(com.hazelcast.map.merge.MapMergePolicy) 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