Browse Source

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

Airhead 8 years ago
parent
commit
bf6fefbbd2
53 changed files with 2184 additions and 418 deletions
  1. 0 1
      hos-arbiter/pom.xml
  2. 8 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/HosArbiterApplication.java
  3. 3 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/ArbiterServerController.java
  4. 2 2
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/BrokerServerController.java
  5. 3 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/EndpointController.java
  6. 22 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/ArbiterServer.java
  7. 14 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/BrokerServer.java
  8. 14 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/Endpoint.java
  9. 39 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/routers/LinuxShellRouter.java
  10. 156 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/LinuxShellService.java
  11. 8 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ServiceFlowService.java
  12. 78 0
      hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ShellService.java
  13. 10 4
      hos-arbiter/src/main/resources/application.yml
  14. 6 0
      hos-broker/pom.xml
  15. 40 0
      hos-broker/src/main/java/com/yihu/hos/broker/common/camelrouter/CrawlerMongoRouter.java
  16. 2 0
      hos-broker/src/main/java/com/yihu/hos/broker/common/constants/MonitorConstant.java
  17. 41 0
      hos-broker/src/main/java/com/yihu/hos/broker/common/processor/AddMongoProcessor.java
  18. 31 0
      hos-broker/src/main/java/com/yihu/hos/broker/common/processor/CrawlerMongoProcessor.java
  19. 9 114
      hos-broker/src/main/java/com/yihu/hos/broker/common/scheduler/MonitorScheduler.java
  20. 128 0
      hos-broker/src/main/java/com/yihu/hos/broker/common/shell/SSHLinuxTool.java
  21. 3 9
      hos-broker/src/main/java/com/yihu/hos/broker/configurations/MongoConfiguration.java
  22. 35 0
      hos-broker/src/main/java/com/yihu/hos/broker/controllers/ESBShellController.java
  23. 23 0
      hos-broker/src/main/java/com/yihu/hos/broker/models/BusinessLog.java
  24. 0 66
      hos-broker/src/main/java/com/yihu/hos/broker/models/ServiceMetrics.java
  25. 1 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/BusinessLogService.java
  26. 25 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/CenterMongoService.java
  27. 94 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/ServerMonitorService.java
  28. 61 0
      hos-broker/src/main/java/com/yihu/hos/broker/services/ServerShellService.java
  29. 42 19
      hos-broker/src/main/java/com/yihu/hos/broker/services/ServiceMonitorService.java
  30. 33 23
      hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java
  31. 20 2
      hos-broker/src/main/resources/application.yml
  32. 55 17
      hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java
  33. 32 0
      hos-rest/src/main/java/com/yihu/hos/rest/controllers/MetricController.java
  34. 38 0
      hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/MetricManager.java
  35. 13 0
      hos-web-framework/src/main/java/com/yihu/hos/web/framework/constant/ServiceFlowConstant.java
  36. 98 0
      hos-web-framework/src/main/java/com/yihu/hos/web/framework/model/bo/ServiceShell.java
  37. 5 0
      pom.xml
  38. 5 0
      src/main/java/com/yihu/hos/ESBApplication.java
  39. 366 0
      src/main/java/com/yihu/hos/common/graph/BFSGraph.java
  40. 75 0
      src/main/java/com/yihu/hos/common/graph/DGraph.java
  41. 56 0
      src/main/java/com/yihu/hos/common/graph/Edge.java
  42. 33 47
      src/main/java/com/yihu/hos/config/BeanConfig.java
  43. 9 7
      src/main/java/com/yihu/hos/config/MongoConfig.java
  44. 1 1
      src/main/java/com/yihu/hos/datacollect/service/DatacollectManager.java
  45. 3 3
      src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java
  46. 97 0
      src/main/java/com/yihu/hos/remoteManage/controller/RemoteShellController.java
  47. 101 0
      src/main/java/com/yihu/hos/remoteManage/service/RemoteShellService.java
  48. 66 0
      src/main/java/com/yihu/hos/services/ServiceShellEventService.java
  49. 9 0
      src/main/java/com/yihu/hos/system/controller/ProcessController.java
  50. 39 16
      src/main/java/com/yihu/hos/system/service/FlowManager.java
  51. 105 74
      src/main/java/com/yihu/hos/system/service/ProcessManager.java
  52. 27 12
      src/main/resources/application.yml
  53. 0 1
      src/main/webapp/WEB-INF/ehr/jsp/system/process/processJs.jsp

+ 0 - 1
hos-arbiter/pom.xml

@ -40,7 +40,6 @@
            <artifactId>hos-web-framework</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.zbus/zbus -->
        <dependency>
            <groupId>org.zbus</groupId>

+ 8 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/HosArbiterApplication.java

@ -2,6 +2,7 @@ package com.yihu.hos.arbiter;
import com.yihu.hos.arbiter.configuration.ArbiterServerConfiguration;
import com.yihu.hos.arbiter.services.ProxyService;
import com.yihu.hos.arbiter.services.ShellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
@ -16,6 +17,7 @@ import org.zbus.mq.server.MqServerConfig;
public class HosArbiterApplication implements CommandLineRunner {
    private ArbiterServerConfiguration configuration;
    private ProxyService proxyService;
    private ShellService shellService;
    public static void main(String[] args) {
        SpringApplication.run(HosArbiterApplication.class, args);
@ -32,6 +34,7 @@ public class HosArbiterApplication implements CommandLineRunner {
        }
        proxyService.start();
        shellService.start();
    }
    @Autowired
@ -43,4 +46,9 @@ public class HosArbiterApplication implements CommandLineRunner {
    public void setProxyService(ProxyService proxyService) {
        this.proxyService = proxyService;
    }
    @Autowired
    public void setShellService(ShellService shellService) {
        this.shellService = shellService;
    }
}

+ 3 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/ArbiterServerController.java

@ -3,12 +3,14 @@ package com.yihu.hos.arbiter.controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.arbiter.models.ArbiterServer;
import com.yihu.hos.arbiter.services.ArbiterServerService;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Date;
/**
 * @author Airhead
@ -26,6 +28,7 @@ public class ArbiterServerController {
    public void register(@RequestBody String body) {
        try {
            ArbiterServer arbiterServer = objectMapper.readValue(body, ArbiterServer.class);
            arbiterServer.setCreateTime(DateUtil.getSysDateTime());
            arbiterServerService.save(arbiterServer);
        } catch (IOException e) {
            e.printStackTrace();

+ 2 - 2
hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/BrokerServerController.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.arbiter.models.BrokerServer;
import com.yihu.hos.arbiter.services.BrokerServerService;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -26,7 +27,7 @@ public class BrokerServerController {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            BrokerServer server = objectMapper.readValue(brokerServer, BrokerServer.class);
            server.setUpdateTime(new Date());
            server.setCreateTime(DateUtil.getSysDateTime());
            brokerServerService.save(server);
        } catch (IOException e) {
            e.printStackTrace();
@ -55,7 +56,6 @@ public class BrokerServerController {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            BrokerServer server = objectMapper.readValue(brokerServer, BrokerServer.class);
            server.setUpdateTime(new Date());
            brokerServerService.delete(server);
        } catch (IOException e) {
            e.printStackTrace();

+ 3 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/controllers/EndpointController.java

@ -3,12 +3,14 @@ package com.yihu.hos.arbiter.controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.arbiter.models.Endpoint;
import com.yihu.hos.arbiter.services.EndpointService;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Date;
/**
 * @created Airhead 2016/7/27.
@ -24,6 +26,7 @@ public class EndpointController {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Endpoint endpoint = objectMapper.readValue(service, Endpoint.class);
            endpoint.setCreateTime(DateUtil.getSysDateTime());
            endpointService.save(endpoint);
        } catch (IOException e) {
            e.printStackTrace();

+ 22 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/ArbiterServer.java

@ -1,9 +1,12 @@
package com.yihu.hos.arbiter.models;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
 * @author Airhead
 * @since 2016/12/9.
@ -15,8 +18,11 @@ public class ArbiterServer {
    @Indexed
    private String tenant;
    private String url;
    private Date createTime;
    private Date updateTime;
    public ArbiterServer() {
        this.createTime = DateUtil.getSysDateTime();
    }
    public String getId() {
@ -42,4 +48,20 @@ public class ArbiterServer {
    public void setUrl(String url) {
        this.url = url;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 14 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/BrokerServer.java

@ -1,5 +1,6 @@
package com.yihu.hos.arbiter.models;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
@ -22,8 +23,13 @@ public class BrokerServer {
    private boolean registered;
    @Indexed(name = "updateTime_1", expireAfterSeconds = 30)
    private Date updateTime;
    private Date createTime;
    private ArrayList<ServiceFlow> serviceFlows;
    public BrokerServer() {
        this.createTime = DateUtil.getSysDateTime();
    }
    public boolean isFlowOn(String routeCode) {
        if (serviceFlows == null) {
            return false;
@ -62,6 +68,14 @@ public class BrokerServer {
        this.port = port;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }

+ 14 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/models/Endpoint.java

@ -1,5 +1,6 @@
package com.yihu.hos.arbiter.models;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
@ -22,6 +23,11 @@ public class Endpoint {
    private String healthCheckURL;
    private Integer metricsType;
    private String metricsURL;
    private Date createTime;
    public Endpoint() {
        this.createTime = DateUtil.getSysDateTime();
    }
    public String getId() {
        return id;
@ -47,6 +53,14 @@ public class Endpoint {
        this.endpoint = endpoint;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }

+ 39 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/routers/LinuxShellRouter.java

@ -0,0 +1,39 @@
package com.yihu.hos.arbiter.routers;
import com.yihu.hos.arbiter.configuration.ActivemqConfiguration;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.model.ModelCamelContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.jms.ConnectionFactory;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@Component
public class LinuxShellRouter extends RouteBuilder {
    @Autowired
    private ActivemqConfiguration activemqConfiguration;
    @Override
    public void configure() throws Exception {
        ModelCamelContext context = this.getContext();
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
                activemqConfiguration.getUser(), activemqConfiguration.getPassword(), activemqConfiguration.getBrokerURL());
        // Note we can explicit name the component
        context.addComponent("service.shell.event", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
        from(ServiceFlowConstant.SHELL_EVENT_ENDPOINT)
                .choice()
                .when(header("tenant").isNotNull()).to("bean:linuxShellService?method=proxy")
                .when(header("event").isEqualTo(ServiceFlowConstant.ARBITER_SHELL_SEND)).to("bean:linuxShellService?method=sendShell")
                .when(header("event").isEqualTo(ServiceFlowConstant.ARBITER_SHELL_ACEPT)).to("bean:linuxShellService?method=shellBack")
                .endChoice();
    }
}

+ 156 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/LinuxShellService.java

@ -0,0 +1,156 @@
package com.yihu.hos.arbiter.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.arbiter.models.BrokerServer;
import com.yihu.hos.core.http.HTTPResponse;
import com.yihu.hos.core.http.HttpClientKit;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.bo.ServiceShell;
import org.apache.camel.Body;
import org.apache.camel.Headers;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zbus.broker.ZbusBroker;
import org.zbus.mq.Producer;
import org.zbus.net.http.Message;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@Service("linuxShellService")
public class LinuxShellService {
    private static final Logger logger = LogManager.getLogger(LinuxShellService.class);
    @Autowired
    private BrokerServerService brokerServerService;
    private ZbusBroker zbusBroker;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * SAAS化的管理端过来的消息会被proxy进行中转,之后发送到终端的Arbiter对Broker进行实际的控制。
     *
     * @param header 消息头部信息
     * @param msg    消息
     */
    public void proxy(@Headers Map<String, String> header, @Body String msg) {
        if (zbusBroker == null) {
            logger.error("zbusBroker is null.");
            return;
        }
        try {
            //TODO 设置shell发起用户
            Producer producer = new Producer(zbusBroker, ServiceFlowConstant.SHELL_ARBITER + "@" + header.get("tenant"));
            producer.createMQ();    //确定为创建消息队列需要显示调用
            Message message = new Message();
            message.setHead("event", header.get("event"));
            message.setHead("tenant", header.get("tenant"));
            message.setMethod("POST");
            message.setBody(msg);
            message = producer.sendSync(message);
            logger.debug(message);
//            System.out.println("test");
        } catch (IOException | InterruptedException e) {
            logger.error(e.getMessage());
            e.printStackTrace();
        }
    }
    /**
     * 发送shell命令请求到broker
     * @param msg    命令消息内容
     */
    public void sendShell(String msg) {
        try {
            List<BrokerServer> brokerServerList  = brokerServerService.get(false);
            for (BrokerServer broker : brokerServerList) {
                String result = sendMessage(broker, "post", "/esb/serviceShell/send", msg);
                if (result==null) {
                    logger.error("sendMessage to broker server failed, broker:" + broker.getURL() + ", msg:" + msg);
                    continue;
                }else {
                    System.out.println("发送shell请求到broker成功!!!");
                    //TODO shell执行成功,见执行结果返回到中心显示。
                    ServiceShell serviceShell = objectMapper.readValue(msg,ServiceShell.class);
                    Producer producer = new Producer(zbusBroker, ServiceFlowConstant.SHELL_ADMIN + "@" + serviceShell.getTenant());
                    producer.createMQ();    //确定为创建消息队列需要显示调用
                    Message message = new Message();
                    message.setHead("event", serviceShell.getType());
                    message.setHead("tenant", serviceShell.getTenant());
                    message.setMethod("POST");
                    message.setBody(result);
                    message = producer.sendSync(message);
                    System.out.println("发送到中心zubs的shell结果!"+message);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
    }
    private String sendMessage(BrokerServer brokerServer, String method, String path, String msg) {
        if (brokerServer == null) {
            return null;
        }
        switch (method) {
            case "post": {
                HTTPResponse response = HttpClientKit.post(brokerServer.getURL() + path, msg);
                if (response.getStatusCode() == 200) {
                    String body = response.getBody();
                    System.out.println(body);
                    return body;
                }
                return null;
            }
            case "put": {
                HTTPResponse response = HttpClientKit.put(brokerServer.getURL() + path, msg);
                if (response.getStatusCode() == 200) {
                    String body = response.getBody();
                    logger.debug(body);
                    return body;
                }
                return null;
            }
            case "delete": {
                HTTPResponse response = HttpClientKit.delete(brokerServer.getURL() + path, msg);
                if (response.getStatusCode() == 200) {
                    String body = response.getBody();
                    logger.debug(body);
                    return body;
                }
                return null;
            }
            default:
                break;
        }
        return null;
    }
    @Autowired
    public void setZbusBroker(ZbusBroker zbusBroker) {
        this.zbusBroker = zbusBroker;
    }
}

+ 8 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ServiceFlowService.java

@ -1,6 +1,8 @@
package com.yihu.hos.arbiter.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.BasicDBObject;
import com.mongodb.WriteResult;
import com.yihu.hos.arbiter.models.BrokerServer;
import com.yihu.hos.core.http.HTTPResponse;
import com.yihu.hos.core.http.HttpClientKit;
@ -63,7 +65,13 @@ public class ServiceFlowService {
        update.set("flowType", serviceFlow.getFlowType());
        update.set("tenant", serviceFlow.getTenant());
        //删除旧记录
        Update delete = new Update();
        for (ServiceFlow.HandleFile handleFile : serviceFlow.getHandleFiles()) {
            delete.pull("handleFiles",new BasicDBObject("className",handleFile.getClassName()));
            Query deleteQuery = Query.query(Criteria.where("className").is(handleFile.getClassName()));
            WriteResult result = mongoOperations.updateFirst(deleteQuery, delete, ServiceFlow.HandleFile.class);
            update.addToSet("handleFiles", handleFile);
        }

+ 78 - 0
hos-arbiter/src/main/java/com/yihu/hos/arbiter/services/ShellService.java

@ -0,0 +1,78 @@
package com.yihu.hos.arbiter.services;
import com.yihu.hos.arbiter.configuration.ArbiterServerConfiguration;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zbus.broker.ZbusBroker;
import org.zbus.mq.Consumer;
import org.zbus.net.http.Message;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/6.
 */
@Service
public class ShellService {
    private static final Logger logger = LoggerFactory.getLogger(ShellService.class);
    private CamelContext camelContext;
    private ArbiterServerConfiguration configuration;
    private ZbusBroker zbusBroker;
    private Consumer consumer;
    public void proxy(Message message, Consumer consumer) {
        Map<String, Object> header = new HashMap<>();
        header.put("event", message.getHead("event"));
        ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
        producerTemplate.sendBodyAndHeaders(ServiceFlowConstant.SHELL_EVENT_ENDPOINT, message.getBodyString(), header);
    }
    public void start() {
        if (zbusBroker == null) {
            logger.error("zbusBroker is null");
            return;
        }
        consumer = new Consumer(zbusBroker, ServiceFlowConstant.SHELL_ARBITER + "@" + configuration.getTenant());
        try {
            consumer.start(this::proxy);
        } catch (IOException e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
    }
    @Autowired
    public void setZbusBroker(ZbusBroker zbusBroker) {
        this.zbusBroker = zbusBroker;
    }
    @Autowired
    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
    }
    @Autowired
    public void setConfiguration(ArbiterServerConfiguration configuration) {
        this.configuration = configuration;
    }
    @Override
    protected void finalize() throws Throwable {
        consumer.close();
        super.finalize();
    }
}

+ 10 - 4
hos-arbiter/src/main/resources/application.yml

@ -20,7 +20,7 @@ spring:
    password: admin
arbiter:
  timer:
      period: 10000
    period: 10000
  central:
    url:
    port: 15555
@ -34,14 +34,14 @@ spring:
  profiles: test
  data:
    mongodb:
      host: 172.19.103.86
      host: 172.19.103.58
      port: 27017
      username: esb
      password: esb
      authenticationDatabase: admin
      database: configuration
  activemq:
    broker-url: tcp://172.19.103.86:61616
    broker-url: tcp://172.19.103.58:61616
    user: admin
    password: admin
arbiter:
@ -106,4 +106,10 @@ arbiter:
  terminal:
    url: 192.168.131.38:15555
  tenant:
    name: yichang
    name: yichang
#jcraft shell操作
jcraft:
  host: 172.19.103.57
  port: 22
  user: root
  password: ceshi

+ 6 - 0
hos-broker/pom.xml

@ -95,6 +95,12 @@
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.53</version>
        </dependency>
    </dependencies>

+ 40 - 0
hos-broker/src/main/java/com/yihu/hos/broker/common/camelrouter/CrawlerMongoRouter.java

@ -0,0 +1,40 @@
package com.yihu.hos.broker.common.camelrouter;
import com.yihu.hos.broker.common.processor.CrawlerMongoProcessor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class CrawlerMongoRouter extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("quartz://myGroup/myTimerName?cron=0 0/1 * * * ? ")
            .process(new CrawlerMongoProcessor())
                .to("stream:out");
//            .process(new CrawlerMongoProcessor())
//            .to("mongodb:mongo?database=runtime&collection=arbiterServer&operation=findOneByQuery")
//            .split(simple("${body}"))
//            .process(new AddMongoProcessor("runtime", "arbiterServer"))
//            .to("bean:centerMongoService?method=save")
//            .process(new CrawlerMongoProcessor())
//            .to("mongodb:mongo?database=runtime&collection=brokerServer&operation=findOneByQuery")
//            .split(simple("${body}"))
//            .process(new AddMongoProcessor("runtime", "brokerServer"))
//            .to("bean:centerMongoService?method=save")
//            .process(new CrawlerMongoProcessor())
//            .to("mongodb:mongo?database=runtime&collection=endpoint&operation=findOneByQuery")
//            .split(simple("${body}"))
//            .process(new AddMongoProcessor("runtime", "endpoint"))
//            .to("bean:centerMongoService?method=save")
//            .process(new CrawlerMongoProcessor())
//            .to("mongodb:mongo?database=log&collection=server&operation=findOneByQuery")
//            .split(simple("${body}"))
//            .process(new AddMongoProcessor("log", "server"))
//            .to("bean:centerMongoService?method=save")
//            .process(new CrawlerMongoProcessor())
//            .to("mongodb:mongo?database=log&collection=service&operation=findOneByQuery")
//            .split(simple("${body}"))
//            .process(new AddMongoProcessor("log", "service"))
//            .to("bean:centerMongoService?method=save");
    }
}

+ 2 - 0
hos-broker/src/main/java/com/yihu/hos/broker/common/constants/MonitorConstant.java

@ -8,6 +8,8 @@ package com.yihu.hos.broker.common.constants;
public class MonitorConstant {
    public static String MONITOR_DATABASE = "log";
    public static String SERVER = "server";
    public static String SERVICE = "service";
    public static String BUSSINESS_LOG = "businessLog";
    public static String HOST = "host";     //这个是否需要,可以在runtime库中使用brokerServer?

+ 41 - 0
hos-broker/src/main/java/com/yihu/hos/broker/common/processor/AddMongoProcessor.java

@ -0,0 +1,41 @@
package com.yihu.hos.broker.common.processor;
import com.mongodb.BasicDBObject;
import com.mongodb.QueryOperators;
import com.yihu.hos.core.datatype.DateUtil;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.bson.types.ObjectId;
import org.json.JSONArray;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by Zdm on 2016/7/13.
 */
public class AddMongoProcessor implements Processor {
    private String database;
    private String collection;
    public AddMongoProcessor(String database, String collection) {
        this.database = database;
        this.collection = collection;
    }
    @Override
    public void process(Exchange exchange) throws Exception {
        Map record = exchange.getIn().getBody(Map.class);
        Map info = new HashMap();
        info.put("database", database);
        info.put("collection", collection);
        ObjectId objectId = (ObjectId) record.get("_id");
        record.put("_id", objectId.toString());
        JSONArray jsonArray = new JSONArray();
        jsonArray.put(info);
        jsonArray.put(record);
        exchange.getIn().setBody(jsonArray);
    }
}

+ 31 - 0
hos-broker/src/main/java/com/yihu/hos/broker/common/processor/CrawlerMongoProcessor.java

@ -0,0 +1,31 @@
package com.yihu.hos.broker.common.processor;
import com.mongodb.BasicDBObject;
import com.mongodb.QueryOperators;
import com.yihu.hos.core.datatype.DateUtil;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import java.util.Date;
/**
 * Created by Zdm on 2016/7/13.
 */
public class CrawlerMongoProcessor implements Processor {
    @Override
    public void process(Exchange exchange) throws Exception {
        Message out = exchange.getOut();
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 60000);
        String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        String endTime = DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.GTE, beginTime)),
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.LT, endTime))});
        out.setBody(queryObject.toJson());
    }
}

+ 9 - 114
hos-broker/src/main/java/com/yihu/hos/broker/common/scheduler/MonitorScheduler.java

@ -1,29 +1,13 @@
package com.yihu.hos.broker.common.scheduler;
import com.mongodb.*;
import com.yihu.hos.broker.common.constants.MonitorConstant;
import com.yihu.hos.broker.daos.BrokerDao;
import com.yihu.hos.broker.models.SystemServiceEndpoint;
import com.yihu.hos.broker.models.SystemServiceFlow;
import com.yihu.hos.broker.services.ServerMonitorService;
import com.yihu.hos.broker.services.ServiceMonitorService;
import com.yihu.hos.broker.util.SigarUtil;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 服务器性能数据采集定时器
@ -36,28 +20,17 @@ import java.util.List;
public class MonitorScheduler {
    static private final Logger logger = LoggerFactory.getLogger(MonitorScheduler.class);
    private static String host = SigarUtil.getHost();
    @Value("${hos.tenant.name}")
    private String tenant;
    @Autowired
    private MongoOperations mongoOperations;
    @Autowired
    private Mongo mongo;
    @Resource(name = ServiceMonitorService.BEAN_ID)
    private ServiceMonitorService serviceMonitorService;
    @Autowired
    private BrokerDao brokerDao;
    @Resource(name = ServerMonitorService.BEAN_ID)
    private ServerMonitorService serverMonitorService;
    @Scheduled(cron = "0 0/1 * * * ?") //每分钟执行一次
    public void statusCheck() {
        System.out.println("每分钟执行一次。开始============================================");
        //TODO 采集服务器健康监控指标数据 statusTask.healthCheck();
        collectEnvHealth();
        try {
            collectServiceHealth();
        } catch (Exception e) {
            e.printStackTrace();
        }
        collectServiceHealth();
        System.out.println("每分钟执行一次。结束。");
    }
@ -66,69 +39,12 @@ public class MonitorScheduler {
     *
     * @return
     */
    public String collectEnvHealth() {
        try {
            mongoOperations = new MongoTemplate(mongo, MonitorConstant.MONITOR_DATABASE);
            Document result = null;
            result = new Document();
            result.put("tenant", tenant);
            result.put("create_date", DateUtil.getCurrentString(DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
            result.put("create_time", new Date());
            result.put("host", host);
            //cpu
            JSONObject cpu = JSONObject.fromObject(SigarUtil.cpu());
            result.put("data", cpu);
            result.put("type", MonitorConstant.CPU);
            mongoOperations.insert(result, MonitorConstant.SERVER);
            //内存
            JSONObject memory = JSONObject.fromObject(SigarUtil.memory());
            result.put("data", memory);
            result.put("type", MonitorConstant.MEMORY);
            result.remove("_id");
            mongoOperations.insert(result, MonitorConstant.SERVER);
            //硬盘
            List<JSONObject> files = JSONArray.fromObject(SigarUtil.file());
            result.put("data", files);
            result.put("type", MonitorConstant.FILES);
            result.remove("_id");
            mongoOperations.insert(result, MonitorConstant.SERVER);
            //网络
            JSONObject net = JSONObject.fromObject(SigarUtil.net());
            result.put("data", net);
            result.put("type", MonitorConstant.NET);
            result.remove("_id");
            mongoOperations.insert(result, MonitorConstant.SERVER);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    public void collectEnvHealth() {
        serverMonitorService.collectEnvHealth();
    }
    public void collectServiceHealth() throws Exception {
        Date now = new Date();
        Date beforeDate = new Date(now.getTime() - 60000);
        String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        String endTime = DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        List<SystemServiceFlow> flowList = brokerDao.getSystemServiceFlowList();
        List<SystemServiceEndpoint> endpointList = brokerDao.getSystemServiceEndpointList();
        List<String> codeList = new ArrayList<>();
        for (SystemServiceFlow systemServiceFlow : flowList) {
            codeList.add(systemServiceFlow.getCode());
        }
        for (SystemServiceEndpoint systemServiceEndpoint : endpointList) {
            codeList.add(systemServiceEndpoint.getCode());
        }
        serviceMonitorService.bandwidth(beginTime, endTime, codeList);
        serviceMonitorService.qps(beginTime, endTime, codeList);
        serviceMonitorService.delay(beginTime, endTime, codeList);
        serviceMonitorService.usage(beginTime, endTime, codeList);
    public void collectServiceHealth() {
        serviceMonitorService.collectServiceHealth();
    }
    /**
@ -137,28 +53,7 @@ public class MonitorScheduler {
//    @Scheduled(cron = "0 0 12 * * ?") //每天中午12点触发
    @Scheduled(fixedDelay = 3600 * 24 * 1000, initialDelay = 3000) //每天中午12点触发
    public void checkHost() {
        mongoOperations = new MongoTemplate(mongo, MonitorConstant.MONITOR_DATABASE);
        DBCollection envCollection = mongoOperations.getCollection(MonitorConstant.HOST);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("tenant", tenant)});
        DBCursor cursor = envCollection.find(queryObject);
        if (cursor.size() < 1) {
            try {
                Document result = new Document();
                String host = SigarUtil.getHost();
                String hostName = SigarUtil.getHostName();
                result.put("tenant", tenant);
                result.put("name", hostName);
                result.put("host", host);
                mongoOperations.insert(result, MonitorConstant.HOST);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        serverMonitorService.checkHost();
    }
}

+ 128 - 0
hos-broker/src/main/java/com/yihu/hos/broker/common/shell/SSHLinuxTool.java

@ -0,0 +1,128 @@
package com.yihu.hos.broker.common.shell;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.io.OutputStream;
/**
 * ssh 链接操作测试类
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/3.
 */
@Service("SSHLinuxTool")
public class SSHLinuxTool {
    public static final String BEAN_ID = "SSHLinuxTool";
    @Value("${hos.jcraft.host}")
    private String host;
    @Value("${hos.jcraft.port}")
    private Integer port;
    @Value("${hos.jcraft.user}")
    private String user;
    @Value("${hos.jcraft.password}")
    private String password;
    public static Channel channel = null;
    /**
     * //TODO 密钥密码等验证
     * 建立一个shell连接会话
     *
     * @return
     * @throws JSchException
     */
    public Session getsessionConn() throws JSchException {
        JSch jsch = new JSch();
        Session session = jsch.getSession(user, host, port);
        session.setConfig("StrictHostKeyChecking", "no");
        //    java.util.Properties config = new java.util.Properties();
        //   config.put("StrictHostKeyChecking", "no");
        session.setTimeout(600000); // 设置timeout时间
        session.setPassword(password);
        session.connect();
        return session;
    }
//    public String exeCommand(Session session, String command, boolean exit) throws JSchException, IOException {
//
//        if (!session.isConnected()) {
//            session = getsessionConn();
//        }
//
//        ChannelExec channelExec = (ChannelExec) session.openChannel("exec");
//        InputStream in = channelExec.getInputStream();
//        channelExec.setCommand(command);
//        channelExec.setErrStream(System.err);
//        channelExec.connect();
//        String out = IOUtils.toString(in, "UTF-8");
//        if (exit) {
//            channelExec.disconnect();
//        }
//        return out;
//    }
    /**
     * 利用JSch实现远程主机SHELL命令执行
     */
    public  String sshShell(Session session, String command, boolean exit) throws Exception {
        //如果服务器连接不上,则抛出异常
        if (session == null) {
            throw new Exception("session is null");
        }
        try {
            //创建sftp通信通道
            if (channel == null) {
                channel = session.openChannel("shell");
                channel.connect(3000);
            }
            //获取输入流和输出流
            InputStream instream = channel.getInputStream();
            OutputStream outstream = channel.getOutputStream();
            //发送需要执行的SHELL命令,需要用\n结尾,表示回车
            String shellCommand = command + " \n";
            outstream.write(shellCommand.getBytes());
            outstream.flush();
            //获取命令执行的结果
            Thread.sleep(2000);
            if (instream.available() > 0) {
                byte[] data = new byte[instream.available()];
                int nLen = instream.read(data);
                if (nLen < 0) {
                    throw new Exception("network error.");
                }
                //转换输出结果并打印出来
                String temp = new String(data, 0, nLen, "iso8859-1");
                System.out.println(temp);
                return temp;
            }
            outstream.close();
            instream.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (exit) {
                channel.disconnect();
                session.disconnect();
            }
        }
        return null;
    }
}

+ 3 - 9
hos-broker/src/main/java/com/yihu/hos/broker/configurations/MongoConfiguration.java

@ -37,21 +37,15 @@ public class MongoConfiguration extends AbstractMongoConfiguration {
        return database;
    }
    @Override
    @Bean
    public Mongo mongo() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    private static MongoClient mongo;
    @Bean
    public MongoClient mongoClient() throws Exception {
        if(mongo == null) {
            return new MongoClient(singletonList(new ServerAddress(host, port)),
                    singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
        }
        return mongo;
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
}

+ 35 - 0
hos-broker/src/main/java/com/yihu/hos/broker/controllers/ESBShellController.java

@ -0,0 +1,35 @@
package com.yihu.hos.broker.controllers;
import com.yihu.hos.broker.services.ServerShellService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/6.
 */
@RestController
@RequestMapping("/esb")
public class ESBShellController {
    @Resource(name = ServerShellService.BEAN_ID)
    private ServerShellService serverShellService;
    @RequestMapping(value = "/serviceShell/send", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation(value = "shell命令执行", produces = "application/json", notes = "执行shell命令并返回结果")
    public Result onServiceFlowModifyAdd(
            @ApiParam(name = "msg", value = "消息", required = true)
            @RequestBody() String msg) {
        return serverShellService.executeShell(msg);
    }
}

+ 23 - 0
hos-broker/src/main/java/com/yihu/hos/broker/models/BusinessLog.java

@ -1,5 +1,6 @@
package com.yihu.hos.broker.models;
import com.yihu.hos.core.datatype.DateUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
@ -28,6 +29,12 @@ public class BusinessLog {
    private String body;
    private Integer bodyLength;
    private String fireTimeSource;
    private Date updateTime;
    private Date createTime;
    public BusinessLog() {
        this.createTime = DateUtil.getSysDateTime();
    }
    //@Indexed(name = "fireTime_1", expireAfterSeconds = 30)
    @Indexed
@ -144,4 +151,20 @@ public class BusinessLog {
    public void setOrder(String order) {
        this.order = order;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 0 - 66
hos-broker/src/main/java/com/yihu/hos/broker/models/ServiceMetrics.java

@ -1,66 +0,0 @@
package com.yihu.hos.broker.models;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
 * @created Airhead 2016/8/8.
 */
@Document(collection = "serviceMetrics")
public class ServiceMetrics {
    @Id
    private String id;
    private String type;
    private String name;
    private String value;
    private String createTime;
    private String tenant;
    public String getTenant() {
        return tenant;
    }
    public void setTenant(String tenant) {
        this.tenant = tenant;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/BusinessLogService.java

@ -27,6 +27,7 @@ public class BusinessLogService {
            String fireTimeSource = businessLog.getFireTimeSource();
            businessLog.setFireTime(DateUtil.toTimestamp(fireTimeSource));
            businessLog.setBodyLength(businessLog.getBody().length());
            businessLog.setCreateTime(DateUtil.getSysDateTime());
            mongoOperations.save(businessLog);
        } catch (IOException e) {
            e.printStackTrace();

+ 25 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/CenterMongoService.java

@ -0,0 +1,25 @@
package com.yihu.hos.broker.services;
import com.yihu.hos.core.http.HttpClientKit;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component("centerMongoService")
public class CenterMongoService {
    private static final Logger logger = LoggerFactory.getLogger(CenterMongoService.class);
    @Value("${hos.rest.url}")
    private String url;
    public void save(String msg) {
        Map<String, String> params = new HashMap<>();
        params.put("msg", msg);
        String returnData = HttpClientKit.post(url + "/metric/saveToMongo", params).getBody();
        System.out.println(returnData);
    }
}

+ 94 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/ServerMonitorService.java

@ -0,0 +1,94 @@
package com.yihu.hos.broker.services;
import com.mongodb.*;
import com.yihu.hos.broker.common.constants.MonitorConstant;
import com.yihu.hos.broker.util.SigarUtil;
import com.yihu.hos.core.datatype.DateUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("ServerMonitorService")
public class ServerMonitorService {
    public static final String BEAN_ID = "ServerMonitorService";
    @Value("${hos.tenant.name}")
    private String tenant;
    private static String host = SigarUtil.getHost();
    @Autowired
    private Mongo mongo;
    /**
     * 服务器健康指标采集
     *
     * @return
     */
    public void collectEnvHealth() {
        try {
            BasicDBObject result = new BasicDBObject();
            DBCollection terminal = mongo.getDB(MonitorConstant.MONITOR_DATABASE).getCollection(MonitorConstant.SERVER);
            result.put("tenant", tenant);
            result.put("create_date", DateUtil.getCurrentString(DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
            result.put("create_time", DateUtil.getSysDateTime());
            result.put("host", host);
            //cpu
            net.sf.json.JSONObject cpu = net.sf.json.JSONObject.fromObject(SigarUtil.cpu());
            result.put("data", cpu);
            result.put("type", MonitorConstant.CPU);
            terminal.insert(result);
            //内存
            net.sf.json.JSONObject memory = net.sf.json.JSONObject.fromObject(SigarUtil.memory());
            result.put("data", memory);
            result.put("type", MonitorConstant.MEMORY);
            result.remove("_id");
            terminal.insert(result);
            //硬盘
            List<net.sf.json.JSONObject> files = JSONArray.fromObject(SigarUtil.file());
            result.put("data", files);
            result.put("type", MonitorConstant.FILES);
            result.remove("_id");
            terminal.insert(result);
            //网络
            JSONObject net = JSONObject.fromObject(SigarUtil.net());
            result.put("data", net);
            result.put("type", MonitorConstant.NET);
            result.remove("_id");
            terminal.insert(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void checkHost() {
        DBCollection terminal = mongo.getDB(MonitorConstant.MONITOR_DATABASE).getCollection(MonitorConstant.HOST);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("tenant", tenant)});
        DBCursor cursor = terminal.find(queryObject);
        if (cursor.size() < 1) {
            try {
                BasicDBObject result = new BasicDBObject();
                String host = SigarUtil.getHost();
                String hostName = SigarUtil.getHostName();
                result.put("tenant", tenant);
                result.put("name", hostName);
                result.put("host", host);
                terminal.insert(result);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

+ 61 - 0
hos-broker/src/main/java/com/yihu/hos/broker/services/ServerShellService.java

@ -0,0 +1,61 @@
package com.yihu.hos.broker.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jcraft.jsch.Session;
import com.yihu.hos.broker.common.shell.SSHLinuxTool;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.model.bo.ServiceShell;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/6.
 */
@Service("ServerShellService")
public class ServerShellService {
    public static final String BEAN_ID = "ServerShellService";
    @Resource(name = SSHLinuxTool.BEAN_ID)
    private SSHLinuxTool sshLinuxTool;
    @Autowired
    private ObjectMapper objectMapper;
    public static Session session ;
    public Result executeShell(String msg) {
        String result="";
        try {
            ServiceShell serviceShell = objectMapper.readValue(msg , ServiceShell.class);
            if (session==null){
                session = sshLinuxTool.getsessionConn();
            }
            if (!serviceShell.isDisconnect()) {
                //保持通道连接
                System.out.println("执行命令,并保持当前会话==================");
                result = sshLinuxTool.sshShell(session, serviceShell.getCommand(), false);
                System.out.println("结果:"+result);
                return Result.success(result);
            } else {
                //断开通道连接,会话
                System.out.println("执行命令,并结束当前会话==================");
                result = sshLinuxTool.sshShell(session, serviceShell.getCommand(), true);
                session = null;
                System.out.println("结果:"+result);
                return Result.success(result);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.error("shell命令执行失败!");
    }
}

+ 42 - 19
hos-broker/src/main/java/com/yihu/hos/broker/services/ServiceMonitorService.java

@ -3,22 +3,20 @@ package com.yihu.hos.broker.services;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.*;
import com.yihu.hos.broker.models.BusinessLog;
import com.yihu.hos.broker.models.ServiceMetrics;
import com.yihu.hos.broker.common.constants.MonitorConstant;
import com.yihu.hos.broker.daos.BrokerDao;
import com.yihu.hos.broker.models.SystemServiceEndpoint;
import com.yihu.hos.broker.models.SystemServiceFlow;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.datatype.NumberUtil;
import com.yihu.hos.core.datatype.StringUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by chenweida on 2016/1/27.
@ -29,19 +27,44 @@ public class ServiceMonitorService {
    @Value("${hos.tenant.name}")
    private String tenant;
    @Autowired
    private MongoOperations mongoOperations;
    private Mongo mongo;
    @Autowired
    private BrokerDao brokerDao;
    private DBCollection businessLog;
    public DBCollection getBusinessLog() {
        if (businessLog == null) {
            businessLog = mongoOperations.getCollection(mongoOperations
                    .getCollectionName(BusinessLog.class));
            businessLog = mongo.getDB(MonitorConstant.MONITOR_DATABASE).getCollection(MonitorConstant.BUSSINESS_LOG);
        }
        return businessLog;
    }
    public void collectServiceHealth() {
        try {
            Date now = new Date();
            Date beforeDate = new Date(now.getTime() - 60000);
            String beginTime = DateUtil.toString(beforeDate, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
            String endTime = DateUtil.toString(now, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
            List<SystemServiceFlow> flowList = brokerDao.getSystemServiceFlowList();
            List<SystemServiceEndpoint> endpointList = brokerDao.getSystemServiceEndpointList();
            List<String> codeList = new ArrayList<>();
            for (SystemServiceFlow systemServiceFlow : flowList) {
                codeList.add(systemServiceFlow.getCode());
            }
            for (SystemServiceEndpoint systemServiceEndpoint : endpointList) {
                codeList.add(systemServiceEndpoint.getCode());
            }
            bandwidth(beginTime, endTime, codeList);
            qps(beginTime, endTime, codeList);
            delay(beginTime, endTime, codeList);
            usage(beginTime, endTime, codeList);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void bandwidth(String beginTime, String endTime, List<String> codeList) {
@ -247,7 +270,6 @@ public class ServiceMonitorService {
        Map<String, BigDecimal> delayMapF = new HashMap<>();
        for (DBObject dbObject : flowOutput.results()) {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("routeId"));
            String begin = StringUtil.toString(dbObject.get("beginTime"));
@ -356,13 +378,14 @@ public class ServiceMonitorService {
    }
    public void saveServiceMetrics(String name, String type, String value, String createTime) {
        ServiceMetrics serviceMetrics = new ServiceMetrics();
        serviceMetrics.setTenant(tenant);
        serviceMetrics.setName(name);
        serviceMetrics.setType(type);
        serviceMetrics.setValue(value);
        serviceMetrics.setCreateTime(createTime);
        mongoOperations.save(serviceMetrics);
        BasicDBObject document = new BasicDBObject();
        document.put("tenant", tenant);
        document.put("name", name);
        document.put("type", type);
        document.put("value", value);
        document.put("create_time", createTime);
        DBCollection terminal = mongo.getDB(MonitorConstant.MONITOR_DATABASE).getCollection(MonitorConstant.SERVICE);
        terminal.save(document);
    }
    public Integer isNull(Integer count) {

+ 33 - 23
hos-broker/src/main/java/com/yihu/hos/broker/services/camel/ESBCamelService.java

@ -1,10 +1,11 @@
package com.yihu.hos.broker.services.camel;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.result.DeleteResult;
import com.yihu.hos.broker.configurations.MongoConfiguration;
import com.yihu.hos.core.constants.CoreConstant;
import com.yihu.hos.core.datatype.ClassFileUtil;
@ -48,10 +49,10 @@ import java.util.ArrayList;
public class ESBCamelService {
    private static Logger logger = LogManager.getLogger(ESBCamelService.class);
    @Autowired
    private MongoConfiguration mongoConfig;
    private MongoClient mongoClient;
    private String serviceFlow = "serviceFlow";
    private String configuration = "configuration";
    private String configuration = "runtime";
    @Autowired
    private ObjectMapper objectMapper;
    @Value("${hos.esb.rest-url}")
@ -106,26 +107,28 @@ public class ESBCamelService {
            if (serviceFlowValid.is()) return Result.error("必要的入参数据不正确,请检查!");
            ServiceFlow serviceFlow = serviceFlowValid.getServiceFlow();
            ServiceFlow.HandleFile handleFile = serviceFlowValid.getHandleFile();
            SystemCamelContext.stopRouter(serviceFlow.getRouteCode());
            SystemCamelContext.removeRouter(serviceFlow.getRouteCode());
            boolean created;
            if ("java".equals(handleFile.getFileType())) {
                created = this.generateClassFile(handleFile);
            } else {
                created = this.createClassFile(handleFile);
            }
            if (!created) {
                return Result.error("服务流程变更增加失败!");
            ArrayList<ServiceFlow.HandleFile> handleFiles = serviceFlowValid.getHandleFiles();
            for (ServiceFlow.HandleFile handleFile : handleFiles) {
                if ("java".equals(handleFile.getFileType())) {
                    created = this.generateClassFile(handleFile);
                } else {
                    created = this.createClassFile(handleFile);
                }
                if (!created) {
                    return Result.error("服务流程变更增加失败!");
                }
            }
            SystemCamelContext.stopRouter(serviceFlow.getRouteCode());
            SystemCamelContext.removeRouter(serviceFlow.getRouteCode());
            this.addRouter(serviceFlowValid.getHandleFiles());
            SystemCamelContext.startRouter(serviceFlow.getRouteCode());
            return Result.error("服务流程变更增加成功!");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e);
//            logger.error(e);
            return Result.error("服务流程变更增加失败!");
        }
    }
@ -258,7 +261,6 @@ public class ESBCamelService {
        SystemCamelContext.putClassMapping(handleFile.getRouteCode(), handleFile.getPackageName(), handleFile.getUsage(), handleFile.getClassName());
        URL resource = SystemCamelContext.getResource(this);
//        FileOutputStream outputStream = ClassFileUtil.createFile(resource, handleFile.getPackageName(), handleFile.getClassName(), ClassFileUtil.JAVA_FILE);
        String fileName = DES.decrypt(handleFile.getFilePath(), DES.COMMON_PASSWORD);
//        MongoDatabase db = mongoConfig.mongoClient().getDatabase(dbName);
//
//        boolean read = GridFSUtil.readFileContent(db, outputStream, fileName);
@ -283,14 +285,15 @@ public class ESBCamelService {
            String classPath =  resource.getPath()+ packagePath + "/" + handleFile.getClassName() + ClassFileUtil.CLASS_FILE;
//            GridFSUtil.uploadFile(classPath, handleFile.getClassName() + handleFile.getRouteCode() + ClassFileUtil.CLASS_FILE, null);
//            TODO 上传到本地mongodb和中心mongodb
            String enFileName = DES.encrypt(handleFile.getClassName() + handleFile.getRouteCode() + ClassFileUtil.CLASS_FILE, DES.COMMON_PASSWORD);
            String fileName = DES.decrypt(handleFile.getFilePath(), DES.COMMON_PASSWORD).replaceAll(ClassFileUtil.JAVA_FILE,ClassFileUtil.CLASS_FILE);
            String enFileName = DES.encrypt(fileName, DES.COMMON_PASSWORD);
            String uploadUrl = centerUrl + "/tenant/upload/" + enFileName;
            ClassFileUtil.uploadFile(uploadUrl,new File(classPath),handleFile.getClassName() + handleFile.getRouteCode() + ClassFileUtil.CLASS_FILE);
            ClassFileUtil.uploadFile(uploadUrl,new File(classPath),fileName);
        }
        return succ;
    }
    private void deleteClassFile(ServiceFlow.HandleFile handleFile) {
    private void deleteClassFile(ServiceFlow.HandleFile handleFile) throws Exception {
//        String className = SystemCamelContext.getClassMapping(handleFile.getRouteCode(), handleFile.getClassName(), handleFile.getUsage());
//        if (StringUtil.isEmpty(className)) {
//            return;
@ -303,9 +306,16 @@ public class ESBCamelService {
        ClassFileUtil.deleteClassfile(classPath);
        ClassFileUtil.deleteClassfile(javaPath);
        //TODO 从中心删除
        String uploadUrl = centerUrl + "/tenant/delFile/" + javaPath;
        ClassFileUtil.deleteFile(uploadUrl);
        //删除class文件
        String delJavaUrl = centerUrl + "/tenant/delFile/" + handleFile.getFilePath();
        ClassFileUtil.deleteFile(delJavaUrl);
        //删除java文件
        String classFilePath = DES.decrypt( handleFile.getFilePath(),DES.COMMON_PASSWORD);
        String javaFilePath = classFilePath.replace(ClassFileUtil.CLASS_FILE,ClassFileUtil.JAVA_FILE);
        String enJavaPath = DES.encrypt(javaFilePath,DES.COMMON_PASSWORD);
        String delClassUrl = centerUrl + "/tenant/delFile/" + enJavaPath;
         ClassFileUtil.deleteFile(delClassUrl);
        // 完成
        logger.info("===================" + handleFile.getPackageName() + CoreConstant.DOT + handleFile.getClassName() + ".class 删除过程结束");
    }
@ -317,9 +327,9 @@ public class ESBCamelService {
     */
    private void deleteServiceFlow(String routeCode) {
        try {
            MongoDatabase db = mongoConfig.mongoClient().getDatabase(configuration);
            MongoDatabase db = mongoClient.getDatabase(configuration);
            MongoCollection<Document> collection = db.getCollection(serviceFlow);
            DeleteResult result = collection.deleteMany(Filters.eq("routeCode", routeCode));
            collection.deleteMany(Filters.eq("routeCode", routeCode));
        } catch (Exception e) {
            e.printStackTrace();
        }

+ 20 - 2
hos-broker/src/main/resources/application.yml

@ -36,7 +36,7 @@ spring:
      password: admin
  data:
    mongodb:
      host: 172.19.103.57
      host: 172.19.103.58
      port: 27017
      username: esb
      password: esb
@ -52,10 +52,18 @@ hos:
  arbiter:
    enable: true
    url: http://localhost:10135
  rest:
    url: http://localhost:8088
  timer:
      period: 10000
  tenant:
    name: jkzl
  #jcraft shell操作
  jcraft:
    host: 172.19.103.57
    port: 22
    user: root
    password: ceshi
---
spring:
@ -74,7 +82,7 @@ spring:
      min-idle: 10
      initial-size: 10
  activemq:
      broker-url: tcp://172.19.103.57:61616
      broker-url: tcp://172.19.103.58:61616
      user: admin
      password: admin
  data:
@ -95,6 +103,8 @@ hos:
  arbiter:
    enable: false
    url: http://172.19.103.57:10135
  rest:
    url: http://localhost:8088
  timer:
      period: 10000
@ -138,7 +148,15 @@ hos:
  arbiter:
    enable: true
    url: http://192.168.131.38:10135
  rest:
    url: http://localhost:8088
  timer:
      period: 10000
  tenant:
    name: yichang
  #jcraft shell操作
  jcraft:
    host: 172.19.103.57
    port: 22
    user: root
    password: ceshi

+ 55 - 17
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -1,6 +1,7 @@
package com.yihu.hos.core.datatype;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.core.file.FileUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
@ -15,12 +16,10 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map;
public class ClassFileUtil {
    public static final String CLASS_FILE = ".class";
@ -216,8 +215,8 @@ public class ClassFileUtil {
    public static String uploadFile(String uploadUrl, File file,String fileName) {
        try {
            byte[] bytes = upload(uploadUrl, file,fileName);//文件内容
            if (bytes!=null){
            boolean succ = upload(uploadUrl, file,fileName);//文件内容
            if (succ){
                return fileName;
            }else {
                return null;
@ -260,12 +259,12 @@ public class ClassFileUtil {
    }
    /**
     *  http 上传文件请求
     *  http 上传文件到中心请求
     * @param url  请求地址
     * @param file  文件名
     * @return
     */
    public static byte[] upload( String url,File file,String fileName) {
    public static boolean upload( String url,File file,String fileName) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        CloseableHttpResponse response = null;
@ -279,11 +278,20 @@ public class ClassFileUtil {
            httpPost.setEntity(reqEntity1.build());
            response = httpClient.execute(httpPost);
            response.setHeader( "Content-Type", "application/octet-stream;charset=UTF-8");
            response.setHeader( "Content-Type", "application/json;charset=UTF-8");
            entity = response.getEntity();
            byte[] bytes= FileUtil.getBytesByStream(entity.getContent());
//            EntityUtils.toString(response.getEntity(), "UTF-8");
            return bytes;
            int code = response.getStatusLine().getStatusCode();
            Map<String,Object> responMap = parseRespon(entity);
            if (code == 200){
                boolean succ = (boolean) responMap.get("successFlg");
                if (!succ){
                    System.out.println("请求成功,上传失败!message:"+responMap.get("message").toString());;
                }
                return succ;
            }else {
                System.out.println("上传请求失败,status:"+code);
                return false;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
@ -295,10 +303,15 @@ public class ClassFileUtil {
            }
        }
        return null;
        return false;
    }
    public static String deleteFile( String url) {
    /**
     * http请求 从管理中心删除文件
     * @param url
     * @return
     */
    public static boolean deleteFile( String url) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        CloseableHttpResponse response = null;
@ -307,9 +320,20 @@ public class ClassFileUtil {
            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000*60*5).setConnectTimeout(1000*60*5).build();//设置请求和传输超时时间
            httpPost.setConfig(requestConfig);
            response = httpClient.execute(httpPost);
            response.setHeader( "Content-Type", "application/octet-stream;charset=UTF-8");
            response.setHeader( "Content-Type", "application/json;charset=UTF-8");
            entity = response.getEntity();
            return entity.toString();
            int code = response.getStatusLine().getStatusCode();
            Map<String,Object> responMap = parseRespon(entity);
            if (code == 200){
                boolean succ = (boolean) responMap.get("successFlg");
                if (!succ){
                    System.out.println("请求成功,删除失败!message:"+responMap.get("message").toString());;
                }
                return succ;
            }else {
                System.out.println("删除请求失败,status:"+code);
                return false;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
@ -321,7 +345,21 @@ public class ClassFileUtil {
            }
        }
        return null;
        return false;
    }
    public static  Map<String,Object> parseRespon(HttpEntity entity ) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
        String line = null;
        while ((line = br.readLine()) != null) {
            stringBuilder.append(line);
        }
        String responseText = stringBuilder.toString();
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String,Object> map = objectMapper.readValue(responseText,Map.class);
        return map;
    }
}

+ 32 - 0
hos-rest/src/main/java/com/yihu/hos/rest/controllers/MetricController.java

@ -0,0 +1,32 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.rest.services.crawler.MetricManager;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
 * 应用管理
 */
@RequestMapping("/metric")
@Controller
public class MetricController extends BaseController {
    @Resource(name = MetricManager.BEAN_ID)
    private MetricManager metricManager;
    @RequestMapping("/saveToMongo")
    @ResponseBody
    public Result saveToMongo(String msg) {
        try {
            Result result = metricManager.saveToMongo(msg);
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
}

+ 38 - 0
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/MetricManager.java

@ -0,0 +1,38 @@
package com.yihu.hos.rest.services.crawler;
import com.yihu.ehr.dbhelper.mongodb.MongodbHelper;
import com.yihu.hos.web.framework.model.Result;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
@Service("MetricManager")
public class MetricManager {
    public static final String BEAN_ID = "MetricManager";
    MongodbHelper mongoLog = new MongodbHelper("log");
    MongodbHelper mongoRuntime = new MongodbHelper("runtime");
    public Result saveToMongo(String msg) {
        JSONArray jsonArray = new JSONArray(msg);
        JSONObject info = (JSONObject) jsonArray.get(0);
        String database = info.getString("database");
        MongodbHelper mongo;
        if (database.equals("log")) {
            mongo = mongoLog;
        } else {
            mongo = mongoRuntime;
        }
        String collection = info.getString("collection");
        JSONObject record = (JSONObject) jsonArray.get(1);
        JSONObject jsonObject = new JSONObject();
        for (Object key : record.keySet()) {
            jsonObject.put((String) key, record.get((String) key).toString());
        }
        try {
            mongo.insert(collection, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success("保存成功!");
    }
}

+ 13 - 0
hos-web-framework/src/main/java/com/yihu/hos/web/framework/constant/ServiceFlowConstant.java

@ -39,4 +39,17 @@ public interface ServiceFlowConstant {
    //ArbiterServer MQ
    String SSH = "ssh";
    // shell 请求命令,对列名称
    String SHELL_EVENT_QUEUE = "configuration.service.shell";
    String SHELL_EVENT_ENDPOINT = "service.shell.event:queue:configuration.service.shell";
    //Arbiter shell
    String ARBITER_SHELL_SEND = "arbiterShellSend"; //shell 命令执行消息
    String ARBITER_SHELL_ACEPT = "arbiterShellAcept"; //shell 执行结果消息
    //arbiter 发送shell命令 消息队列
    String SHELL_ARBITER = "shell_arbiter";
    // hos-admin 接收shell执行结果
    String SHELL_ADMIN = "shell_admin";
}

+ 98 - 0
hos-web-framework/src/main/java/com/yihu/hos/web/framework/model/bo/ServiceShell.java

@ -0,0 +1,98 @@
package com.yihu.hos.web.framework.model.bo;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@Document
public class ServiceShell {
    @Id
    private String id;
    private String name;
    private String type;    //send or acept?
    private Date updated;
    private String fromHost;
    private String tenant;
    private String command;
    private String result;
    private boolean disconnect;//是否断开连接
    public boolean isDisconnect() {
        return disconnect;
    }
    public void setDisconnect(boolean disconnect) {
        this.disconnect = disconnect;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Date getUpdated() {
        return updated;
    }
    public void setUpdated(Date updated) {
        this.updated = updated;
    }
    public String getFromHost() {
        return fromHost;
    }
    public void setFromHost(String fromHost) {
        this.fromHost = fromHost;
    }
    public String getTenant() {
        return tenant;
    }
    public void setTenant(String tenant) {
        this.tenant = tenant;
    }
    public String getCommand() {
        return command;
    }
    public void setCommand(String command) {
        this.command = command;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
}

+ 5 - 0
pom.xml

@ -143,6 +143,11 @@
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>
        <dependency>
            <groupId>org.zbus</groupId>
            <artifactId>zbus</artifactId>
            <version>7.2.0</version>
        </dependency>
    </dependencies>
    <build>

+ 5 - 0
src/main/java/com/yihu/hos/ESBApplication.java

@ -36,4 +36,9 @@ public class ESBApplication extends WebMvcConfigurerAdapter {
    public Queue queue() {
        return new ActiveMQQueue(ServiceFlowConstant.FLOW_EVENT_QUEUE);
    }
    @Bean(name = "shellQueue")
    public Queue shellQueue() {
        return new ActiveMQQueue(ServiceFlowConstant.SHELL_EVENT_QUEUE);
    }
}

+ 366 - 0
src/main/java/com/yihu/hos/common/graph/BFSGraph.java

@ -0,0 +1,366 @@
package com.yihu.hos.common.graph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
 * 邻接链表(Adjacency List)实现的有向图
 * @param <V>
 */
public class BFSGraph<V> implements DGraph<V>{
    private static Logger logger = LoggerFactory.getLogger(BFSGraph.class);
    /**
     * 顶点对象,其中有对应的顶点以及从以此顶点为起点的边
     */
    private class VE {
        /**此顶点*/
        private V v;
        /**以此顶点为起点的边的集合,是一个列表,列表的每一项是一条边*/
        private List<Edge<V>> mEdgeList;
        
        /**
         * 构造一个新的顶点对象
         * @param v
         */
        public VE(V v) {
            this.v = v;
            this.mEdgeList = new LinkedList<Edge<V>>();
            logger.info("VE construct : %s", v);
        }
        
        @Override
        public String toString() {
            String ret = String.format("v : %s , list len : %s",
                                       v, mEdgeList.size());
            return ret;
        }
        
        /**
         * 将一条边添加到边集合中
         * @param e
         */
        public void addEdge(Edge<V> e) {
            logger.info("add edge : %s", e);
            if(getEdge(e.getDest()) == null) {
                mEdgeList.add(e);
            } else {
                logger.info("edge exist : %s", e);
            }
        }
        
        /**
         * 读取某条边
         * @param dest
         * @return
         */
        public Edge<V> getEdge(V dest) {
            Edge<V> ret = null;
            if(dest != null) {
                for(Edge<V> edge : mEdgeList) {
                    if(edge.getDest() != null &&
                       dest.equals(edge.getDest())) {
                        logger.info("get edge : %s", edge);
                        ret = edge;
                        break;
                    }
                }
            }
            return ret;
        }
        
        /**
         * 读取某条边
         * @param dest
         * @return
         */
        public Edge<V> removeEdge(V dest) {
            Edge<V> ret = null;
            if(dest != null) {
                for(Edge<V> edge : mEdgeList) {
                    if(edge.getDest() != null &&
                       dest.equals(edge.getDest())) {
                        logger.info("remove edge : %s", edge);
                        ret = edge;
                        mEdgeList.remove(edge);
                        break;
                    }
                }
            }
            return ret;
        }
    }
    
    /**
     * 广度优先的迭代器
     */
    private class BFSIterator implements Iterator<V> {
        /**已访问过的顶点列表*/
        private List<V> mVisitList = null;
        /**待访问的顶点队列*/
        private Queue<V> mVQueue = null;
        
        /**
         * 构造广度优先迭代器
         * @param root
         */
        public BFSIterator(V root) {
            mVisitList = new LinkedList<V>();
            mVQueue = new LinkedList<V>();
            
            //将初始节点入队列
            mVQueue.offer(root);
        }
        
        @Override
        public boolean hasNext() {
            logger.info("queue size : " + mVQueue.size());
            if(mVQueue.size() > 0) {
                return true;
            } else {
                return false;
            }
        }
        @Override
        public V next() {
            //1.取队列元素
            V v = mVQueue.poll();
            
            if(v != null) {
                //2.将此元素的邻接边中对应顶点入队列,这些顶点需要符合以下条件:
                //1)没访问过;
                //2)不在队列中;
                VE ve = getVE(v);
                if(ve != null) {
                    List<Edge<V>> list = ve.mEdgeList;
                    for(Edge<V> edge : list) {
                        V dest = edge.getDest();
                        if(!VinList(dest, mVisitList.iterator()) &&
                           !VinList(dest, mVQueue.iterator())) {
                            mVQueue.offer(dest);
                            logger.info("add to queue : " + dest);
                        }
                    }
                }
                
                //3.将此顶点添加到已访问过的顶点列表中
                mVisitList.add(v);
            }
            
            //4.返回出队列的元素
            return v;
        }
        @Override
        public void remove() {
            // 暂时不实现
        }
        
    }
    
    /**顶点列表,由于会经常进行插入删除,使用链表队列*/
    private LinkedList<VE> mVEList;
    /**
     * 构造邻接链表有向图
     */
    public BFSGraph() {
        mVEList = new LinkedList<VE>();
        logger.info("ListDGraph construct!");
    }
    @Override
    public int add(V v) {
        int index = -1;
        if(v != null) {
            logger.info("add v: %s", v);
            VE ve = new VE(v);
            mVEList.add(ve);
            index = mVEList.indexOf(ve);
        }
        return index;
    }
    @Override
    public void add(Edge<V> e) {
        if(e != null) {
            logger.info("add edge: %s", e);
            VE ve = getVE(e.getSource());
            if(ve != null) {
                //若边的起点已经在列表里,则直接将其添加到对应的顶点对象中
                ve.addEdge(e);
            } else {
                //否则提示错误
                logger.info("Error, can't find v : %s", e.getSource());
            }
        }
    }
    
    @Override
    public V remove(V v) {
        V ret = null;
        
        VE ve = removeVE(v);
        if(ve != null) {
            ret = ve.v;
        }
        
        removeRelateEdge(v);
        
        return ret;
    }
    @Override
    public Edge<V> remove(Edge<V> e) {
        Edge<V> ret = null;
        
        if(e != null) {
            VE ve = getVE(e.getSource());
            if(ve != null) {
                ret = ve.removeEdge(e.getDest());
            }
        }
        
        return ret;
    }
    @Override
    public V get(int index) {
        V ret = null;
        if(index >=0 && index < mVEList.size()) {
            VE ve = mVEList.get(index);
            if(ve != null) {
                ret = ve.v;
                logger.info("get , index : %s , v : %s", index, ret);
            }
        }
        return ret;
    }
    @Override
    public Edge<V> get(int src, int dest) {
        Edge<V> ret = null;
        V s = get(src);
        V d = get(dest);
        if(s != null && d != null) {
            VE ve = getVE(s);
            if(ve != null) {
                ret = ve.getEdge(d);
            }
        }
        return ret;
    }
    @Override
    public Iterator<V> iterator(V root) {
        Iterator<V> ret = null;
            //广度优先的迭代器
        ret = new BFSIterator(root);
        return ret;
    }
    @Override
    public void convertDAG() {
        // TODO Auto-generated method stub
        
    }
    /**
     * 从顶点对象列表中读取输入顶点对应的所有边对象
     * @param v
     * @return
     */
    @Override
    public List<Edge<V>> getEdgeList(V v) {
        List<Edge<V>> edgeList = new ArrayList<>();
        VE ret = null;
        if(v != null) {
            for(VE ve : mVEList) {
                if(ve.v != null && v.equals(ve.v)) {
                    logger.info("getVE : %s", ve);
                    ret = ve;
                    break;
                }
            }
        }
        if (ret != null) {
            return ret.mEdgeList;
        }
        return edgeList;
    }
    //////////////////////////////私有方法//////////////////////////////
    /**
     * 从顶点对象列表中读取输入顶点对应的对象
     * @param v
     * @return
     */
    public VE getVE(V v) {
        VE ret = null;
        if(v != null) {
            for(VE ve : mVEList) {
                if(ve.v != null && v.equals(ve.v)) {
                    logger.info("getVE : %s", ve);
                    ret = ve;
                    break;
                }
            }
        }
        return ret;
    }
    /**
     * 从顶点对象列表中删除输入顶点对应的对象
     * @param v
     * @return 删除的顶点对象
     */
    private VE removeVE(V v) {
        VE ret = null;
        if(v != null) {
            for(VE ve : mVEList) {
                if(ve.v != null && v.equals(ve.v)) {
                    logger.info("removeVE : %s", v);
                    ret = ve;
                    mVEList.remove(ve);
                    break;
                }
            }
        }
        return ret;
    }
    
    /**
     * 删除以某个点作为重点的边
     * @param v
     */
    private void removeRelateEdge(V v) {
        if(v != null) {
            for(VE ve : mVEList) {
                ve.removeEdge(v);
            }
        }
    }
    
    /**
     * 判断某个端点是否在某个列表里
     * @param v
     * @param it
     * @return
     */
    private boolean VinList(V v, Iterator<V> it) {
        boolean ret = false;
        
        if(v != null && it != null) {
            while(it.hasNext()) {
                V v_temp = it.next();
                if(v_temp != null && v_temp.equals(v)) {
                    ret = true;
                    break;
                }
            }
        }
        
        return ret;
    }
}

+ 75 - 0
src/main/java/com/yihu/hos/common/graph/DGraph.java

@ -0,0 +1,75 @@
package com.yihu.hos.common.graph;
import java.util.Iterator;
import java.util.List;
/**
 * 有向图接口,定义需要实现的各个方法,可以选择使用邻接矩阵或者邻接链表来实现
 * @param <V> V代表端点,可以根据需要设置器数据类型
 */
public interface DGraph<V> {
    
    /**广度优先遍历*/
    public static final int ITERATOR_TYPE_BFS = 0;
    
    /**
     * 添加一个端点
     * @param v
     * @return 新增端点的编号,-1表示插入失败
     */
    public int add(V v);
    
    /**
     * 添加一个边
     * @param e
     */
    public void add(Edge<V> e);
    
    /**
     * 删除一个顶点,与其相连的边也会被删除
     * @param v
     * @return 被删除的顶点,如果找不到对应顶点则返回null
     */
    public V remove(V v);
    
    /**
     * 删除一条边
     * @param e
     * @return 被删除的边,如果找不到对应的边则返回null
     */
    public Edge<V> remove(Edge<V> e);
    
    /**
     * 获得一个顶点
     * @param index 顶点的编号
     * @return
     */
    public V get(int index);
    
    /**
     * 获得一条边
     * @param src 起点的编号
     * @param dest 终点的编号
     * @return
     */
    public Edge<V> get(int src, int dest);
    
    /**
     * 得到当前图的迭代器,用于对图进行遍历
     * @param root 从哪个点开始遍历
     * @return
     */
    public Iterator<V> iterator(V root);
    
    /**
     * 将图转换为无环图
     */
    public void convertDAG();
    /**
     * 从顶点对象列表中读取输入顶点对应的所有边对象
     * @param v
     * @return
     */
    public List<Edge<V>> getEdgeList(V v);
}

+ 56 - 0
src/main/java/com/yihu/hos/common/graph/Edge.java

@ -0,0 +1,56 @@
package com.yihu.hos.common.graph;
/**
 * 一条边,可以根据需要继承此类
 * @param <V>
 */
public class Edge<V> {
    /**起点*/
    private V src;
    /**终点*/
    private V dest;
    /**名称*/
    private V name;
    
    /**
     * 带名称的一条边
     * @param src
     * @param dest
     * @param name
     */
    public Edge(V src, V dest, V name) {
        this.src = src;
        this.dest = dest;
        this.name = name;
    }
    
    /**
     * 获取起点
     * @return
     */
    public V getSource() {
        return this.src;
    }
    
    /**
     * 获取终点
     * @return
     */
    public V getDest() {
        return this.dest;
    }
    
    /**
     * 获取名称
     * @return
     */
    public V getName() {
        return this.name;
    }
    
    @Override
    public String toString() {
        String ret = String.format("src : %s , dest : %s , weight : %s", src, dest, name);
        return ret;
    }
}

+ 33 - 47
src/main/java/com/yihu/hos/config/BeanConfig.java

@ -3,13 +3,11 @@ package com.yihu.hos.config;
import com.yihu.hos.interceptor.AuditInterceptor;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.core.env.Environment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@ -21,10 +19,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.zbus.broker.ZbusBroker;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
/**
@ -36,57 +35,45 @@ import java.util.Properties;
@EnableTransactionManagement
@ComponentScan("com.yihu.hos")
//@ImportResource({"classpath:spring/applicationContext.xml"}) //applicationContext相关bean创建
public class BeanConfig  implements EnvironmentAware {
public class BeanConfig {
    @Autowired
    BasicDataSource dataSource;
//    @Value("${spring.jpa.hibernate.dialect}")
//    private String dialect;
//    @Value("${spring.jpa.format-sql}")
//    private String formatSql;
//    @Value("${spring.jpa.show-sql}")
//    private String showSql;
    @Value("${hos.zbus.url}")
    private String zbusUrl;
    private ZbusBroker zbusBroker;
    private Environment environment;
    private Map<String , Object> hibernatePropertyResolver;
    private Map<String , Object> datasourcePropertyResolver;
    //从application.yml中读取资源
    @Bean
    public ZbusBroker getZbusBroker() {
        try {
            zbusBroker = new ZbusBroker(this.zbusUrl);
            return zbusBroker;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
        datasourcePropertyResolver = new RelaxedPropertyResolver(environment).getSubProperties("spring.datasource.");
        this.hibernatePropertyResolver = new RelaxedPropertyResolver(environment).getSubProperties("spring.jpa.");
    protected void finalize() throws Throwable {
        if (zbusBroker != null) {
            zbusBroker.close();
        }
        super.finalize();
    }
    //sessionFactory
//    @Bean
//    public LocalSessionFactoryBean sessionFactory() throws SQLException {
//        LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
//        localSessionFactoryBean.setDataSource(this.dataSource);
//        Properties properties1 = new Properties();
//        properties1.setProperty("hibernate.dialect",hibernatePropertyResolver.get("hibernate.dialect").toString());
//        properties1.setProperty("hibernate.show_sql",hibernatePropertyResolver.get("show-sql").toString());
//        properties1.setProperty("hibernate.format_sql",hibernatePropertyResolver.get("format-sql").toString());
//        localSessionFactoryBean.setHibernateProperties(properties1);
//        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.*.model");
//        ResourceLoader resourceLoader = new DefaultResourceLoader();
//        Resource resource = resourceLoader.getResource("classpath:resource/");
//        localSessionFactoryBean.setMappingDirectoryLocations(resource);
////        localSessionFactoryBean.setPackagesToScan("*");
//        return localSessionFactoryBean;
//    }
    @Bean
    public LocalSessionFactoryBean sessionFactory()   {
    public LocalSessionFactoryBean sessionFactory() {
        LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
        localSessionFactoryBean.setDataSource(this.dataSource);
        Properties properties1 = new Properties();
        properties1.setProperty("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");
        properties1.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
        properties1.setProperty("hibernate.show_sql", "false");
        properties1.setProperty("hibernate.format_sql","true");
        properties1.setProperty("hibernate.format_sql", "true");
        localSessionFactoryBean.setHibernateProperties(properties1);
        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.*.model");
        ResourceLoader resourceLoader = new DefaultResourceLoader();
@ -131,23 +118,22 @@ public class BeanConfig  implements EnvironmentAware {
    //文经上传
    @Bean
    public CommonsMultipartResolver multipartResolver(){
    public CommonsMultipartResolver multipartResolver() {
        return new CommonsMultipartResolver();
    }
    //国际化配置
    @Bean
    public ResourceBundleMessageSource messageSource(){
        ResourceBundleMessageSource messageSource =new ResourceBundleMessageSource();
    public ResourceBundleMessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setBasenames("text/message");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }
    @Bean
    public CookieLocaleResolver localeResolver(){
    public CookieLocaleResolver localeResolver() {
        CookieLocaleResolver localeResolver = new CookieLocaleResolver();
        localeResolver.setCookieName("Language");
        localeResolver.setCookieMaxAge(604800);
@ -156,12 +142,12 @@ public class BeanConfig  implements EnvironmentAware {
    }
    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor(){
    public LocaleChangeInterceptor localeChangeInterceptor() {
        return new LocaleChangeInterceptor();
    }
    @Bean
    public JdbcTemplate jdbcTemplate(){
    public JdbcTemplate jdbcTemplate() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        try {
            jdbcTemplate.setDataSource(this.dataSource);
@ -182,7 +168,7 @@ public class BeanConfig  implements EnvironmentAware {
    }
    @Bean
    public AuditInterceptor auditInterceptor(){
    public AuditInterceptor auditInterceptor() {
        return new AuditInterceptor();
    }

+ 9 - 7
src/main/java/com/yihu/hos/config/MongoConfig.java

@ -1,5 +1,6 @@
package com.yihu.hos.config;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
@ -26,15 +27,16 @@ public class MongoConfig {
    @Value("${spring.data.mongodb.authenticationDatabase}")
    private String authenticationDatabase;
    private static MongoClient mongo;
    @Bean
    public MongoClient mongoClient() throws Exception {
        if(mongo == null) {
            return new MongoClient(singletonList(new ServerAddress(host, port)),
                    singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
        }
        return mongo;
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    @Bean
    public Mongo mongo() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    public String getHost() {

+ 1 - 1
src/main/java/com/yihu/hos/datacollect/service/DatacollectManager.java

@ -247,7 +247,7 @@ public class DatacollectManager{
    @Transactional
    public ActionResult updateJob(RsJobConfig obj, String cron, String jobDataset) throws Exception {
        Integer flowId = flowManage.updateCamelFile(obj.getFlowTempId(), obj.getFlowId(), cron);
        Integer flowId = flowManage.updateCamelFile(obj.getId(),obj.getFlowTempId(), obj.getFlowId(), cron);
        if (flowId!=null){
            datacollectDao.updateEntity(obj);
            saveJobDataset(obj.getId(), jobDataset);

+ 3 - 3
src/main/java/com/yihu/hos/monitor/service/ServiceMonitorService.java

@ -33,7 +33,7 @@ import java.util.Map;
public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    public static final String dbName = "log";
    public static final String tableName = "serviceMetrics";
    public static final String tableName = "service";
    public static final String serviceFlow = "serviceFlow";
    public static final String configuration = "configuration";
@ -75,9 +75,9 @@ public class ServiceMonitorService {
        DBCollection metrics = mongoOperations.getCollection(tableName);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("createTime",
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.GTE, beginTime)),
                        new BasicDBObject().append("createTime",
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.LT, endTime)),
                        new BasicDBObject("name", code),
                        new BasicDBObject("tenant", tenantSession.getTenant())});

+ 97 - 0
src/main/java/com/yihu/hos/remoteManage/controller/RemoteShellController.java

@ -0,0 +1,97 @@
package com.yihu.hos.remoteManage.controller;
import com.yihu.hos.remoteManage.service.RemoteShellService;
import com.yihu.hos.web.framework.util.controller.BaseController;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
 * 远程终端管理--shell操作
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@RequestMapping("/shell")
@Controller
public class RemoteShellController extends BaseController {
    @Resource(name = RemoteShellService.BEAN_ID)
    private RemoteShellService remoteShellService;
    /**
     * 远程shell操作页面
     *
     * @param model
     * @return
     */
    @RequestMapping("/initial")
    public String appInitial(Model model) {
        model.addAttribute("contentPage", "shell/shell");
        return "partView";
    }
    @RequestMapping(value = "/shell", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String shellTest(
            @ApiParam(name = "command", value = "shell命令")
            @RequestParam(value = "command", required = false) String command,
//            @ApiParam(name = "tenant", value = "租户名称")
//            @RequestParam(value = "tenant", required = false) String tenant,
            @ApiParam(name = "disCon", value = "是否断开会话连接")
            @RequestParam(value = "disCon", required = true) boolean disCon) {
        String result = "";
        try {
            //TODO 发送shell命令 消息
            System.out.println("发送shell请求==================");
            remoteShellService.sendShell(command, disCon);
            System.out.println("结果1:" + result);
            //TODO 接收shell命令执行结果 消息
            remoteShellService.start();
            result=remoteShellService.backResult;
            System.out.println("接口返回结果:"+result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
//
//    //连接操作shell测试
//    @RequestMapping(value = "/shell", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//    @ResponseBody
//    public String shellTest(String cmd, String disCon) {
//        String result = "";
//        try {
//            if (session==null){
//                session = sshLinuxTool.getsessionConn();
//            }
//            if ("false".equals(disCon)) {
//                //保持通道连接
//                System.out.println("循环开始1111111==================");
//                result = sshLinuxTool.sshShell(session, cmd, false);
//                System.out.println("结果:"+result);
//            } else {
//                //断开通道连接,会话
//                System.out.println("循环开始2222222222==================");
//                result = sshLinuxTool.sshShell(session, cmd, true);
//                session = null;
//                System.out.println("结果:"+result);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return result;
//    }
}

+ 101 - 0
src/main/java/com/yihu/hos/remoteManage/service/RemoteShellService.java

@ -0,0 +1,101 @@
package com.yihu.hos.remoteManage.service;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.interceptor.LocalContext;
import com.yihu.hos.services.ServiceShellEventService;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.bo.ServiceShell;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.zbus.broker.ZbusBroker;
import org.zbus.mq.Consumer;
import org.zbus.net.http.Message;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Date;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@Service("RemoteShellService")
public class RemoteShellService {
    public static final String BEAN_ID = "RemoteShellService";
    @Value("${hos.zbus.url}")
    private String zbusUrl;
    @Autowired
    private ServiceShellEventService serviceShellEventService;
    private ZbusBroker zbusBroker;
    private Consumer consumer;
    public static String backResult;
    /**
     * 发送shell命令消息
     * @param command
     * @param disConnection
     * @return
     */
    public boolean sendShell(String command,boolean disConnection){
        InetAddress addr = null;
        try {
            addr = InetAddress.getLocalHost();
            String ip = addr.getHostAddress();
            ServiceShell serviceShell = new ServiceShell();
            serviceShell.setCommand(command);
            serviceShell.setFromHost(ip);
            serviceShell.setUpdated(new Date());
            serviceShell.setDisconnect(disConnection);
            serviceShellEventService.serviceShellSend(serviceShell);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    public void proxy(Message message, Consumer consumer) {
        String bodyString = message.getBodyString();
        this.backResult=bodyString;
    }
    public void start() {
        if (zbusBroker == null) {
            System.out.println("zbusBroker is null");
            return;
        }
        String attachment = LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
        if (attachment==null){
            return;
        }
        consumer = new Consumer(zbusBroker, ServiceFlowConstant.SHELL_ADMIN + "@" + attachment);
        try {
            consumer.start(this::proxy);
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }
    @Autowired
    public void setZbusBroker(ZbusBroker zbusBroker) {
        this.zbusBroker = zbusBroker;
    }
    @Override
    protected void finalize() throws Throwable {
        consumer.close();
        super.finalize();
    }
}

+ 66 - 0
src/main/java/com/yihu/hos/services/ServiceShellEventService.java

@ -0,0 +1,66 @@
package com.yihu.hos.services;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.interceptor.LocalContext;
import com.yihu.hos.web.framework.constant.ServiceFlowConstant;
import com.yihu.hos.web.framework.model.bo.ServiceShell;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.jms.Queue;
import java.util.HashMap;
import java.util.Map;
/**
 *  发送shell命令消息到MQ
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/1/5.
 */
@Component
public class ServiceShellEventService {
    static final Logger logger = LoggerFactory.getLogger(ServiceShellEventService.class);
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    @Resource(name = "shellQueue")
    private Queue shellQueue;
    @Autowired
    private ObjectMapper objectMapper;
    public void serviceShellSend(ServiceShell serviceShell) {
        serviceShell.setType(ServiceFlowConstant.ARBITER_SHELL_SEND);
        this.sendMsg(ServiceFlowConstant.ARBITER_SHELL_SEND, serviceShell);
    }
    public void serviceShellAcept(ServiceShell serviceShell) {
        serviceShell.setType(ServiceFlowConstant.ARBITER_SHELL_ACEPT);
        this.sendMsg(ServiceFlowConstant.ARBITER_SHELL_ACEPT, serviceShell);
    }
    private void sendMsg(String event, ServiceShell serviceShell) {
        try {
            Map<String, Object> header = new HashMap<>();
            String attachment = LocalContext.getContext().getAttachment(ContextAttributes.TENANT_NAME);
            serviceShell.setTenant(attachment);
            String msg = objectMapper.writeValueAsString(serviceShell);
            header.put("tenant", attachment);
            header.put("event", event);
            this.jmsMessagingTemplate.convertAndSend(this.shellQueue, msg, header);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
    }
}

+ 9 - 0
src/main/java/com/yihu/hos/system/controller/ProcessController.java

@ -60,6 +60,15 @@ public class ProcessController  extends BaseController {
        }
    }
    @RequestMapping(value = "/getAllProcessor", method = RequestMethod.GET)
    public Result getAllProcessor() {
        try {
            return processManager.getAllProcessor();
        } catch (Exception e) {
            return Result.error("查找所有转换器失败");
        }
    }
    @RequestMapping(value = "/json", method = RequestMethod.POST)
    public Result formatJson(String code, String name, String positionJson, String flowJson) {
        try {

+ 39 - 16
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -524,38 +524,60 @@ public class FlowManager {
     * @throws Exception
     */
    public Integer updateCamelFile(Integer flowTempId, Integer flowId, String newCron) throws Exception {
    public Integer updateCamelFile(String jobId,Integer flowTempId, Integer flowId, String newCron) throws Exception {
         /* 修改route文件无需重新生成flowClass记录,文件名根据className+routeId 生成;*/
        List<SystemServiceFlowTemp> flowTempRouters = flowTempDao.getFlowTemps(flowTempId, ServiceFlowConstant.FLOW_TYPE_ROUTE);
        List<SystemServiceFlowTemp> flowTempProces = flowTempDao.getFlowTemps(flowTempId, ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
        SystemServiceFlow flow = flowDao.getEntity(SystemServiceFlow.class, flowId);
        //route模板文件记录是否存在。不存在就返回。
        if (!flowTempRouters.isEmpty()) {
            SystemServiceFlowTemp flowTemp = flowTempRouters.get(0);
            StringBuilder basePath = new StringBuilder();
            ;
            if (flowTemp.getPackageName() != null) {
                String packagePath[] = flowTemp.getPackageName().split("\\.");
                for (int i = 0; i < packagePath.length; i++) {
                    basePath.append(packagePath[i]).append("/");
            ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
            ServiceFlow serviceFlow = new ServiceFlow();
            //新增processor记录
            for (SystemServiceFlowTemp process : flowTempProces) {
                String deName = DES.decrypt(process.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
                String newFileName = genProcessorJavaFile(jobId, flow.getCode(), deName, process.getClassName());
                //生成新的java文件
                String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
                if (newFileName != null) {
                    //发送消息
                    serviceFlow.setRouteCode(flow.getCode());
                    serviceFlow.setFlowType(ServiceFlowConstant.CLASS);
                    ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
                    handleFile.setRouteCode(flow.getCode());
                    handleFile.setFileType(ServiceFlowConstant.JAVA);
                    handleFile.setPackageName(process.getPackageName());
                    handleFile.setClassName(process.getClassName());
                    handleFile.setFilePath(enNewFileName);
                    handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                    handleFiles.add(handleFile);
                    serviceFlow.setHandleFiles(handleFiles);
                } else {
                    System.out.println("生成processor的java文件过程出错");
                    return null;
                }
            }
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            //生成新的route文件
            String newFileName = genRouteJavaFile(flow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
            ServiceFlow serviceFlow = new ServiceFlow();
            serviceFlow.setRouteCode(flow.getCode());
            serviceFlow.setFlowType(ServiceFlowConstant.JAVA);
            ServiceFlow.HandleFile handleFile = new ServiceFlow.HandleFile();
            handleFile.setRouteCode(flow.getCode());
            handleFile.setFileType(ServiceFlowConstant.JAVA);
            handleFile.setPackageName(basePath.toString());
            handleFile.setPackageName(flowTemp.getPackageName());
            handleFile.setClassName(flowTemp.getClassName() + flow.getCode());
            handleFile.setFilePath(enNewFileName);
            handleFile.setUsage(ServiceFlowConstant.FLOW_TYPE_ROUTE);
            ArrayList<ServiceFlow.HandleFile> handleFiles = new ArrayList<>();
            handleFiles.add(handleFile);
            serviceFlow.setHandleFiles(handleFiles);
            serviceFlowEventService.serviceFlowModifiedAdd(serviceFlow);
@ -583,7 +605,9 @@ public class FlowManager {
            //新增processor记录
            String deName = DES.decrypt(flowTemp.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
            String enClassName = DES.encrypt(deName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
            String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enClassName = DES.encrypt(newFileName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
            SystemServiceFlowClass newFlowClass = new SystemServiceFlowClass();
            newFlowClass.setPackageName(flowTemp.getPackageName());
            newFlowClass.setClassName(flowTemp.getClassName() + newFlow.getCode());
@ -593,8 +617,7 @@ public class FlowManager {
            flowClassDao.saveEntity(newFlowClass);
            newFlowClass.setIsUpdate("1");
            //生成新的route文件
            String newFileName = genRouteJavaFile(newFlow.getCode(), flowTemp.getClassName(), deName, newCron);
            String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
            String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);//加密文件名
            if (newFileName != null) {
                ServiceFlow serviceFlow = new ServiceFlow();
@ -653,8 +676,9 @@ public class FlowManager {
                }
                String deName = DES.decrypt(process.getClassPath(), DES.COMMON_PASSWORD);//吉阿米果的文件名
                String enClassName = DES.encrypt(deName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
                String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, process.getClassName());
                String enClassName = DES.encrypt(newFileName.replace(".java", ".class"), DES.COMMON_PASSWORD);//生成机密过的classPath
                SystemServiceFlowClass processClass = new SystemServiceFlowClass();
                processClass.setPackageName(process.getPackageName());
                processClass.setClassName(process.getClassName());
@ -663,7 +687,6 @@ public class FlowManager {
                processClass.setType(ServiceFlowConstant.FLOW_TYPE_PROCESSOR);
                processClass.setIsUpdate("1");
                //生成新的java文件
                String newFileName = genProcessorJavaFile(jobId, newFlow.getCode(), deName, processClass.getClassName());
                String enNewFileName = DES.encrypt(newFileName, DES.COMMON_PASSWORD);
                if (newFileName != null) {

+ 105 - 74
src/main/java/com/yihu/hos/system/service/ProcessManager.java

@ -2,14 +2,20 @@ package com.yihu.hos.system.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.graph.BFSGraph;
import com.yihu.hos.common.graph.DGraph;
import com.yihu.hos.common.graph.Edge;
import com.yihu.hos.config.MongoConfig;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.encrypt.DES;
import com.yihu.hos.system.dao.AppDao;
import com.yihu.hos.system.dao.AppServiceDao;
import com.yihu.hos.system.dao.FlowProcessDao;
import com.yihu.hos.system.dao.ProcessorDao;
import com.yihu.hos.system.model.SystemApp;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.model.SystemServiceFlowProcess;
import com.yihu.hos.system.model.SystemServiceFlowProcessor;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.GridFSUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +24,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
@Service("ProcessManager")
@ -29,15 +36,17 @@ public class ProcessManager {
    private AppDao appDao;
    @Resource(name = AppServiceDao.BEAN_ID)
    private AppServiceDao appServiceDao;
    @Resource(name = ProcessorDao.BEAN_ID)
    private ProcessorDao processorDao;
    @Resource(name = FlowProcessDao.BEAN_ID)
    private FlowProcessDao processDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    public Result getAllApp() throws Exception {
        String hql = "select * from SystemServiceEndpoint";
        List<SystemServiceEndpoint> serviceEndpointList = appServiceDao.getEntityList(SystemServiceEndpoint.class, hql);
        String result = objectMapper.writeValueAsString(serviceEndpointList);
        String hql = "select * from SystemApp";
        List<SystemApp> appList = appDao.getEntityList(SystemApp.class, hql);
        String result = objectMapper.writeValueAsString(appList);
        return Result.success(result);
    }
@ -55,6 +64,13 @@ public class ProcessManager {
        return Result.success(result);
    }
    public Result getAllProcessor() throws Exception {
        String hql = "select * from SystemServiceFlowProcessor";
        List<SystemServiceFlowProcessor> processorList = processorDao.getEntityList(SystemServiceFlowProcessor.class, hql);
        String result = objectMapper.writeValueAsString(processorList);
        return Result.success(result);
    }
    public void saveProcess(String code, String name, String fileName, String positionJsonStr) throws Exception {
        SystemServiceFlowProcess process = new SystemServiceFlowProcess();
        process.setCode(code);
@ -95,70 +111,61 @@ public class ProcessManager {
                "        }\n" +
                "    }\n" +
                "}";
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode flowJson = objectMapper.readValue(flowJsonStr, JsonNode.class);
        String code = flowJson.get("code").asText();
        String javaName = toUpperCaseFirstOne(code)+"Route";
        //sort flow by lines
        JsonNode lines = flowJson.get("lines");
        Iterator<JsonNode> lineIterator = lines.iterator();
        String[] nodeNameArray = new String[lines.size() + 1];
        Boolean isFirstLineFlg = true;
        while (lineIterator.hasNext()) {
            JsonNode line = lineIterator.next();
            String nodeNameFrom = line.get("from").asText();
            String nodeNameTo = line.get("to").asText();
            if (isFirstLineFlg) {
                nodeNameArray[0] = nodeNameFrom;
                nodeNameArray[1] = nodeNameTo;
                isFirstLineFlg = false;
                continue;
            }
            for (int i=0; i<nodeNameArray.length; i++) {
                if (nodeNameArray[i].equals(nodeNameFrom)) {
                    if (StringUtil.isEmpty(nodeNameArray[i + 1])) {
                        nodeNameArray[i + 1] = nodeNameTo;
                    } else {
                        insertArray(nodeNameTo, nodeNameArray, i + 1);
                    }
                    break;
                } else if (nodeNameArray[i].equals(nodeNameTo)) {
                    insertArray(nodeNameFrom, nodeNameArray, i);
                }
            }
        }
        JsonNode lines = flowJson.get("lines");
        Iterator<Map.Entry<String, JsonNode>> lineIterator = lines.fields();
        //get nodeMap by nodes
        JsonNode nodes = flowJson.get("nodes");
        Map<String, JsonNode> nodeMap = new HashMap<>();
        Iterator<Map.Entry<String, JsonNode>> nodeIterator = nodes.fields();
        //for the java code import processor class
        List<String> processorImport = new ArrayList<>();
        Map<String, JsonNode> nodeMap = new HashMap<>();
        Map<String, JsonNode> lineMap = new HashMap<>();
        DGraph<String> mDG = new BFSGraph<String>();
        while (nodeIterator.hasNext()) {
            Map.Entry<String, JsonNode> map = nodeIterator.next();
            JsonNode node = map.getValue();
            String type = node.get("type").asText();
            if (type.equals("processor")) {
                processorImport.add(node.get("value").asText());
            }
            nodeMap.put(map.getKey(), map.getValue());
            mDG.add(map.getKey());
        }
        while (lineIterator.hasNext()) {
            Map.Entry<String, JsonNode> map = lineIterator.next();
            lineMap.put(map.getKey(), map.getValue());
            String nodeNameFrom = map.getValue().get("from").asText();
            String nodeNameTo = map.getValue().get("to").asText();
            mDG.add(new Edge<String>(nodeNameFrom, nodeNameTo, map.getKey()));
        }
        //mosaic the java code
        //generate the java code
        return generate(code, lineMap, nodeMap, mDG);
    }
    public String generate(String code, Map<String, JsonNode> lineMap, Map<String, JsonNode> nodeMap, DGraph<String> mDG) throws IOException {
        Boolean isFirstNodeFlg = true;
        StringBuilder javaBuilder = new StringBuilder();
        String javaName = toUpperCaseFirstOne(code)+"Route";
        javaBuilder.append("package "+code+".route;\n\n");
        javaBuilder.append("import org.apache.camel.Exchange;\n");
        javaBuilder.append("import org.apache.camel.builder.RouteBuilder;\n");
        for (String packageName : processorImport) {
            javaBuilder.append("import " + packageName + ";\n");
        for (String key : nodeMap.keySet()) {
            JsonNode node = nodeMap.get(key);
            String type = node.get("type").asText();
            if (type.equals("processor")) {
                javaBuilder.append("import " + node.get("value").asText() + ";\n");
            }
        }
        javaBuilder.append("public class "+javaName+" extends RouteBuilder {\n");
        javaBuilder.append("public void configure() throws Exception {\n");
        for (String nodeName : nodeNameArray) {
        Iterator<String> it = mDG.iterator("1");
        while(it.hasNext()) {
            String nodeName = it.next();
            JsonNode node = nodeMap.get(nodeName);
            String type = node.get("type").asText();
            String value = node.get("value").asText();
@ -171,6 +178,8 @@ public class ProcessManager {
            } else {
                if (type.equals("processor")) {
                    javaBuilder.append("\n.process(\"new "+name+"())");
                } else if (type.equals("judgement")) {
                    judgement(javaBuilder, value, nodeName, mDG, it, lineMap, nodeMap);
                } else {
                    javaBuilder.append("\n.setHeader(Exchange.HTTP_METHOD, constant(\"POST\"))");
                    javaBuilder.append("\n.to(\"");
@ -178,48 +187,70 @@ public class ProcessManager {
                }
            }
        }
        javaBuilder.append("\n}\n}");
        System.out.println(javaBuilder.toString());
        String packageFilePath = System.getProperty("user.dir");
        String filePath = packageFilePath + "/" + javaName + ".java";
        File file = new File(filePath);
        FileWriter fw = new FileWriter(file);
        fw.write(javaBuilder.toString());
        fw.flush();
        fw.close();//这里只是产生一个JAVA文件,简单的IO操作
        //upload to mongo
        String dbName = "upload";
        String newFileName;
        try {
            newFileName = GridFSUtil.uploadFile(filePath, file.getName(), null);
            if (!StringUtil.isEmpty(newFileName)) {
                return newFileName;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
//        String packageFilePath = System.getProperty("user.dir");
//
//        String filePath = packageFilePath + "/" + javaName + ".java";
//        File file = new File(filePath);
//
//        FileWriter fw = new FileWriter(file);
//        fw.write(javaBuilder.toString());
//        fw.flush();
//        fw.close();//这里只是产生一个JAVA文件,简单的IO操作
//
//        //upload to mongo
//        String newFileName;
//        try {
//            newFileName = GridFSUtil.uploadFile(filePath, file.getName(), null);
//            if (!StringUtil.isEmpty(newFileName)) {
//                return newFileName;
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        return "";
    }
    public void insertArray(String nodeName, String[] array, int index) {
        for (int i=index; i<array.length; i++) {
            String nodeNameTemp = array[i];
            array[i] = nodeName;
            nodeName = nodeNameTemp;
        }
    }
    //首字母转大写
    public String toUpperCaseFirstOne(String s)
    {
    public String toUpperCaseFirstOne(String s) {
        if(Character.isUpperCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
    }
    public void judgement(StringBuilder javaBuilder, String value, String nodeName, DGraph<String> mDG, Iterator<String> it,  Map<String, JsonNode> lineMap, Map<String, JsonNode> nodeMap) {
        javaBuilder.append("\n.when("+value+")");
        List<Edge<String>> edgeList = mDG.getEdgeList(nodeName);
        String trueNodeName = "";
        String falseNodeName = "";
        for (Edge<String> edge : edgeList) {
            String nextNodeName = edge.getDest();
            String nextLineName = edge.getName();
            JsonNode nextLine = lineMap.get(nextLineName);
            if (nextLine.get("value").asText().equals("right")) {
                trueNodeName = nextNodeName;
            } else {
                falseNodeName = nextNodeName;
            }
        }
        JsonNode node1 = nodeMap.get(trueNodeName);
        JsonNode node2 = nodeMap.get(falseNodeName);
        String firstValue = node1.get("value").asText();
        String secondValue =  node2.get("value").asText();
        javaBuilder.append("\n.setHeader(Exchange.HTTP_METHOD, constant(\"POST\"))");
        javaBuilder.append("\n.to(\"");
        javaBuilder.append(firstValue + "\")");
        javaBuilder.append(".otherwise()");
        javaBuilder.append("\n.setHeader(Exchange.HTTP_METHOD, constant(\"POST\"))");
        javaBuilder.append("\n.to(\"");
        javaBuilder.append(secondValue + "\")");
        it.next();
        it.next();
    }
}

+ 27 - 12
src/main/resources/application.yml

@ -56,33 +56,48 @@ spring:
    pooled: false
  aop:
    proxy-target-class: true
hos:
  zbus:
    url: 192.168.131.119:15555
---
spring:
  profiles: test
  #SAAS管理员账号,暂时配置在此处
  administrators: jkzl
  datasource:
      driverClassName: com.mysql.jdbc.Driver
      url: jdbc:mysql://192.168.1.220:8066/global_db?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
      username: hos
      password: 123456
      test-on-borrow: true
      validation-query: SELECT 1
      test-while-idle: true
      max-total: 100
      default-auto-commit: true
      max-idle: 50
      min-idle: 20
      initial-size: 10
  jpa:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      dialect: org.hibernate.dialect.MySQL5Dialect
    format-sql: true
    show-sql: false
  data:
    mongodb:
      host: 172.19.103.86
      host: 172.19.103.57
      port: 27017
      username: esb
      password: esb
      authenticationDatabase: admin
      gridFsDatabase: dfs
  activemq:
    broker-url: tcp://172.19.103.86:61616?wireFormat.maxInactivityDuration=0
    broker-url: tcp://172.19.103.57:61616?wireFormat.maxInactivityDuration=0
    user: admin
    password: admin
    pooled: false
#  data:
#    mongodb:
#      host: 172.19.103.86
#      port: 27017
#      username: esb
#      password: esb
#      authenticationDatabase: admin
#      database: configuration
  aop:
    proxy-target-class: true
---
spring:
  #SAAS管理员账号,暂时配置在此处

+ 0 - 1
src/main/webapp/WEB-INF/ehr/jsp/system/process/processJs.jsp

@ -2,7 +2,6 @@
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<link rel="stylesheet" type="text/css" href="${contextRoot}/develop/lib/gooflow/goo/codebase/GooFlow2.css"/>
<link rel="stylesheet" type="text/css" href="${contextRoot}/develop/lib/gooflow/default.css"/>
<script type="text/javascript" src="${contextRoot}/develop/lib/gooflow/jquery.min.js"></script>
<script type="text/javascript" src="${contextRoot}/develop/lib/gooflow/goo/data.js"></script>
<script type="text/javascript" src="${contextRoot}/develop/lib/gooflow/GooFunc.js"></script>
<script type="text/javascript" src="${contextRoot}/develop/lib/gooflow/json2.js"></script>