浏览代码

bug修复

zhenglingfeng 8 年之前
父节点
当前提交
b60052bda4

+ 6 - 2
hos-broker/src/main/java/com/yihu/hos/common/appender/JMSAppender.java

@ -319,9 +319,13 @@ public class JMSAppender extends AppenderSkeleton {
      String routeId = StringUtil.toString(event.getMDC("camel.routeId"));
      if (message.contains("("+routeId+") log[servers:")) {
        String body = message.substring(message.indexOf("Body:") + 5);
        String code = "";
        String order = "0";
        String totalServers = message.substring(message.indexOf("log[servers:") + 13, message.indexOf(","));
        String code = message.substring(message.indexOf("code") + 6, message.indexOf(",order"));
        String order = message.substring(message.indexOf("order") + 7, message.indexOf("]"));
        if (!totalServers.equals("0")) {
           code = message.substring(message.indexOf("code") + 6, message.indexOf(",order"));
           order = message.substring(message.indexOf("order") + 7, message.indexOf("]"));
        }
        Map<String, Object> map = new HashMap<>();
        map.put("exchangeId", StringUtil.toString(event.getMDC("camel.exchangeId")));
        map.put("correlationId", StringUtil.toString(event.getMDC("camel.correlationId")));

+ 11 - 10
hos-broker/src/main/java/com/yihu/hos/common/listener/ApplicationStartListener.java

@ -44,6 +44,8 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
        BrokerDao brokerDao = (BrokerDao) contextRefreshedEvent.getApplicationContext().getBean(BrokerDao.BEAN_ID);
        List<SystemServiceFlow> systemServiceFlowList = brokerDao.getSystemServiceFlowList();
        List<SystemServiceFlowClass> systemServiceFlowClassList = brokerDao.getSystemServiceFlowClassList();
        File systemClassPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath());
        List<File> systemClassFlowPathList = new ArrayList<>();
        //对所有route与processor进行分类存储
        Map<String, List<SystemServiceFlowClass>> systemServiceFlowClassGroupMap = new HashMap<>();
        for (SystemServiceFlowClass systemServiceFlowClass : systemServiceFlowClassList) {
@ -60,7 +62,6 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
            }
        }
        List<File> systemClassFlowPaths = new ArrayList<>();
        List<RouteBuilder> alreadyRouteBuilders = new ArrayList<>();
        Map<String, Boolean> isCorrectClassMap = new HashMap<>();
        for (SystemServiceFlow systemServiceFlow : systemServiceFlowList) {
@ -68,7 +69,6 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
            String code = systemServiceFlow.getCode();
            //默认所有class均为正确
            // 这是system业务系统在本地存储class的根目录
            File systemClassFlowPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath());
            List<SystemServiceFlowClass> processesClassList = systemServiceFlowClassGroupMap.get("processor" + flowId);
            List<SystemServiceFlowClass> routesClassList = systemServiceFlowClassGroupMap.get("route" + flowId);
            // 创建processor文件
