use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class CacheCreateConfigOperation method run.
@Override
public void run() throws Exception {
ICacheService service = getService();
if (!ignoreLocal) {
response = service.putCacheConfigIfAbsent(config);
}
if (createAlsoOnOthers) {
NodeEngine nodeEngine = getNodeEngine();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
int remoteNodeCount = members.size() - 1;
if (remoteNodeCount > 0) {
postponeReturnResponse();
ExecutionCallback<Object> callback = new CacheConfigCreateCallback(this, remoteNodeCount);
OperationService operationService = nodeEngine.getOperationService();
for (Member member : members) {
if (!member.localMember()) {
CacheCreateConfigOperation op = new CacheCreateConfigOperation(config, false);
operationService.createInvocationBuilder(ICacheService.SERVICE_NAME, op, member.getAddress()).setExecutionCallback(callback).invoke();
}
}
}
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class CacheDestroyOperation method destroyCacheOnAllMembers.
private void destroyCacheOnAllMembers(String name, String callerUuid) {
NodeEngine nodeEngine = getNodeEngine();
OperationService operationService = nodeEngine.getOperationService();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
for (Member member : members) {
if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
CacheDestroyOperation op = new CacheDestroyOperation(name, true);
operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
}
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class CollectionService method rollbackTransaction.
@Override
public void rollbackTransaction(String transactionId) {
final Set<String> collectionNames = getContainerMap().keySet();
IPartitionService partitionService = nodeEngine.getPartitionService();
OperationService operationService = nodeEngine.getOperationService();
for (String name : collectionNames) {
int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
Operation operation = new CollectionTransactionRollbackOperation(name, transactionId).setPartitionId(partitionId).setService(this).setNodeEngine(nodeEngine);
operationService.execute(operation);
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class DurableExecutorServiceProxy method shutdown.
@Override
public void shutdown() {
NodeEngine nodeEngine = getNodeEngine();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
OperationService operationService = nodeEngine.getOperationService();
Collection<Future> calls = new LinkedList<Future>();
for (Member member : members) {
if (member.localMember()) {
getService().shutdownExecutor(name);
} else {
ShutdownOperation op = new ShutdownOperation(name);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
calls.add(f);
}
}
waitWithDeadline(calls, 1, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class AbstractTransactionalCollectionProxy method remove.
public boolean remove(E e) {
checkTransactionActive();
checkObjectNotNull(e);
final NodeEngine nodeEngine = getNodeEngine();
final Data value = nodeEngine.toData(e);
final Iterator<CollectionItem> iterator = getCollection().iterator();
long reservedItemId = -1;
while (iterator.hasNext()) {
final CollectionItem item = iterator.next();
if (value.equals(item.getValue())) {
reservedItemId = item.getItemId();
break;
}
}
final CollectionReserveRemoveOperation operation = new CollectionReserveRemoveOperation(name, reservedItemId, value, tx.getTxnId());
try {
final OperationService operationService = nodeEngine.getOperationService();
Future<CollectionItem> f = operationService.invokeOnPartition(getServiceName(), operation, partitionId);
CollectionItem item = f.get();
if (item != null) {
if (reservedItemId == item.getItemId()) {
iterator.remove();
removeFromRecord(reservedItemId);
itemIdSet.remove(reservedItemId);
return true;
}
if (!itemIdSet.add(item.getItemId())) {
throw new TransactionException("Duplicate itemId: " + item.getItemId());
}
CollectionTxnRemoveOperation op = new CollectionTxnRemoveOperation(name, item.getItemId());
putToRecord(op);
return true;
}
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
return false;
}
Aggregations