Search in sources :

Example 6 with MapOperation

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

the class MapProxySupport method setAsyncInternal.

protected InternalCompletableFuture<Data> setAsyncInternal(Data key, Data value, long ttl, TimeUnit timeunit) {
    int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
    MapOperation operation = operationProvider.createSetOperation(name, key, value, getTimeInMillis(ttl, timeunit));
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        return operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 7 with MapOperation

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

the class MapProxySupport method putAsyncInternal.

protected InternalCompletableFuture<Data> putAsyncInternal(Data key, Data value, long ttl, TimeUnit timeunit) {
    int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
    MapOperation operation = operationProvider.createPutOperation(name, key, value, getTimeInMillis(ttl, timeunit));
    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 8 with MapOperation

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

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

the class TransactionalMapProxySupport method replaceInternal.

public Data replaceInternal(Data key, Data value) {
    boolean unlockImmediately = !valueMap.containsKey(key);
    VersionedValue versionedValue = lockAndGet(key, tx.getTimeoutMillis());
    if (versionedValue.value == null) {
        if (unlockImmediately) {
            unlock(key, versionedValue);
            return null;
        }
        addUnlockTransactionRecord(key, versionedValue.version);
        return null;
    }
    MapOperation operation = operationProvider.createTxnSetOperation(name, key, value, versionedValue.version, -1);
    tx.add(new MapTransactionLogRecord(name, key, getPartitionId(key), operation, versionedValue.version, tx.getOwnerUuid()));
    return versionedValue.value;
}
Also used : MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 10 with MapOperation

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

the class TransactionalMapProxySupport method replaceIfSameInternal.

public boolean replaceIfSameInternal(Data key, Object oldValue, Data newValue) {
    boolean unlockImmediately = !valueMap.containsKey(key);
    VersionedValue versionedValue = lockAndGet(key, tx.getTimeoutMillis());
    if (!isEquals(oldValue, versionedValue.value)) {
        if (unlockImmediately) {
            unlock(key, versionedValue);
            return false;
        }
        addUnlockTransactionRecord(key, versionedValue.version);
        return false;
    }
    MapOperation operation = operationProvider.createTxnSetOperation(name, key, newValue, versionedValue.version, -1);
    tx.add(new MapTransactionLogRecord(name, key, getPartitionId(key), operation, versionedValue.version, tx.getOwnerUuid()));
    return true;
}
Also used : 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