Package healthchecks

Source Code of healthchecks.ElasticSearchHealthCheck

package healthchecks;

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.node.Node;

import com.yammer.metrics.core.HealthCheck;

public class ElasticSearchHealthCheck extends HealthCheck {

    private Node node;

    public ElasticSearchHealthCheck(Node node) {
        super("elasticsearch");
        this.node = node;
    }

    @Override
    protected Result check() throws Exception {
        ClusterHealthResponse clusterHealthResponse = node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
        return Result.healthy("Last status: " + clusterHealthResponse.status().name());
    }

}
TOP

Related Classes of healthchecks.ElasticSearchHealthCheck

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.