// Path: elasticservice/src/main/java/elasticsearch/constant/ESConstants.java
// public class ESConstants {
//     public      static  final   String STORE_INDEX = "stores";
//     public      static  final   String PRODUCT_TYPE = "product";
//     public      static  final   String SKU_TYPE = "sku";
//     public      static  final   String PRODUCT_PROPERTY = "productproperty";
//     public      static  final   String CHANNEL_TYPE = "channels";
//     public      static  final   int SNIFFER_INTERVAL = 15000;
//     public      static  final   int RESTCLIENT_TIMEOUT = 20000; // 20s
// 
// 
//     public      static  final   Pattern ROUTINGKEY_PATTERN = Pattern.compile("([\\w\\.]+)\\.(\\w+)\\.(\\d+)");
// 
// }


import com.google.gson.JsonObject;
import elasticsearch.constant.ESConstants;
import org.apache.http.HttpHost;
import org.apache.log4j.Logger;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.sniff.ElasticsearchHostsSniffer;
import org.elasticsearch.client.sniff.HostsSniffer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

package elasticsearch.esapi;



/**
 * Created by I311352 on 11/17/2016.
 */

@Component
public class ClusterService {
    private static final Logger logger = Logger.getLogger(ClusterService.class);
    private final RestClient client;
    private final ElasticsearchHostsSniffer elasticsearchHostsSniffer;
    private static Task task = null;

    @Autowired
    public ClusterService(RestClient client) {
        this.client = client;
        this.elasticsearchHostsSniffer = new ElasticsearchHostsSniffer(client);
    }

    public List<HttpHost> getNodesInfo() {
        try {
            return elasticsearchHostsSniffer.sniffHosts();
        } catch (IOException e) {
            logger.error("Cannot get elastic search nodes.." + e);
        }
        return null;
    }

    public JsonObject getNodesJvmInfo() {
        return null;
    }

    public void startSniffer() {

// Path: elasticservice/src/main/java/elasticsearch/constant/ESConstants.java
// public class ESConstants {
//     public      static  final   String STORE_INDEX = "stores";
//     public      static  final   String PRODUCT_TYPE = "product";
//     public      static  final   String SKU_TYPE = "sku";
//     public      static  final   String PRODUCT_PROPERTY = "productproperty";
//     public      static  final   String CHANNEL_TYPE = "channels";
//     public      static  final   int SNIFFER_INTERVAL = 15000;
//     public      static  final   int RESTCLIENT_TIMEOUT = 20000; // 20s
// 
// 
//     public      static  final   Pattern ROUTINGKEY_PATTERN = Pattern.compile("([\\w\\.]+)\\.(\\w+)\\.(\\d+)");
// 
// }


// Path: elasticservice/src/main/java/elasticsearch/esapi/ClusterService.java
import com.google.gson.JsonObject;
import elasticsearch.constant.ESConstants;
import org.apache.http.HttpHost;
import org.apache.log4j.Logger;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.sniff.ElasticsearchHostsSniffer;
import org.elasticsearch.client.sniff.HostsSniffer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

package elasticsearch.esapi;



/**
 * Created by I311352 on 11/17/2016.
 */

@Component
public class ClusterService {
    private static final Logger logger = Logger.getLogger(ClusterService.class);
    private final RestClient client;
    private final ElasticsearchHostsSniffer elasticsearchHostsSniffer;
    private static Task task = null;

    @Autowired
    public ClusterService(RestClient client) {
        this.client = client;
        this.elasticsearchHostsSniffer = new ElasticsearchHostsSniffer(client);
    }

    public List<HttpHost> getNodesInfo() {
        try {
            return elasticsearchHostsSniffer.sniffHosts();
        } catch (IOException e) {
            logger.error("Cannot get elastic search nodes.." + e);
        }
        return null;
    }

    public JsonObject getNodesJvmInfo() {
        return null;
    }

    public void startSniffer() {

        this.task = new Task(elasticsearchHostsSniffer, client, ESConstants.SNIFFER_INTERVAL);
