use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleGetClusterVersion.
private void handleGetClusterVersion(HttpGetCommand command) {
String res = "{\"status\":\"${STATUS}\",\"version\":\"${VERSION}\"}";
Node node = textCommandService.getNode();
ClusterService clusterService = node.getClusterService();
res = res.replace("${STATUS}", "success");
res = res.replace("${VERSION}", clusterService.getClusterVersion().toString());
command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res));
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleClusterShutdown.
private void handleClusterShutdown(HttpPostCommand command) throws UnsupportedEncodingException {
String res;
try {
Node node = textCommandService.getNode();
ClusterService clusterService = node.getClusterService();
if (!checkCredentials(command)) {
res = response(ResponseType.FORBIDDEN);
} else {
res = response(ResponseType.SUCCESS);
sendResponse(command, res);
clusterService.shutdown();
return;
}
} catch (Throwable throwable) {
logger.warning("Error occurred while shutting down cluster", throwable);
res = exceptionResponse(throwable);
}
sendResponse(command, res);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class KeyValueJob method startSupervisionTask.
private <T> JobCompletableFuture<T> startSupervisionTask(TrackableJobFuture<T> jobFuture, String jobId) {
AbstractJobTracker jobTracker = (AbstractJobTracker) this.jobTracker;
JobTrackerConfig config = jobTracker.getJobTrackerConfig();
boolean communicateStats = config.isCommunicateStats();
if (chunkSize == -1) {
chunkSize = config.getChunkSize();
}
if (topologyChangedStrategy == null) {
topologyChangedStrategy = config.getTopologyChangedStrategy();
}
ClusterService clusterService = nodeEngine.getClusterService();
for (Member member : clusterService.getMembers(KeyValueJobOperation.MEMBER_SELECTOR)) {
Operation operation = new KeyValueJobOperation<KeyIn, ValueIn>(name, jobId, chunkSize, keyValueSource, mapper, combinerFactory, reducerFactory, communicateStats, topologyChangedStrategy);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
// After we prepared all the remote systems we can now start the processing
for (Member member : clusterService.getMembers(DATA_MEMBER_SELECTOR)) {
Operation operation = new StartProcessingJobOperation<KeyIn>(name, jobId, keys, predicate);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
return jobFuture;
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createNodeState.
private void createNodeState(MemberStateImpl memberState) {
Node node = instance.node;
ClusterService cluster = instance.node.clusterService;
NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(), cluster.getClusterVersion(), node.getVersion());
memberState.setNodeState(nodeState);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class MapReduceUtil method executeOperation.
public static <V> V executeOperation(Operation operation, Address address, MapReduceService mapReduceService, NodeEngine nodeEngine) {
ClusterService cs = nodeEngine.getClusterService();
OperationService os = nodeEngine.getOperationService();
boolean returnsResponse = operation.returnsResponse();
try {
if (cs.getThisAddress().equals(address)) {
// Locally we can call the operation directly
operation.setNodeEngine(nodeEngine);
operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
operation.setService(mapReduceService);
operation.run();
if (returnsResponse) {
return (V) operation.getResponse();
}
} else {
if (returnsResponse) {
InvocationBuilder ib = os.createInvocationBuilder(SERVICE_NAME, operation, address);
return (V) ib.invoke().get();
} else {
os.send(operation, address);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
Aggregations