Browse Source

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

demon 8 năm trước cách đây
mục cha
commit
b3de84240d

+ 16 - 10
hos-broker/src/main/java/com/yihu/hos/services/ServiceMonitorService.java

@ -8,7 +8,6 @@ import com.yihu.hos.core.datatype.NumberUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.models.BusinessLog;
import com.yihu.hos.models.ServiceMetrics;
import com.yihu.hos.web.framework.model.Result;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
@ -25,10 +24,7 @@ public class ServiceMonitorService {
    public static final String BEAN_ID = "ServiceMonitorService";
    @Autowired
    private MongoOperations mongoOperations;
    private DBCollection businessLog = mongoOperations.getCollection(mongoOperations
            .getCollectionName(BusinessLog.class));
    private DBCollection businessLog;
//    public Result mapReduce(String beginTime, String endTime) {
//        DBCollection businessLogDB = mongoOperations.getCollection(mongoOperations
//                .getCollectionName(BusinessLog.class));
@ -85,15 +81,25 @@ public class ServiceMonitorService {
//        return jsonObject;
//    }
    public DBCollection getBusinessLog() {
        if (businessLog == null) {
            businessLog = mongoOperations.getCollection(mongoOperations
                    .getCollectionName(BusinessLog.class));
        }
        return businessLog;
    }
    public void bandwidth(String beginTime, String endTime) {
        DBObject match = getMatchFields(beginTime, endTime);
        DBObject flowGroup = getFlowGroupFields();
        DBObject sort = getSortFields();
        DBObject serviceGroup = getServiceGroupFields();
        // run aggregation
        AggregationOutput flowOutput = businessLog.aggregate(match, flowGroup, sort);
        AggregationOutput flowOutput = getBusinessLog().aggregate(match, flowGroup, sort);
        // run aggregation
        AggregationOutput serviceOutput = businessLog.aggregate(match, serviceGroup, sort);
        AggregationOutput serviceOutput = getBusinessLog().aggregate(match, serviceGroup, sort);
        Integer calls = 0;
        String routeId = "";
@ -127,7 +133,7 @@ public class ServiceMonitorService {
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer calls = 0;
        String routeId = "";
        for (DBObject dbObject : output.results()) {
@ -151,7 +157,7 @@ public class ServiceMonitorService {
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer successCount = 0;
        Integer failureCount = 0;
        String routeId = "";
@ -180,7 +186,7 @@ public class ServiceMonitorService {
        DBObject group = getFlowGroupFields();
        DBObject sort = getSortFields();
        // run aggregation
        AggregationOutput output = businessLog.aggregate(match, group, sort);
        AggregationOutput output = getBusinessLog().aggregate(match, group, sort);
        Integer calls = 0;
        String routeId = "";
        for (DBObject dbObject : output.results()) {