Merge pull request #844 from peng-yongsheng/feature/getApplicationTopology
"getApplicationTopology" Refactor topology build logic.
This commit is contained in:
commit
e138b8d5fc
|
|
@ -27,7 +27,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
|||
*/
|
||||
public interface IApplicationComponentUIDAO extends DAO {
|
||||
|
||||
List<ApplicationComponent> load(Step step, long startTime, long endTime);
|
||||
List<ApplicationComponent> load(Step step, long startTimeBucket, long endTimeBucket);
|
||||
|
||||
class ApplicationComponent {
|
||||
private int componentId;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationMappingUIDAO extends DAO {
|
||||
List<ApplicationMapping> load(Step step, long startTime, long endTime);
|
||||
List<ApplicationMapping> load(Step step, long startTimeBucket, long endTimeBucket);
|
||||
|
||||
class ApplicationMapping {
|
||||
private int applicationId;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,9 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationReferenceMetricUIDAO extends DAO {
|
||||
List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
|
||||
List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
|
||||
List<ApplicationReferenceMetric> getReferences(Step step, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
List<ApplicationReferenceMetric> getReferences(Step step, long startTimeBucket, long endTimeBucket,
|
||||
MetricSource metricSource, Integer... applicationIds);
|
||||
|
||||
class ApplicationReferenceMetric {
|
||||
private int source;
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationCo
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationComponent> load(Step step, long startTime, long endTime) {
|
||||
logger.debug("application component load, start time: {}, end time: {}", startTime, endTime);
|
||||
@Override public List<ApplicationComponent> load(Step step, long startTimeBucket, long endTimeBucket) {
|
||||
logger.debug("application component load, start time: {}, end time: {}", startTimeBucket, endTimeBucket);
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE);
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
searchRequestBuilder.setTypes(ApplicationComponentTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
searchRequestBuilder.addAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_COMPONENT_ID).field(ApplicationComponentTable.COLUMN_COMPONENT_ID).size(100)
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationMapping> load(Step step, long startTime, long endTime) {
|
||||
@Override public List<ApplicationMapping> load(Step step, long startTimeBucket, long endTimeBucket) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
searchRequestBuilder.setTypes(ApplicationMappingTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
searchRequestBuilder.addAggregation(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.CollectionUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
|
|
@ -46,9 +47,8 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
@Override public List<ApplicationReferenceMetric> getReferences(Step step, long startTimeBucket, long endTimeBucket,
|
||||
MetricSource metricSource, Integer... applicationIds) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
|
|
@ -56,48 +56,20 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, applicationId));
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue()));
|
||||
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
if (CollectionUtils.isNotEmpty(applicationIds)) {
|
||||
BoolQueryBuilder applicationBoolQuery = QueryBuilders.boolQuery();
|
||||
int[] ids = new int[applicationIds.length];
|
||||
for (int i = 0; i < applicationIds.length; i++) {
|
||||
ids[i] = applicationIds[i];
|
||||
}
|
||||
|
||||
return buildMetrics(searchRequestBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, applicationId));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue()));
|
||||
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
return buildMetrics(searchRequestBuilder);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationReferenceMetric> getReferences(Step step, long startTime, long endTime,
|
||||
MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue()));
|
||||
applicationBoolQuery.should().add(QueryBuilders.termsQuery(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ids));
|
||||
applicationBoolQuery.should().add(QueryBuilders.termsQuery(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, ids));
|
||||
boolQuery.must().add(applicationBoolQuery);
|
||||
}
|
||||
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationComponent> load(Step step, long startTime, long endTime) {
|
||||
@Override public List<ApplicationComponent> load(Step step, long startTimeBucket, long endTimeBucket) {
|
||||
H2Client client = getClient();
|
||||
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE);
|
||||
|
|
@ -54,7 +54,7 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo
|
|||
String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID,
|
||||
tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET);
|
||||
|
||||
Object[] params = new Object[] {startTime, endTime};
|
||||
Object[] params = new Object[] {startTimeBucket, endTimeBucket};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
while (rs.next()) {
|
||||
int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationMapping> load(Step step, long startTime, long endTime) {
|
||||
@Override public List<ApplicationMapping> load(Step step, long startTimeBucket, long endTimeBucket) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE);
|
||||
|
||||
H2Client client = getClient();
|
||||
|
|
@ -53,7 +53,7 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp
|
|||
ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, tableName, ApplicationMappingTable.COLUMN_TIME_BUCKET);
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new LinkedList<>();
|
||||
Object[] params = new Object[] {startTime, endTime};
|
||||
Object[] params = new Object[] {startTimeBucket, endTimeBucket};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
while (rs.next()) {
|
||||
int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
|
||||
|
|
@ -41,49 +40,8 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
H2Client client = getClient();
|
||||
JsonArray applicationReferenceMetricArray = new JsonArray();
|
||||
// String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
|
||||
// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE,
|
||||
// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY,
|
||||
// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET,
|
||||
// ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
|
||||
//
|
||||
// Object[] params = new Object[] {startTime, endTime};
|
||||
// try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
// while (rs.next()) {
|
||||
// int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
|
||||
// int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
|
||||
// JsonObject nodeRefResSumObj = new JsonObject();
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE));
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE));
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE));
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT));
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR));
|
||||
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY));
|
||||
// nodeRefResSumArray.add(nodeRefResSumObj);
|
||||
// }
|
||||
// } catch (SQLException | H2ClientException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getReferences(Step step, long startTime,
|
||||
long endTime, MetricSource metricSource) {
|
||||
@Override public List<ApplicationReferenceMetric> getReferences(Step step,
|
||||
long startTimeBucket, long endTimeBucket, MetricSource metricSource, Integer... applicationIds) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,10 +76,13 @@ public class ApplicationQuery implements Query {
|
|||
}
|
||||
|
||||
public Topology getApplicationTopology(int applicationId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, start, end);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
|
||||
return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
|
||||
}
|
||||
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Duration duration,
|
||||
|
|
|
|||
|
|
@ -20,13 +20,17 @@ package org.apache.skywalking.apm.collector.ui.service;
|
|||
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
|
|
@ -42,6 +46,7 @@ public class ApplicationTopologyService {
|
|||
|
||||
private final IApplicationComponentUIDAO applicationComponentUIDAO;
|
||||
private final IApplicationMappingUIDAO applicationMappingUIDAO;
|
||||
private final IApplicationMetricUIDAO applicationMetricUIDAO;
|
||||
private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO;
|
||||
private final ModuleManager moduleManager;
|
||||
|
||||
|
|
@ -49,76 +54,34 @@ public class ApplicationTopologyService {
|
|||
this.moduleManager = moduleManager;
|
||||
this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class);
|
||||
this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class);
|
||||
this.applicationMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMetricUIDAO.class);
|
||||
this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class);
|
||||
}
|
||||
|
||||
public Topology getApplicationTopology(Step step, int applicationId, long startTime,
|
||||
long endTime) throws ParseException {
|
||||
logger.debug("startTime: {}, endTime: {}", startTime, endTime);
|
||||
List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents = applicationComponentUIDAO.load(step, startTime, endTime);
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTime, endTime);
|
||||
public Topology getApplicationTopology(Step step, int applicationId, long startTimeBucket,
|
||||
long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException {
|
||||
logger.debug("startTime: {}, endTime: {}", startTimeBucket, endTimeBucket);
|
||||
List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, endTimeBucket);
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
|
||||
|
||||
Set<Integer> applicationIds = new HashSet<>();
|
||||
applicationIds.add(applicationId);
|
||||
applicationMappings.forEach(mapping -> {
|
||||
if (mapping.getApplicationId() == applicationId) {
|
||||
applicationIds.add(mapping.getMappingApplicationId());
|
||||
}
|
||||
});
|
||||
|
||||
Map<Integer, String> components = new HashMap<>();
|
||||
applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
|
||||
|
||||
// List<Call> callerCalls = applicationReferenceMetricUIDAO.getFrontApplications(step, applicationId, startTime, endTime, MetricSource.Caller);
|
||||
// callerCalls.addAll(applicationReferenceMetricUIDAO.getBehindApplications(step, applicationId, startTime, endTime, MetricSource.Caller));
|
||||
//
|
||||
// callerCalls.forEach(callerCall -> callerCall.setCallType(components.get(callerCall.getTarget())));
|
||||
//
|
||||
// List<Call> calleeCalls = applicationReferenceMetricUIDAO.getFrontApplications(step, applicationId, startTime, endTime, MetricSource.Callee);
|
||||
// calleeCalls.addAll(applicationReferenceMetricUIDAO.getBehindApplications(step, applicationId, startTime, endTime, MetricSource.Callee));
|
||||
//
|
||||
// calleeCalls.forEach(calleeCall -> calleeCall.setCallType(components.get(calleeCall.getTarget())));
|
||||
//
|
||||
// Set<Integer> mappings = new HashSet<>();
|
||||
// applicationMappings.forEach(mapping -> {
|
||||
// if (applicationId == mapping.getApplicationId()) {
|
||||
// mappings.add(mapping.getMappingApplicationId());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// mappings.forEach(mappingApplicationId -> {
|
||||
// List<Call> frontCallerApplications = applicationReferenceMetricUIDAO.getFrontApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Caller);
|
||||
// frontCallerApplications.forEach(call -> {
|
||||
// call.setCallType(components.get(call.getTarget()));
|
||||
// call.setTarget(applicationId);
|
||||
// callerCalls.add(call);
|
||||
// });
|
||||
//
|
||||
// List<Call> behindCallerApplications = applicationReferenceMetricUIDAO.getBehindApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Caller);
|
||||
// behindCallerApplications.forEach(call -> {
|
||||
// call.setCallType(components.get(call.getTarget()));
|
||||
// call.setSource(applicationId);
|
||||
// callerCalls.add(call);
|
||||
// });
|
||||
//
|
||||
// List<Call> frontCalleeApplications = applicationReferenceMetricUIDAO.getFrontApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Callee);
|
||||
// frontCalleeApplications.forEach(call -> {
|
||||
// call.setCallType(components.get(call.getTarget()));
|
||||
// call.setTarget(applicationId);
|
||||
// calleeCalls.add(call);
|
||||
// });
|
||||
//
|
||||
// List<Call> behindCalleeApplications = applicationReferenceMetricUIDAO.getBehindApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Callee);
|
||||
// behindCalleeApplications.forEach(call -> {
|
||||
// call.setCallType(components.get(call.getTarget()));
|
||||
// call.setSource(applicationId);
|
||||
// calleeCalls.add(call);
|
||||
// });
|
||||
// });
|
||||
List<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics = applicationMetricUIDAO.getApplications(step, startTimeBucket, endTimeBucket, MetricSource.Callee);
|
||||
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> callerReferenceMetric = applicationReferenceMetricUIDAO.getReferences(step, startTimeBucket, endTimeBucket, MetricSource.Caller, applicationIds.toArray(new Integer[0]));
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric = applicationReferenceMetricUIDAO.getReferences(step, startTimeBucket, endTimeBucket, MetricSource.Callee, applicationIds.toArray(new Integer[0]));
|
||||
|
||||
TopologyBuilder builder = new TopologyBuilder(moduleManager);
|
||||
|
||||
// long secondsBetween = DurationUtils.INSTANCE.secondsBetween(step, startTime, endTime);
|
||||
// Topology topology = builder.build(applicationComponents, applicationMappings, callerCalls, calleeCalls, secondsBetween);
|
||||
//
|
||||
// topology.getCalls().forEach(call -> {
|
||||
// long calls = call.getCalls();
|
||||
// long responseTimes = call.getResponseTimes();
|
||||
// call.setCallsPerSec(calls / secondsBetween);
|
||||
// call.setAvgResponseTime(responseTimes / secondsBetween);
|
||||
// });
|
||||
return null;
|
||||
return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, startSecondTimeBucket, endSecondTimeBucket);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue