|
@ -3,6 +3,7 @@ package com.yihu.hos.arbiter.services;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yihu.hos.arbiter.models.BrokerServer;
|
|
import com.yihu.hos.arbiter.models.BrokerServer;
|
|
import com.yihu.hos.arbiter.models.ServiceFlow;
|
|
import com.yihu.hos.arbiter.models.ServiceFlow;
|
|
|
|
import com.yihu.hos.core.datatype.StringUtil;
|
|
import org.apache.http.Consts;
|
|
import org.apache.http.Consts;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
@ -45,6 +46,16 @@ public class ServiceFlowService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Broker原则上具有等同性,这样Arbiter无论选择了哪个Broker能提供的服务都是一样的。
|
|
|
|
* 但是因为Broker上还是会运行一些定时的采集任务,这些采集任务如果是多台Broker运行的话,可能引起数据问题。
|
|
|
|
* 所以在事件触发时需要做一些策略的调整:
|
|
|
|
* 1.实时任务,通知所有的Broker进行更新路由
|
|
|
|
* 2.采集任务,只通知其中的一台进行更新路由
|
|
|
|
* TODO:遗留BUG多Broker启动时,采集任务会在多个Broker中被启动。
|
|
|
|
*
|
|
|
|
* @param msg 数据流
|
|
|
|
*/
|
|
public void trigger(String msg) {
|
|
public void trigger(String msg) {
|
|
System.out.println(msg);
|
|
System.out.println(msg);
|
|
|
|
|
|
@ -58,7 +69,7 @@ public class ServiceFlowService {
|
|
nameValuePairList.add(new BasicNameValuePair("path", serviceFlow.getPath()));
|
|
nameValuePairList.add(new BasicNameValuePair("path", serviceFlow.getPath()));
|
|
nameValuePairList.add(new BasicNameValuePair("cron", serviceFlow.getCron()));
|
|
nameValuePairList.add(new BasicNameValuePair("cron", serviceFlow.getCron()));
|
|
|
|
|
|
boolean one = serviceFlow.getFlowType().equals(""); //TODO:need to implement;
|
|
|
|
|
|
boolean one = !StringUtil.isEmpty(serviceFlow.getCron()); //有cron表达式,就是采集任务。
|
|
List<BrokerServer> brokerServerList = brokerServerService.get(one);
|
|
List<BrokerServer> brokerServerList = brokerServerService.get(one);
|
|
for (BrokerServer brokerServer : brokerServerList) {
|
|
for (BrokerServer brokerServer : brokerServerList) {
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|