package org.elasticsearch.plugin.nlpcn.preAnalyzer;


import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;

/**
 * Created by fangbb on 2016-11-25.
 */
public class AnsjElasticConfigurator {
    public static ESLogger logger = Loggers.getLogger("sql-init");
    public static Environment environment;
    public static String ES_IP = "";
    public static String ES_PORT = "";

    public static void init(Settings settings) {
        try {
            ES_IP = settings.get("network.host");
            ES_PORT = settings.get("http.port");
            logger.info("es 本地IP：" + ES_IP);
            logger.info("es 端口："+ ES_PORT);
            if (ES_IP==null || ES_IP.equals("")){
                logger.error("本地IP获取失败");
            }
            if (ES_PORT==null || ES_PORT.equals("")){
                logger.error("ES服务获取失败");
            }
        } catch (Exception e) {
            logger.error("本地IP和ES端口获取失败");
        }
    }
}

@@ -611,15 +611,12 @@
 et(%22
-network
+ansj
 .hos
@@ -685,174 +685,165 @@
     
-logger.info(%22es %E6%9C%AC%E5%9C%B0IP%EF%BC%9A%22 + ES_IP);%0A            logger.info(%22es %E7%AB%AF%E5%8F%A3%EF%BC%9A%22+ ES_PORT);%0A            if (ES_IP==null %7C%7C ES_IP.equals(%22%22))%7B%0A                logger.error(%22%E6%9C%AC%E5%9C%B0IP%E8%8E%B7%E5%8F%96%E5%A4%B1%E8%B4%A5%22
+if (ES_IP == null %7C%7C ES_IP.equals(%22%22)) %7B%0A                logger.error(%22ansj.host%E8%8E%B7%E5%8F%96%E5%A4%B1%E8%B4%A5%22);%0A            %7D else %7B%0A                logger.info(%22ansj.host%EF%BC%9A%22 + ES_IP
 );%0A 
@@ -878,18 +878,20 @@
 (ES_PORT
+ 
 ==
+ 
 null %7C%7C 
@@ -909,16 +909,17 @@
 als(%22%22))
+ 
 %7B%0A      
@@ -932,31 +932,150 @@
     
-logger.error(%22ES%E6%9C%8D%E5%8A%A1%E8%8E%B7%E5%8F%96%E5%A4%B1%E8%B4%A5%22
+ES_PORT = %229200%22;%0A                logger.error(%22ES%E6%9C%8D%E5%8A%A1%E8%8E%B7%E5%8F%96%E5%A4%B1%E8%B4%A5,%E4%BD%BF%E7%94%A8%E9%BB%98%E8%AE%A4%E7%AB%AF%E5%8F%A3:9200%22);%0A            %7D else %7B%0A                logger.info(%22http.port%EF%BC%9A%22+ ES_PORT
 );%0A 
@@ -1148,23 +1148,22 @@
 ror(
-%22%E6%9C%AC%E5%9C%B0IP%E5%92%8CES%E7%AB%AF%E5%8F%A3%E8%8E%B7%E5%8F%96%E5%A4%B1%E8%B4%A5%22
+e.getMessage()
 );%0A 

modify es-sql init config