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);
}
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations