Explorar el Código

使用消息中的cron字段来判断是否为采集任务。

Airhead hace 8 años
padre
commit
f274f37b75

+ 0 - 10
hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/ServiceFlow.java

@ -15,16 +15,6 @@ public class ServiceFlow {
    private String className;
    private String path;
    private Date updateTime;
    private String flowType;
    public String getFlowType() {
        return flowType;
    }
    public void setFlowType(String flowType) {
        this.flowType = flowType;
    }
    private String cron;
    public String getCron() {

+ 12 - 1
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ServiceFlowService.java

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