Search in sources :

Example 11 with MapOperationProvider

use of com.hazelcast.map.impl.operation.MapOperationProvider 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 12 with MapOperationProvider

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

the class BasicRecordStoreLoader method createOperation.

private Operation createOperation(List<Data> keyValueSequence, final AtomicInteger finishedBatchCounter) {
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(name);
    MapOperation operation = operationProvider.createPutFromLoadAllOperation(name, keyValueSequence);
    operation.setNodeEngine(nodeEngine);
    operation.setOperationResponseHandler(new OperationResponseHandler() {

        @Override
        public void sendResponse(Operation op, Object obj) {
            if (finishedBatchCounter.decrementAndGet() == 0) {
                loaded.set(true);
            }
        }
    });
    operation.setPartitionId(partitionId);
    OperationAccessor.setCallerAddress(operation, nodeEngine.getThisAddress());
    operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
    operation.setServiceName(MapService.SERVICE_NAME);
    return operation;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Operation(com.hazelcast.spi.Operation) RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 13 with MapOperationProvider

use of com.hazelcast.map.impl.operation.MapOperationProvider 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)

Example 14 with MapOperationProvider

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

the class MapPartitionIterator method fetch.

protected List fetch() {
    String name = mapProxy.getName();
    String serviceName = mapProxy.getServiceName();
    MapOperationProvider operationProvider = mapProxy.getOperationProvider();
    OperationService operationService = mapProxy.getOperationService();
    if (prefetchValues) {
        MapOperation operation = operationProvider.createFetchEntriesOperation(name, lastTableIndex, fetchSize);
        InternalCompletableFuture<MapEntriesWithCursor> future = operationService.invokeOnPartition(serviceName, operation, partitionId);
        MapEntriesWithCursor mapEntriesWithCursor = future.join();
        setLastTableIndex(mapEntriesWithCursor.getEntries(), mapEntriesWithCursor.getNextTableIndexToReadFrom());
        return mapEntriesWithCursor.getEntries();
    } else {
        MapOperation operation = operationProvider.createFetchKeysOperation(name, lastTableIndex, fetchSize);
        InternalCompletableFuture<MapKeysWithCursor> future = operationService.invokeOnPartition(serviceName, operation, partitionId);
        MapKeysWithCursor mapKeysWithCursor = future.join();
        setLastTableIndex(mapKeysWithCursor.getKeys(), mapKeysWithCursor.getNextTableIndexToReadFrom());
        return mapKeysWithCursor.getKeys();
    }
}
Also used : OperationService(com.hazelcast.spi.OperationService) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 15 with MapOperationProvider

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

the class MapTryRemoveMessageTask method prepareOperation.

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

Aggregations

MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)25 MapOperation (com.hazelcast.map.impl.operation.MapOperation)20 EntryProcessor (com.hazelcast.map.EntryProcessor)4 Data (com.hazelcast.nio.serialization.Data)2 Predicate (com.hazelcast.query.Predicate)2 Future (java.util.concurrent.Future)2 EntryView (com.hazelcast.core.EntryView)1 MapEntries (com.hazelcast.map.impl.MapEntries)1 RemoveFromLoadAllOperation (com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)1 MapMergePolicy (com.hazelcast.map.merge.MapMergePolicy)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 Operation (com.hazelcast.spi.Operation)1 OperationResponseHandler (com.hazelcast.spi.OperationResponseHandler)1 OperationService (com.hazelcast.spi.OperationService)1