Search in sources :

Example 26 with ClusterService

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));
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Node(com.hazelcast.instance.Node)

Example 27 with ClusterService

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);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Node(com.hazelcast.instance.Node) StringUtil.bytesToString(com.hazelcast.util.StringUtil.bytesToString)

Example 28 with ClusterService

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;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) JobTrackerConfig(com.hazelcast.config.JobTrackerConfig) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) Operation(com.hazelcast.spi.Operation) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) MapReduceUtil.executeOperation(com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) Member(com.hazelcast.core.Member)

Example 29 with ClusterService

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);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) NodeStateImpl(com.hazelcast.monitor.impl.NodeStateImpl) Node(com.hazelcast.instance.Node)

Example 30 with ClusterService

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;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) OperationService(com.hazelcast.spi.OperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) RemoteMapReduceException(com.hazelcast.mapreduce.RemoteMapReduceException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ClusterService (com.hazelcast.internal.cluster.ClusterService)32 Member (com.hazelcast.core.Member)8 ArrayList (java.util.ArrayList)8 Node (com.hazelcast.instance.Node)7 Address (com.hazelcast.nio.Address)7 OperationService (com.hazelcast.spi.OperationService)6 MemberImpl (com.hazelcast.instance.MemberImpl)5 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)5 Future (java.util.concurrent.Future)5 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)4 NodeEngine (com.hazelcast.spi.NodeEngine)4 ILogger (com.hazelcast.logging.ILogger)3 Operation (com.hazelcast.spi.Operation)3 GroupConfig (com.hazelcast.config.GroupConfig)2 JobTrackerConfig (com.hazelcast.config.JobTrackerConfig)2 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)2 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)2 MapReduceUtil.executeOperation (com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation)2 KeyValueJobOperation (com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation)2 StartProcessingJobOperation (com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation)2