@ -79,10 +79,10 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    String packageName = processesClass.getPackageName();
                    String classPath = processesClass.getClassPath();
                    // 创建文件
                    Boolean flag = ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    Boolean flag = ClassFileUtil.createClassfile(systemClassPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR+className, packageName + CoreConstant.DOT + className);
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.PROCESSOR + className, packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
@ -95,17 +95,17 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                    String packageName = routesClass.getPackageName();
                    String classPath = routesClass.getClassPath();
                    // 创建文件
                    Boolean flag =ClassFileUtil.createClassfile(systemClassFlowPath.toURI().toURL(), packageName, className, classPath);
                    Boolean flag =ClassFileUtil.createClassfile(systemClassPath.toURI().toURL(), packageName, className, classPath);
                    // 记录到工具类中,以便其它线程需要时进行取用
                    if (flag) {
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE+className, packageName + CoreConstant.DOT + className);
                        SystemClassMapping.getSystemClassNameMapping().put(code + BrokerConstant.ROUTE + className, packageName + CoreConstant.DOT + className);
                    } else {
                        isCorrectClassMap.put(code, flag);
                    }
                    if (isCorrectClassMap.get(code)) {
                        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
                        try {
                            Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) currentClassLoader.loadClass(SystemClassMapping.getSystemClassNameMapping().get(code + BrokerConstant.ROUTE+className));
                            Class<RouteBuilder> routeBuilderClass = (Class<RouteBuilder>) currentClassLoader.loadClass(SystemClassMapping.getSystemClassNameMapping().get(code + BrokerConstant.ROUTE + className));
                            if (routeBuilderClass != null) {
                                RouteBuilder routeBuilder = routeBuilderClass.newInstance();
                                alreadyRouteBuilders.add(routeBuilder);
@ -120,8 +120,9 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
                isCorrectClassMap.put(code, false);
            }
            if (isCorrectClassMap.get(code)) {
                if (!systemClassFlowPaths.contains(systemClassFlowPath)) {
                    systemClassFlowPaths.add(systemClassFlowPath);
                File systemClassFlowPath = new File(systemClassPath.getPath() + "/" + code);
                if (!systemClassFlowPathList.contains(systemClassFlowPath)) {
                    systemClassFlowPathList.add(systemClassFlowPath);
                }
            }
        }
@ -130,7 +131,7 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
        logger.info("Apache Camel Context 启动完成......");
        // 加载和设置ClassLoader
        List<URL> URLs = new ArrayList<>();
        for (File systemClassFlowPath : systemClassFlowPaths) {
        for (File systemClassFlowPath : systemClassFlowPathList) {
            URLs.add(systemClassFlowPath.toURI().toURL());
        }
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();

+ 27 - 29
hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java

@ -104,13 +104,12 @@ public class ServiceMonitorService {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                if (bandwidthMapF.containsKey(code)) {
                    Integer flowCalls = bandwidthMapF.get(code);
                    bandwidthMapF.put(code, ++flowCalls);
                } else {
                    bandwidthMapF.put(code, 1);
                }
            Integer bodyLength = Integer.parseInt(StringUtil.toString(dbObject.get("bodyLength")));
            if (bandwidthMapF.containsKey(code)) {
                bodyLength = bodyLength + bandwidthMapF.get(code);
                bandwidthMapF.put(code, bodyLength);
            } else {
                bandwidthMapF.put(code, bodyLength);
            }
        }
       //服务带宽
@ -120,11 +119,12 @@ public class ServiceMonitorService {
        for (DBObject dbObject : serviceOutput.results()) {
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("code"));
            Integer bodyLength = Integer.parseInt(StringUtil.toString(dbObject.get("bodyLength")));
            if (bandwidthMapS.containsKey(code)) {
                Integer serviceCalls = bandwidthMapS.get(code);
                bandwidthMapS.put(code, ++serviceCalls);
                bodyLength = bodyLength + bandwidthMapS.get(code);
                bandwidthMapS.put(code, bodyLength);
            } else {
                bandwidthMapS.put(code, 1);
                bandwidthMapS.put(code, bodyLength);
            }
        }
@ -156,15 +156,13 @@ public class ServiceMonitorService {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
                if (total == count/2) {
                    if (qpsMapF.containsKey(code)) {
                        Integer flowCalls = qpsMapF.get(code);
                        qpsMapF.put(code, ++flowCalls);
                    } else {
                        qpsMapF.put(code, 1);
                    }
            Integer total = Integer.parseInt(StringUtil.toString(dbObject.get("total")));
            if (total == count/2) {
                if (qpsMapF.containsKey(code)) {
                    Integer flowCalls = qpsMapF.get(code);
                    qpsMapF.put(code, ++flowCalls);
                } else {
                    qpsMapF.put(code, 1);
                }
            }
        }
@ -298,16 +296,14 @@ public class ServiceMonitorService {
            Integer count = Integer.parseInt(StringUtil.toString(dbObject.get("count")));
            BasicDBObject id = (BasicDBObject) dbObject.get("_id");
            String code = StringUtil.toString(id.get("routeId"));
            if (count >= 2) {
                String begin = StringUtil.toString(dbObject.get("beginTime"));
                String end = StringUtil.toString(dbObject.get("endTime"));
                long interval = getIntervalExact(begin, end);
                if (delayMapF.containsKey(code)) {
                    BigDecimal flowDelay = delayMapF.get(code);
                    delayMapF.put(code, BigDecimal.valueOf(interval).add(flowDelay));
                } else {
                    delayMapF.put(code, BigDecimal.valueOf(interval));
                }
            String begin = StringUtil.toString(dbObject.get("beginTime"));
            String end = StringUtil.toString(dbObject.get("endTime"));
            long interval = getIntervalExact(begin, end);
            if (delayMapF.containsKey(code)) {
                BigDecimal flowDelay = delayMapF.get(code);
                delayMapF.put(code, BigDecimal.valueOf(interval).add(flowDelay));
            } else {
                delayMapF.put(code, BigDecimal.valueOf(interval));
            }
        }
@ -366,6 +362,7 @@ public class ServiceMonitorService {
                new BasicDBObject("id", "$_id")
                        .append("code", "$code"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("bodyLength", new BasicDBObject( "$sum", "$bodyLength"));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        return new BasicDBObject("$group", groupFields);
    }
@ -377,6 +374,7 @@ public class ServiceMonitorService {
                new BasicDBObject("breadcrumbId", "$breadcrumbId")
                        .append("routeId", "$routeId"));
        groupFields.put("count", new BasicDBObject( "$sum", 1));
        groupFields.put("bodyLength", new BasicDBObject( "$sum", "$bodyLength"));
        groupFields.put("total", new BasicDBObject( "$first", "$totalServers"));
        groupFields.put("beginTime", new BasicDBObject( "$first", "$fireTimeSource"));
        groupFields.put("endTime", new BasicDBObject("$last", "$fireTimeSource"));

+ 0 - 22
hos-camel/src/main/java/api3/processor/ApiProcessor.java

@ -17,26 +17,4 @@ public class ApiProcessor implements Processor {
        Message outMessage = exchange.getOut();
        outMessage.setBody("hello,api3");
    }
    /**
     * 从stream中分析字符串内容
     *
     * @param bodyStream
     * @return
     */
    private String analysisMessage(InputStream bodyStream) throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] contextBytes = new byte[4096];
        int realLen;
        while ((realLen = bodyStream.read(contextBytes, 0, 4096)) != -1) {
            outStream.write(contextBytes, 0, realLen);
        }
        // 返回从Stream中读取的字串
        try {
            return new String(outStream.toByteArray(), "UTF-8");
        } finally {
            outStream.close();
        }
    }
}

+ 2 - 2
hos-camel/src/main/java/api3/route/ApiRouteBulider.java

@ -10,7 +10,7 @@ import org.apache.camel.builder.RouteBuilder;
public class ApiRouteBulider extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("jetty:http://localhost:9093/api/v1").routeId("api3")
                .process(new ApiProcessor());
        from("jetty:http://localhost:9093/api/v1").routeId("api3").log("servers: 0,code: ,order: 0")
                .process(new ApiProcessor()).log("servers: 0,code: ,order: 0");
    }
}

