use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class MasterConfirmationOperation method run.
@Override
public void run() {
final Address endpoint = getCallerAddress();
if (endpoint == null) {
return;
}
final ClusterServiceImpl clusterService = getService();
final ILogger logger = getLogger();
final MemberImpl member = clusterService.getMember(endpoint);
if (member == null) {
logger.warning("MasterConfirmation has been received from " + endpoint + ", but it is not a member of this cluster!");
OperationService operationService = getNodeEngine().getOperationService();
operationService.send(new MemberRemoveOperation(clusterService.getThisAddress()), endpoint);
} else {
if (clusterService.isMaster()) {
clusterService.getClusterHeartbeatManager().acceptMasterConfirmation(member, timestamp);
} else {
logger.warning(endpoint + " has sent MasterConfirmation, but this node is not master!");
}
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class ReplicaSyncRequest method sendRetryResponse.
/** Send a response to the replica to retry the replica sync */
private void sendRetryResponse() {
NodeEngine nodeEngine = getNodeEngine();
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
ReplicaSyncRetryResponse response = new ReplicaSyncRetryResponse();
response.setPartitionId(partitionId).setReplicaIndex(replicaIndex);
Address target = getCallerAddress();
OperationService operationService = nodeEngine.getOperationService();
operationService.send(response, target);
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class MapNearCacheManager method createRepairingInvalidationTask.
private RepairingTask createRepairingInvalidationTask() {
ExecutionService executionService = nodeEngine.getExecutionService();
ClusterService clusterService = nodeEngine.getClusterService();
OperationService operationService = nodeEngine.getOperationService();
HazelcastProperties properties = nodeEngine.getProperties();
ILogger logger = nodeEngine.getLogger(RepairingTask.class);
MetaDataFetcher metaDataFetcher = new MemberMapMetaDataFetcher(clusterService, operationService, logger);
String localUuid = nodeEngine.getLocalMember().getUuid();
return new RepairingTask(metaDataFetcher, executionService.getGlobalTaskScheduler(), partitionService, properties, localUuid, logger);
}
use of com.hazelcast.spi.OperationService 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.OperationService in project hazelcast by hazelcast.
the class TransactionalMultiMapProxySupport method nextId.
private long nextId(Data key) {
final NodeEngine nodeEngine = getNodeEngine();
TxnGenerateRecordIdOperation operation = new TxnGenerateRecordIdOperation(name, key);
try {
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
final OperationService operationService = nodeEngine.getOperationService();
Future<Long> f = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
return f.get();
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
}
Aggregations