Search in sources :

Example 11 with MapOperation

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

the class TransactionalMapProxySupport method putIfAbsentInternal.

public Data putIfAbsentInternal(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 versionedValue.value;
        }
        addUnlockTransactionRecord(key, versionedValue.version);
        return versionedValue.value;
    }
    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 12 with MapOperation

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

the class TransactionalMapProxySupport method getInternal.

public Object getInternal(Data key) {
    if (nearCacheEnabled) {
        Object value = getCachedValue(key, true);
        if (value != NOT_CACHED) {
            return value;
        }
    }
    MapOperation operation = operationProvider.createGetOperation(name, key);
    operation.setThreadId(ThreadUtil.getThreadId());
    int partitionId = partitionService.getPartitionId(key);
    try {
        Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
        return future.get();
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : Future(java.util.concurrent.Future) TransactionalDistributedObject(com.hazelcast.spi.TransactionalDistributedObject) TransactionalObject(com.hazelcast.transaction.TransactionalObject) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 13 with MapOperation

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

the class MapContainsKeyMessageTask method prepareOperation.

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

Example 14 with MapOperation

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

the class MapGetEntryViewMessageTask method prepareOperation.

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

Example 15 with MapOperation

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

the class MapPutIfAbsentWithMaxIdleMessageTask method prepareOperation.

protected Operation prepareOperation() {
    MapOperationProvider operationProvider = getMapOperationProvider(parameters.name);
    MapOperation op = operationProvider.createPutIfAbsentOperation(parameters.name, parameters.key, parameters.value, parameters.ttl, parameters.maxIdle);
    op.setThreadId(parameters.threadId);
    return op;
}
Also used : MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) 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