chenweida 7 лет назад
Родитель
Сommit
41d9e52b58
18 измененных файлов с 136 добавлено и 110 удалено
  1. 31 15
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/save/es/ElasticFactory.java
  2. 2 3
      patient-co/patient-co-statistics-es/src/main/resources/application-dev.yml
  3. 2 3
      patient-co/patient-co-statistics-es/src/main/resources/application-devtest.yml
  4. 2 3
      patient-co/patient-co-statistics-es/src/main/resources/application-prod.yml
  5. 2 3
      patient-co/patient-co-statistics-es/src/main/resources/application-test.yml
  6. 2 2
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java
  7. 41 29
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java
  8. 2 3
      patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml
  9. 2 3
      patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml
  10. 2 3
      patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml
  11. 2 3
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  12. 34 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java
  13. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  14. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  15. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  16. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  17. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  18. 2 3
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 31 - 15
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/save/es/ElasticFactory.java

@ -13,6 +13,9 @@ import org.springframework.util.StringUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
/**
@ -23,11 +26,9 @@ public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;
    @Value("${es.port}")
    private String port;
    @Value("${es.tPort}")
    private String tPort;
    private String esHost;//http://59.61.92.90:9065,http://59.61.92.90:9067
    @Value("${es.tHost}")
    private String tHost;// 59.61.92.90:9066,59.61.92.90:9068
    @Value("${es.clusterName}")
    private String clusterName;
//-----------------------------------jestClient----------------------------------------
@ -46,23 +47,28 @@ public class ElasticFactory {
    /**
     * 初始化链接
     * 9200
     */
    public synchronized void init() {
        String[] hostArray = esHost.split(",");
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://" + esHost + ":" + port)
        HttpClientConfig httpClientConfig = new HttpClientConfig
                .Builder(Arrays.asList(hostArray))
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
                .connTimeout(60*1000)
               // .discoveryEnabled(true)
                .readTimeout(60*1000)//60秒
                .build());//得到链接
                .connTimeout(60 * 1000)
                // .discoveryEnabled(true)
                .readTimeout(60 * 1000)//60秒
                .build();
        factory.setHttpClientConfig(httpClientConfig);//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private Client transportClient;
    private TransportClient transportClient;
    public Client getTransportClient() {
        try {
@ -74,15 +80,25 @@ public class ElasticFactory {
        return null;
    }
    /**
     * 9300
     *
     * @throws UnknownHostException
     */
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            String[] hosts = tHost.split(",");
            Settings settings = Settings.settingsBuilder()
                   // .put("client.transport.sniff", true)//开启嗅探功能
                    // .put("client.transport.sniff", true)//开启嗅探功能
                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                    .build();
            transportClient = TransportClient.builder().settings(settings).build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
            transportClient = TransportClient.builder().settings(settings).build();
            for (String oneHost : hosts) {
                String[] hostAndport = oneHost.split(":");
                transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostAndport[0]), Integer.valueOf(hostAndport[1])));
            }
        }
    }
}

+ 2 - 3
patient-co/patient-co-statistics-es/src/main/resources/application-dev.yml

@ -43,9 +43,8 @@ systemConfig:
es:
  index: wlyy_quota_dev
  type: wlyy_quota_dev
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-statistics-es/src/main/resources/application-devtest.yml

@ -48,9 +48,8 @@ systemConfig:
es:
  index: wlyy_quota_test
  type: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
wlyy:

+ 2 - 3
patient-co/patient-co-statistics-es/src/main/resources/application-prod.yml

@ -30,9 +30,8 @@ systemConfig:
es:
  index: wlyy_quota_prod
  type: wlyy_quota_prod
  host:  59.61.92.90
  port: 9067
  tPort: 9068
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
wlyy:

+ 2 - 3
patient-co/patient-co-statistics-es/src/main/resources/application-test.yml

@ -48,9 +48,8 @@ systemConfig:
es:
  index: wlyy_quota_test
  type: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
wlyy:

+ 2 - 2
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java

@ -75,13 +75,13 @@ public class QuartzJobLog implements java.io.Serializable {
		this.jobId = jobId;
	}
	@Column(name = "job_content", length = 1000)
	@Column(name = "job_content")
	public String getJobContent() {
		return this.jobContent;
	}
	public void setJobContent(String jobContent) {
		this.jobContent = "";
		this.jobContent = jobContent;
	}
	@Column(name = "job_type", length = 1)

+ 41 - 29
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java

@ -14,61 +14,62 @@ import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
	private static JestClientFactory factory = null;
	
	@Value("${es.host}")
	private String esHost;
	@Value("${es.port}")
	private String port;
	@Value("${es.tPort}")
	private String tPort;
	private String esHost;//http://59.61.92.90:9065,http://59.61.92.90:9067
	@Value("${es.tHost}")
	private String tHost;// 59.61.92.90:9066,59.61.92.90:9068
	@Value("${es.clusterName}")
	private String clusterName;
