// 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 elasticsearch.constant.ESConstants;
import org.apache.http.HttpHost;
import org.apache.log4j.Logger;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.sniff.Sniffer;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

package elasticsearch;



/**
 * Created by I311352 on 9/30/2016.
 */

@Component
public class ElasticRestClient extends AbstractFactoryBean<RestClient> {
    private static Logger logger = Logger.getLogger(ElasticRestClient.class);
    private ClusterFailureListener clusterFailureListener;
    private volatile RestClient restClient;
    private static List<String> hosts = new ArrayList<>();
    private Sniffer sniffer;

    static {
        hosts.add("10.128.161.107:9200");
    }

    @Override
    public Class<?> getObjectType() {
        return RestClient.class;
    }


    @Override
    public RestClient createInstance() throws Exception {
        if (this.restClient != null) {
            return this.restClient;
        }

        HttpHost[] addresses = new HttpHost[hosts.size()];
        for (int i = 0; i < hosts.size(); i++) {
            addresses[i] = HttpHost.create(hosts.get(i));
        }

        this.restClient = RestClient
                .builder(addresses)

// 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/ElasticRestClient.java
import elasticsearch.constant.ESConstants;
import org.apache.http.HttpHost;
import org.apache.log4j.Logger;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.sniff.Sniffer;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

package elasticsearch;



/**
 * Created by I311352 on 9/30/2016.
 */

@Component
public class ElasticRestClient extends AbstractFactoryBean<RestClient> {
    private static Logger logger = Logger.getLogger(ElasticRestClient.class);
    private ClusterFailureListener clusterFailureListener;
    private volatile RestClient restClient;
    private static List<String> hosts = new ArrayList<>();
    private Sniffer sniffer;

    static {
        hosts.add("10.128.161.107:9200");
    }

    @Override
    public Class<?> getObjectType() {
        return RestClient.class;
    }


    @Override
    public RestClient createInstance() throws Exception {
        if (this.restClient != null) {
            return this.restClient;
        }

        HttpHost[] addresses = new HttpHost[hosts.size()];
        for (int i = 0; i < hosts.size(); i++) {
            addresses[i] = HttpHost.create(hosts.get(i));
        }

        this.restClient = RestClient
                .builder(addresses)

                .setMaxRetryTimeoutMillis(ESConstants.RESTCLIENT_TIMEOUT)
