use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class QueryDispatcher method dispatchPartitionScanQueryOnOwnerMemberOnPartitionThread.
protected Future<Result> dispatchPartitionScanQueryOnOwnerMemberOnPartitionThread(Query query, int partitionId) {
Operation op = new QueryPartitionOperation(query);
op.setPartitionId(partitionId);
try {
return operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.Operation 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.spi.Operation in project hazelcast by hazelcast.
the class NodeQueryCacheEndToEndConstructor method madePublishable.
private void madePublishable(String mapName, String cacheName) throws Exception {
InvokerWrapper invokerWrapper = context.getInvokerWrapper();
Collection<Member> memberList = context.getMemberList();
List<Future> futures = new ArrayList<Future>(memberList.size());
for (Member member : memberList) {
Operation operation = new MadePublishableOperation(mapName, cacheName);
Future future = invokerWrapper.invokeOnTarget(operation, member.getAddress());
futures.add(future);
}
waitWithDeadline(futures, OPERATION_WAIT_TIMEOUT_MINUTES, MINUTES);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MapReduceUtil method executeOperation.
public static <V> List<V> executeOperation(Collection<Member> members, OperationFactory operationFactory, MapReduceService mapReduceService, NodeEngine nodeEngine) {
final OperationService operationService = nodeEngine.getOperationService();
final List<InternalCompletableFuture<V>> futures = new ArrayList<InternalCompletableFuture<V>>();
final List<V> results = new ArrayList<V>();
final List<Exception> exceptions = new ArrayList<Exception>(members.size());
for (Member member : members) {
try {
Operation operation = operationFactory.createOperation();
if (nodeEngine.getThisAddress().equals(member.getAddress())) {
// Locally we can call the operation directly
operation.setNodeEngine(nodeEngine);
operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
operation.setService(mapReduceService);
operation.run();
V response = (V) operation.getResponse();
if (response != null) {
results.add(response);
}
} else {
InvocationBuilder ib = operationService.createInvocationBuilder(SERVICE_NAME, operation, member.getAddress());
final InternalCompletableFuture<V> future = ib.invoke();
futures.add(future);
}
} catch (Exception e) {
exceptions.add(e);
}
}
for (InternalCompletableFuture<V> future : futures) {
try {
V response = future.join();
if (response != null) {
results.add(response);
}
} catch (Exception e) {
exceptions.add(e);
}
}
if (exceptions.size() > 0) {
throw new RemoteMapReduceException("Exception on mapreduce operation", exceptions);
}
return results;
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MultiMapTransactionLogRecord method writeData.
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeUTF(name);
out.writeInt(partitionId);
out.writeInt(opList.size());
for (Operation op : opList) {
out.writeObject(op);
}
out.writeData(key);
out.writeLong(ttl);
out.writeLong(threadId);
}
Aggregations