use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class WanMapSupportingService method handleAddOrUpdate.
private void handleAddOrUpdate(WanMapAddOrUpdateEvent replicationUpdate) {
SplitBrainMergePolicy mergePolicy = replicationUpdate.getMergePolicy();
String mapName = replicationUpdate.getObjectName();
MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
SerializationService serializationService = nodeEngine.getSerializationService();
MapMergeTypes<Object, Object> mergingEntry = createMergingEntry(serializationService, replicationUpdate.getEntryView());
// noinspection unchecked
MapOperation operation = operationProvider.createMergeOperation(mapName, mergingEntry, (SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object>) mergePolicy, true);
try {
int partitionId = nodeEngine.getPartitionService().getPartitionId(replicationUpdate.getEntryView().getKey());
Future future = nodeEngine.getOperationService().invokeOnPartition(SERVICE_NAME, operation, partitionId);
future.get();
wanEventTypeCounters.incrementUpdate(mapName);
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class MapPartitionIterator method fetch.
protected List fetch() {
String name = mapProxy.getName();
MapOperationProvider operationProvider = mapProxy.getOperationProvider();
MapOperation operation = prefetchValues ? operationProvider.createFetchEntriesOperation(name, pointers, fetchSize) : operationProvider.createFetchKeysOperation(name, pointers, fetchSize);
AbstractCursor cursor = invoke(operation);
setIterationPointers(cursor.getBatch(), cursor.getIterationPointers());
return cursor.getBatch();
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class TransactionalMapProxySupport method replaceInternal.
Data replaceInternal(Data key, Data value, NearCachingHook hook) {
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, UNSET);
tx.add(new MapTransactionLogRecord(name, key, getPartitionId(key), operation, tx.getOwnerUuid(), tx.getTxnId(), hook));
return versionedValue.value;
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class TransactionalMapProxySupport method containsKeyInternal.
boolean containsKeyInternal(Data dataKey, Object objectKey, boolean skipNearCacheLookup) {
if (!skipNearCacheLookup && nearCacheEnabled) {
Object nearCacheKey = serializeKeys ? dataKey : objectKey;
Object cachedValue = getCachedValue(nearCacheKey, false);
if (cachedValue != NOT_CACHED) {
return cachedValue != null;
}
}
MapOperation operation = operationProvider.createContainsKeyOperation(name, dataKey);
operation.setThreadId(ThreadUtil.getThreadId());
int partitionId = partitionService.getPartitionId(dataKey);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
return (Boolean) future.get();
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.map.impl.operation.MapOperation in project hazelcast by hazelcast.
the class TransactionalMapProxySupport method replaceIfSameInternal.
boolean replaceIfSameInternal(Data key, Object oldValue, Data newValue, NearCachingHook hook) {
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, UNSET);
tx.add(new MapTransactionLogRecord(name, key, getPartitionId(key), operation, tx.getOwnerUuid(), tx.getTxnId(), hook));
return true;
}
Aggregations