use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapProxySupport method getInternal.
protected Object getInternal(Object key) {
// TODO: action for read-backup true is not well tested
Data keyData = toDataWithStrategy(key);
if (mapConfig.isReadBackupData()) {
Object fromBackup = readBackupDataOrNull(keyData);
if (fromBackup != null) {
return fromBackup;
}
}
MapOperation operation = operationProvider.createGetOperation(name, keyData);
operation.setThreadId(getThreadId());
return invokeOperation(keyData, operation);
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapProxySupport method getEntryViewInternal.
protected EntryView getEntryViewInternal(Data key) {
int partitionId = partitionService.getPartitionId(key);
MapOperation operation = operationProvider.createGetEntryViewOperation(name, key);
operation.setThreadId(getThreadId());
operation.setServiceName(SERVICE_NAME);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
return (EntryView) toObject(future.get());
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapProxySupport method getAsyncInternal.
protected InternalCompletableFuture<Data> getAsyncInternal(Object key) {
Data keyData = toDataWithStrategy(key);
int partitionId = partitionService.getPartitionId(keyData);
MapOperation operation = operationProvider.createGetOperation(name, keyData);
try {
long startTimeNanos = Timer.nanos();
InvocationFuture<Data> future = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).setAsync().invoke();
if (statisticsEnabled) {
future.whenCompleteAsync(new IncrementStatsExecutionCallback<>(operation, startTimeNanos), CALLER_RUNS);
}
return future;
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapProxySupport method putIfAbsentInternal.
protected Data putIfAbsentInternal(Object key, Data value, long ttl, TimeUnit ttlUnit, long maxIdle, TimeUnit maxIdleUnit) {
Data keyData = toDataWithStrategy(key);
MapOperation operation = newPutIfAbsentOperation(keyData, value, ttl, ttlUnit, maxIdle, maxIdleUnit);
return (Data) invokeOperation(keyData, operation);
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapProxySupport method flush.
@Override
public void flush() {
// TODO: add a feature to Management Center to sync cache to db completely
try {
MapOperation mapFlushOperation = operationProvider.createMapFlushOperation(name);
BinaryOperationFactory operationFactory = new BinaryOperationFactory(mapFlushOperation, getNodeEngine());
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operationFactory);
List<Future> futures = new ArrayList<>();
for (Entry<Integer, Object> entry : results.entrySet()) {
Integer partitionId = entry.getKey();
Long count = ((Long) entry.getValue());
if (count != 0) {
Operation operation = new AwaitMapFlushOperation(name, count);
futures.add(operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId));
}
}
for (Future future : futures) {
future.get();
}
} catch (Throwable t) {
throw rethrow(t);
}
}
Aggregations