+ 20 - 0
src/main/webapp/WEB-INF/ehr/jsp/monitor/service/sEnvManageJs.jsp

@ -136,6 +136,11 @@
                     tooltip: {
                         trigger: 'axis'
                     },
                     dataZoom : {
                         show : true,
                         start : 50,
                         end : 100
                     },
                     legend: {
                         left: 'left',
                         data: ['带宽']
@ -191,6 +196,11 @@
                    tooltip: {
                        trigger: 'axis'
                    },
                    dataZoom : {
                        show : true,
                        start : 50,
                        end : 100
                    },
                    legend: {
                        left: 'left',
                        data: ['吞吐量']
@ -246,6 +256,11 @@
                    tooltip: {
                        trigger: 'axis'
                    },
                    dataZoom : {
                        show : true,
                        start : 50,
                        end : 100
                    },
                    legend: {
                        left: 'left',
                        data: ['延时']
@ -307,6 +322,11 @@
                    tooltip: {
                        trigger: 'axis'
                    },
                    dataZoom : {
                        show : true,
                        start : 50,
                        end : 100
                    },
                    legend: {
                        left: 'left',
                        data: ['总使用数', '成功数', '失败数']

+ 3 - 3
src/main/webapp/WEB-INF/ehr/jsp/system/flow/editorFlow.jsp

@ -15,7 +15,7 @@
            </div>
        </div>
        <div class="m-form-group">
            <label><span class="red">*&nbsp;</span>流程Code:</label>
            <label><span class="red">*&nbsp;</span>路由唯一标识:</label>
            <div class="m-form-control ">
                <div class="l-text">
@ -98,7 +98,7 @@
        </div>
        <div class="m-form-group">
            <label>类别:</label>
            <label>文件类别:</label>
            <div class="m-form-control ">
                <div class="l-text">
                    <input type="text" id="fileType"   class="l-text-field required" name="fileType">
@ -143,6 +143,6 @@
    .wrapper{position:absolute;z-index:1;top:0;bottom:48px;left:0;width:100%;overflow:hidden;}
    .content{height:100%;padding-top:10px;position:absolute;z-index:1;width:100%;overflow-x:hidden;}
    .m-form-bottom{position:absolute;z-index:2;bottom:0;left:0;width:100%;background:#f5f8fa;padding:0; height: auto;}
    .flows{    border: 1px solid deepskyblue;margin-bottom: 10px;width: 550px;}
    .flows{border: 2px solid #c4e1ff;margin-bottom: 10px;width: 550px;}
    .btnIconGrayUp.required{border: #FF7777 1px solid; float: left;}
</style>