//-----------------------------------jestClient----------------------------------------
	
	/**
	 * @param "http://localhost:9200"
	 * @return
	 */
	//@PostConstruct
	public JestClient getJestClient() {
		synchronized (ElasticFactory.class) {
			if (factory == null) {
				//初始化链接
				init();
			}
		if (factory == null) {
			//初始化链接
			init();
		}
		return factory.getObject();
	}
	
	/**
	 * 初始化链接
	 * 9200
	 */
	public synchronized void init() {
		
		String[] hostArray = esHost.split(",");
		// Construct a new Jest client according to configuration via factory
		factory = new JestClientFactory();
		factory.setHttpClientConfig(new HttpClientConfig
				.Builder("http://" + esHost + ":" + port)
		HttpClientConfig httpClientConfig = new HttpClientConfig
				.Builder(Arrays.asList(hostArray))
				.multiThreaded(true)
				.maxTotalConnection(50)// 最大链接
				.maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
				.connTimeout(30000)
				.discoveryEnabled(true)
				.readTimeout(30000)//30秒
				.build());//得到链接
				.connTimeout(60 * 1000)
				// .discoveryEnabled(true)
				.readTimeout(60 * 1000)//60秒
				.build();
		factory.setHttpClientConfig(httpClientConfig);//得到链接
	}
	
	//-----------------------------------TransportClient----------------------------------------
	private Client transportClient;
	
	private TransportClient transportClient;
	public Client getTransportClient() {
		try {
			initTranClient();
@ -78,16 +79,27 @@ public class ElasticFactory {
		}
		return null;
	}
	
	/**
	 * 9300
	 *
	 * @throws UnknownHostException
	 */
	private synchronized void initTranClient() throws UnknownHostException {
		if (transportClient == null) {
			String[] hosts = tHost.split(",");
			Settings settings = Settings.settingsBuilder()
					.put("client.transport.sniff", true)//开启嗅探功能
					// .put("client.transport.sniff", true)//开启嗅探功能
					.put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
					.build();
			
			transportClient = TransportClient.builder().settings(settings).build()
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
			transportClient = TransportClient.builder().settings(settings).build();
			for (String oneHost : hosts) {
				String[] hostAndport = oneHost.split(":");
				transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostAndport[0]), Integer.valueOf(hostAndport[1])));
			}
		}
	}
}

+ 2 - 3
patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml

@ -123,7 +123,6 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_dev
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml

@ -115,7 +115,6 @@ es:
    HealthEduArticlePatient: wlyy_quota_test
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml

@ -123,7 +123,6 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_prod
    Statistics: wlyy_quota_prod
    FollowUpContent: wlyy_followup_content
  host: 59.61.92.90
  port: 9065
  tPort: 9066
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml

@ -120,7 +120,6 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 34 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java

@ -14,21 +14,21 @@ import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;
    @Value("${es.port}")
    private String port;
    @Value("${es.tPort}")
    private String tPort;
    private String esHost;//http://59.61.92.90:9065,http://59.61.92.90:9067
    @Value("${es.tHost}")
    private String tHost;// 59.61.92.90:9066,59.61.92.90:9068
    @Value("${es.clusterName}")
    private String clusterName;
//-----------------------------------jestClient----------------------------------------
@ -37,37 +37,38 @@ public class ElasticFactory {
     * @param "http://localhost:9200"
     * @return
     */
    //@PostConstruct
    public JestClient getJestClient() {
        synchronized (ElasticFactory.class) {
            if (factory == null) {
                //初始化链接
                init();
            }
        if (factory == null) {
            //初始化链接
            init();
        }
        return factory.getObject();
    }
    /**
     * 初始化链接
     * 9200
     */
    public synchronized void init() {
        String[] hostArray = esHost.split(",");
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://" + esHost + ":" + port)
        HttpClientConfig httpClientConfig = new HttpClientConfig
                .Builder(Arrays.asList(hostArray))
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
                .connTimeout(30000)
                .discoveryEnabled(true)
                .readTimeout(30000)//30秒
                .build());//得到链接
                .connTimeout(60 * 1000)
                // .discoveryEnabled(true)
                .readTimeout(60 * 1000)//60秒
                .build();
        factory.setHttpClientConfig(httpClientConfig);//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private Client transportClient;
    private TransportClient transportClient;
    public Client getTransportClient() {
        try {
@ -79,15 +80,26 @@ public class ElasticFactory {
        return null;
    }
    /**
     * 9300
     *
     * @throws UnknownHostException
     */
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            String[] hosts = tHost.split(",");
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.sniff", true)//开启嗅探功能
                    // .put("client.transport.sniff", true)//开启嗅探功能
                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                    .build();
            transportClient = TransportClient.builder().settings(settings).build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
            transportClient = TransportClient.builder().settings(settings).build();
            for (String oneHost : hosts) {
                String[] hostAndport = oneHost.split(":");
                transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostAndport[0]), Integer.valueOf(hostAndport[1])));
            }
        }
    }
}

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -106,9 +106,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_dev
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#消息队列
activemq:

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -104,9 +104,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -102,9 +102,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
#消息队列

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -103,9 +103,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    Statistics: wlyy_quota_test
    FollowUpContent: wlyy_followup_content
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -104,9 +104,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_prod
    Statistics: wlyy_quota_prod
    FollowUpContent: wlyy_followup_content
  host: 59.61.92.90
  port: 9065
  tPort: 9066
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
#消息队列

+ 2 - 3
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -101,9 +101,8 @@ es:
    HealthEduArticlePatient: health_edu_article_patient_test
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#消息队列