use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MapProxySupport method clearInternal.
public void clearInternal() {
try {
Operation clearOperation = operationProvider.createClearOperation(name);
clearOperation.setServiceName(SERVICE_NAME);
BinaryOperationFactory factory = new BinaryOperationFactory(clearOperation, getNodeEngine());
Map<Integer, Object> resultMap = operationService.invokeOnAllPartitions(SERVICE_NAME, factory);
int clearedCount = 0;
for (Object object : resultMap.values()) {
clearedCount += (Integer) object;
}
if (clearedCount > 0) {
publishMapEvent(clearedCount, CLEAR_ALL);
}
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MapProxySupport method waitUntilLoaded.
public void waitUntilLoaded() {
try {
int mapNamePartition = partitionService.getPartitionId(name);
// first we have to check if key-load finished - otherwise the loading on other partitions might not have started.
// In this case we can't invoke IsPartitionLoadedOperation -> they will return "true", but it won't be correct.
int sleepDurationMillis = INITIAL_WAIT_LOAD_SLEEP_MILLIS;
while (true) {
Operation op = new IsKeyLoadFinishedOperation(name);
Future<Boolean> loadingFuture = operationService.invokeOnPartition(SERVICE_NAME, op, mapNamePartition);
if (loadingFuture.get()) {
break;
}
// sleep with some back-off
TimeUnit.MILLISECONDS.sleep(sleepDurationMillis);
sleepDurationMillis = (sleepDurationMillis * 2 < MAXIMAL_WAIT_LOAD_SLEEP_MILLIS) ? sleepDurationMillis * 2 : MAXIMAL_WAIT_LOAD_SLEEP_MILLIS;
}
OperationFactory opFactory = new IsPartitionLoadedOperationFactory(name);
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, opFactory);
// wait for all the data to be loaded on all partitions - wait forever
waitAllTrue(results, opFactory);
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class NodeInvokerWrapper method invokeOnTarget.
@Override
public Future invokeOnTarget(Object operation, Address address) {
checkNotNull(operation, "operation cannot be null");
checkNotNull(address, "address cannot be null");
Operation op = (Operation) operation;
return operationService.invokeOnTarget(MapService.SERVICE_NAME, op, address);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class QueryDispatcher method dispatchFullQueryOnLocalMemberOnQueryThread.
private List<Future<Result>> dispatchFullQueryOnLocalMemberOnQueryThread(Query query) {
Operation operation = new QueryOperation(query);
Future<Result> result = operationService.invokeOnTarget(MapService.SERVICE_NAME, operation, nodeEngine.getThisAddress());
return singletonList(result);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class QueryDispatcher method dispatchFullQueryOnAllMembersOnQueryThread.
private List<Future<Result>> dispatchFullQueryOnAllMembersOnQueryThread(Query query) {
Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
List<Future<Result>> futures = new ArrayList<Future<Result>>(members.size());
for (Member member : members) {
Operation operation = new QueryOperation(query);
Future<Result> future = operationService.invokeOnTarget(MapService.SERVICE_NAME, operation, member.getAddress());
futures.add(future);
}
return futures;
}
Aggregations