// Path: elasticservice/src/main/java/elasticsearch/ElasticRestClient.java
// @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)
//                 .build();
// 
// //        this.sniffer = Sniffer.builder(this.restClient)
// //                                 .setSniffIntervalMillis(60000).build();
// 
//         return this.restClient;
//     }
// 
//     @Override
//     protected void destroyInstance(RestClient instance) throws Exception {
//         try {
//             logger.info("Closing sniffer");
//             instance.close();
//             this.sniffer.close();
//         } catch (IOException e) {
//             logger.warn("Error during close sniffer", e);
//         }
//     }
// 
//     public void setHosts(List<String> hosts) {
//         this.hosts = hosts;
//     }
// }


import elasticsearch.ElasticRestClient;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.rest.RestResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;

package elasticsearch.searchservice;


/**
 * Created by i311352 on 5/2/2017.
 */
@Service
public class ESService {
    private static final Logger logger = LoggerFactory.getLogger(ESService.class);

    private static String baseURL;
    private static String searchProductURL;
    private static String countProductURL;

    @Autowired

// Path: elasticservice/src/main/java/elasticsearch/ElasticRestClient.java
// @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)
//                 .build();
// 
// //        this.sniffer = Sniffer.builder(this.restClient)
// //                                 .setSniffIntervalMillis(60000).build();
// 
//         return this.restClient;
//     }
// 
//     @Override
//     protected void destroyInstance(RestClient instance) throws Exception {
//         try {
//             logger.info("Closing sniffer");
//             instance.close();
//             this.sniffer.close();
//         } catch (IOException e) {
//             logger.warn("Error during close sniffer", e);
//         }
//     }
// 
//     public void setHosts(List<String> hosts) {
//         this.hosts = hosts;
//     }
// }


// Path: elasticservice/src/main/java/elasticsearch/searchservice/ESService.java
import elasticsearch.ElasticRestClient;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.rest.RestResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;

package elasticsearch.searchservice;


/**
 * Created by i311352 on 5/2/2017.
 */
@Service
public class ESService {
    private static final Logger logger = LoggerFactory.getLogger(ESService.class);

    private static String baseURL;
    private static String searchProductURL;
    private static String countProductURL;

    @Autowired

    ElasticRestClient client;
