use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class RequestMapDataOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getLogger();
Address callerAddress = getCallerAddress();
int partitionId = getPartitionId();
NodeEngine nodeEngine = getNodeEngine();
if (logger.isFineEnabled()) {
logger.fine("Caller " + callerAddress + " requested copy of replicated map '" + name + "' (partitionId " + partitionId + ") from " + nodeEngine.getThisAddress());
}
ReplicatedMapService service = getService();
PartitionContainer container = service.getPartitionContainer(partitionId);
ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
store.setLoaded(true);
if (nodeEngine.getThisAddress().equals(callerAddress)) {
return;
}
long version = store.getVersion();
Set<RecordMigrationInfo> recordSet = getRecordSet(store);
Operation op = new SyncReplicatedMapDataOperation(name, recordSet, version).setPartitionId(partitionId).setValidateTarget(false);
OperationService operationService = nodeEngine.getOperationService();
operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class ClearOperation method replicateClearOperation.
private void replicateClearOperation(long version) {
OperationService operationService = getNodeEngine().getOperationService();
Collection<Address> members = getMemberAddresses();
for (Address address : members) {
Operation op = new ClearOperation(mapName, false, version).setPartitionId(getPartitionId()).setValidateTarget(false);
operationService.createInvocationBuilder(getServiceName(), op, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class XAResourceImpl method finalizeTransactionRemotely.
private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException {
NodeEngine nodeEngine = getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
OperationService operationService = nodeEngine.getOperationService();
SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
Data xidData = nodeEngine.toData(serializableXID);
int partitionId = partitionService.getPartitionId(xidData);
FinalizeRemoteTransactionOperation operation = new FinalizeRemoteTransactionOperation(xidData, isCommit);
InternalCompletableFuture<Integer> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
Integer errorCode;
try {
errorCode = future.get();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
if (errorCode != null) {
throw new XAException(errorCode);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CacheProxy method getAll.
@Override
public Map<K, V> getAll(Set<? extends K> keys, ExpiryPolicy expiryPolicy) {
ensureOpen();
validateNotNull(keys);
if (keys.isEmpty()) {
return emptyMap();
}
final int keyCount = keys.size();
final Set<Data> ks = createHashSet(keyCount);
for (K key : keys) {
validateNotNull(key);
Data dataKey = serializationService.toData(key);
ks.add(dataKey);
}
Map<K, V> result = createHashMap(keyCount);
PartitionIdSet partitions = getPartitionsForKeys(ks);
try {
OperationFactory factory = operationProvider.createGetAllOperationFactory(ks, expiryPolicy);
OperationService operationService = getNodeEngine().getOperationService();
Map<Integer, Object> responses = operationService.invokeOnPartitions(getServiceName(), factory, partitions);
for (Object response : responses.values()) {
MapEntries mapEntries = serializationService.toObject(response);
mapEntries.putAllToMap(serializationService, result);
}
} catch (Throwable e) {
throw rethrowAllowedTypeFirst(e, CacheException.class);
}
return result;
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CacheProxySupport method removeAllInternal.
protected void removeAllInternal(Set<? extends K> keys) {
Set<Data> keysData = null;
if (keys != null) {
keysData = createHashSet(keys.size());
for (K key : keys) {
validateNotNull(key);
keysData.add(serializationService.toData(key));
}
}
int partitionCount = getNodeEngine().getPartitionService().getPartitionCount();
Integer completionId = listenerCompleter.registerCompletionLatch(partitionCount);
OperationService operationService = getNodeEngine().getOperationService();
OperationFactory operationFactory = operationProvider.createRemoveAllOperationFactory(keysData, completionId);
try {
Map<Integer, Object> results = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
int completionCount = 0;
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Boolean) {
completionCount++;
}
if (response instanceof Throwable) {
throw (Throwable) response;
}
}
}
listenerCompleter.waitCompletionLatch(completionId, partitionCount - completionCount);
} catch (Throwable t) {
listenerCompleter.deregisterCompletionLatch(completionId);
throw rethrowAllowedTypeFirst(t, CacheException.class);
}
}
Aggregations