The nodes and calls in cluster topology build success.
This commit is contained in:
parent
239579fda2
commit
338b2c6726
|
|
@ -30,4 +30,55 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
|
|||
public interface IApplicationMetricUIDAO extends DAO {
|
||||
List<ApplicationTPS> getTopNApplicationThroughput(Step step, long start, long end, long betweenSecond, int topN,
|
||||
MetricSource metricSource);
|
||||
|
||||
List<ApplicationMetric> getApplications(Step step, long startTimeBucket, long endTimeBucket,
|
||||
MetricSource metricSource);
|
||||
|
||||
class ApplicationMetric {
|
||||
private int id;
|
||||
private long calls;
|
||||
private long errorCalls;
|
||||
private long durations;
|
||||
private long errorDurations;
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setCalls(long calls) {
|
||||
this.calls = calls;
|
||||
}
|
||||
|
||||
public void setErrorCalls(long errorCalls) {
|
||||
this.errorCalls = errorCalls;
|
||||
}
|
||||
|
||||
public void setDurations(long durations) {
|
||||
this.durations = durations;
|
||||
}
|
||||
|
||||
public void setErrorDurations(long errorDurations) {
|
||||
this.errorDurations = errorDurations;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getCalls() {
|
||||
return calls;
|
||||
}
|
||||
|
||||
public long getErrorCalls() {
|
||||
return errorCalls;
|
||||
}
|
||||
|
||||
public long getDurations() {
|
||||
return durations;
|
||||
}
|
||||
|
||||
public long getErrorDurations() {
|
||||
return errorDurations;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,18 +21,75 @@ package org.apache.skywalking.apm.collector.storage.dao.ui;
|
|||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Call;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationReferenceMetricUIDAO extends DAO {
|
||||
List<Call> getFrontApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
|
||||
List<Call> getBehindApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
|
||||
List<Call> getApplications(Step step, long startTime, long endTime, MetricSource metricSource);
|
||||
List<ApplicationReferenceMetric> getReferences(Step step, long startTime, long endTime,
|
||||
MetricSource metricSource);
|
||||
|
||||
class ApplicationReferenceMetric {
|
||||
private int source;
|
||||
private int target;
|
||||
private long calls;
|
||||
private long errorCalls;
|
||||
private long durations;
|
||||
private long errorDurations;
|
||||
|
||||
public int getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(int source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public int getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(int target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public long getCalls() {
|
||||
return calls;
|
||||
}
|
||||
|
||||
public void setCalls(long calls) {
|
||||
this.calls = calls;
|
||||
}
|
||||
|
||||
public long getErrorCalls() {
|
||||
return errorCalls;
|
||||
}
|
||||
|
||||
public void setErrorCalls(long errorCalls) {
|
||||
this.errorCalls = errorCalls;
|
||||
}
|
||||
|
||||
public long getDurations() {
|
||||
return durations;
|
||||
}
|
||||
|
||||
public void setDurations(long durations) {
|
||||
this.durations = durations;
|
||||
}
|
||||
|
||||
public long getErrorDurations() {
|
||||
return errorDurations;
|
||||
}
|
||||
|
||||
public void setErrorDurations(long errorDurations) {
|
||||
this.errorDurations = errorDurations;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,76 +25,76 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Node;
|
|||
*/
|
||||
public class ApplicationNode extends Node {
|
||||
|
||||
private Float sla;
|
||||
private Long callsPerSec;
|
||||
private Long responseTimePerSec;
|
||||
private Float apdex;
|
||||
private Boolean isAlarm;
|
||||
private Integer numOfServer;
|
||||
private Integer numOfServerAlarm;
|
||||
private Integer numOfServiceAlarm;
|
||||
private int sla;
|
||||
private long callsPerSec;
|
||||
private long responseTimePerSec;
|
||||
private int apdex;
|
||||
private boolean isAlarm;
|
||||
private int numOfServer;
|
||||
private int numOfServerAlarm;
|
||||
private int numOfServiceAlarm;
|
||||
|
||||
public Float getSla() {
|
||||
public int getSla() {
|
||||
return sla;
|
||||
}
|
||||
|
||||
public void setSla(Float sla) {
|
||||
public void setSla(int sla) {
|
||||
this.sla = sla;
|
||||
}
|
||||
|
||||
public Long getCallsPerSec() {
|
||||
public long getCallsPerSec() {
|
||||
return callsPerSec;
|
||||
}
|
||||
|
||||
public void setCallsPerSec(Long callsPerSec) {
|
||||
public void setCallsPerSec(long callsPerSec) {
|
||||
this.callsPerSec = callsPerSec;
|
||||
}
|
||||
|
||||
public Long getResponseTimePerSec() {
|
||||
public long getResponseTimePerSec() {
|
||||
return responseTimePerSec;
|
||||
}
|
||||
|
||||
public void setResponseTimePerSec(Long responseTimePerSec) {
|
||||
public void setResponseTimePerSec(long responseTimePerSec) {
|
||||
this.responseTimePerSec = responseTimePerSec;
|
||||
}
|
||||
|
||||
public Float getApdex() {
|
||||
public int getApdex() {
|
||||
return apdex;
|
||||
}
|
||||
|
||||
public void setApdex(Float apdex) {
|
||||
public void setApdex(int apdex) {
|
||||
this.apdex = apdex;
|
||||
}
|
||||
|
||||
public Boolean getAlarm() {
|
||||
public boolean isAlarm() {
|
||||
return isAlarm;
|
||||
}
|
||||
|
||||
public void setAlarm(Boolean alarm) {
|
||||
public void setAlarm(boolean alarm) {
|
||||
isAlarm = alarm;
|
||||
}
|
||||
|
||||
public Integer getNumOfServer() {
|
||||
public int getNumOfServer() {
|
||||
return numOfServer;
|
||||
}
|
||||
|
||||
public void setNumOfServer(Integer numOfServer) {
|
||||
public void setNumOfServer(int numOfServer) {
|
||||
this.numOfServer = numOfServer;
|
||||
}
|
||||
|
||||
public Integer getNumOfServerAlarm() {
|
||||
public int getNumOfServerAlarm() {
|
||||
return numOfServerAlarm;
|
||||
}
|
||||
|
||||
public void setNumOfServerAlarm(Integer numOfServerAlarm) {
|
||||
public void setNumOfServerAlarm(int numOfServerAlarm) {
|
||||
this.numOfServerAlarm = numOfServerAlarm;
|
||||
}
|
||||
|
||||
public Integer getNumOfServiceAlarm() {
|
||||
public int getNumOfServiceAlarm() {
|
||||
return numOfServiceAlarm;
|
||||
}
|
||||
|
||||
public void setNumOfServiceAlarm(Integer numOfServiceAlarm) {
|
||||
public void setNumOfServiceAlarm(int numOfServiceAlarm) {
|
||||
this.numOfServiceAlarm = numOfServiceAlarm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public class InstanceHeartBeatEsPersistenceDAO extends EsDAO implements IInstanc
|
|||
instance.setId(id);
|
||||
instance.setInstanceId(((Number)source.get(InstanceTable.COLUMN_INSTANCE_ID)).intValue());
|
||||
instance.setHeartBeatTime(((Number)source.get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue());
|
||||
logger.debug("getId: {} is exists", id);
|
||||
logger.debug("getApplicationId: {} is exists", id);
|
||||
return instance;
|
||||
} else {
|
||||
logger.debug("getId: {} is not exists", id);
|
||||
logger.debug("getApplicationId: {} is not exists", id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class SegmentDurationEsPersistenceDAO extends EsDAO implements ISegmentDu
|
|||
}
|
||||
|
||||
@Override public IndexRequestBuilder prepareBatchInsert(SegmentDuration data) {
|
||||
logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId());
|
||||
logger.debug("segment cost prepareBatchInsert, getApplicationId: {}", data.getId());
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(SegmentDurationTable.COLUMN_SEGMENT_ID, data.getSegmentId());
|
||||
source.put(SegmentDurationTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class ApplicationRegisterEsDAO extends EsDAO implements IApplicationRegis
|
|||
}
|
||||
|
||||
@Override public void save(Application application) {
|
||||
logger.debug("save application register info, application getId: {}, application code: {}", application.getId(), application.getApplicationCode());
|
||||
logger.debug("save application register info, application getApplicationId: {}, application code: {}", application.getId(), application.getApplicationCode());
|
||||
ElasticSearchClient client = getClient();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
|
||||
|
|
@ -59,6 +59,6 @@ public class ApplicationRegisterEsDAO extends EsDAO implements IApplicationRegis
|
|||
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
|
||||
|
||||
IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save application register info, application getId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name());
|
||||
logger.debug("save application register info, application getApplicationId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class InstanceRegisterEsDAO extends EsDAO implements IInstanceRegisterDAO
|
|||
}
|
||||
|
||||
@Override public void save(Instance instance) {
|
||||
logger.debug("save instance register info, application getId: {}, agentUUID: {}", instance.getApplicationId(), instance.getAgentUUID());
|
||||
logger.debug("save instance register info, application getApplicationId: {}, agentUUID: {}", instance.getApplicationId(), instance.getAgentUUID());
|
||||
ElasticSearchClient client = getClient();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId());
|
||||
|
|
@ -65,7 +65,7 @@ public class InstanceRegisterEsDAO extends EsDAO implements IInstanceRegisterDAO
|
|||
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
|
||||
|
||||
IndexResponse response = client.prepareIndex(InstanceTable.TABLE, instance.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save instance register info, application getId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name());
|
||||
logger.debug("save instance register info, application getApplicationId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name());
|
||||
}
|
||||
|
||||
@Override public void updateHeartbeatTime(int instanceId, long heartbeatTime) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class NetworkAddressRegisterEsDAO extends EsDAO implements INetworkAddres
|
|||
}
|
||||
|
||||
@Override public void save(NetworkAddress networkAddress) {
|
||||
logger.debug("save network address register info, address getId: {}, network address code: {}", networkAddress.getId(), networkAddress.getNetworkAddress());
|
||||
logger.debug("save network address register info, address getApplicationId: {}, network address code: {}", networkAddress.getId(), networkAddress.getNetworkAddress());
|
||||
ElasticSearchClient client = getClient();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress());
|
||||
|
|
@ -59,7 +59,7 @@ public class NetworkAddressRegisterEsDAO extends EsDAO implements INetworkAddres
|
|||
source.put(NetworkAddressTable.COLUMN_SERVER_TYPE, networkAddress.getServerType());
|
||||
|
||||
IndexResponse response = client.prepareIndex(NetworkAddressTable.TABLE, networkAddress.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save network address register info, address getId: {}, network address code: {}, status: {}", networkAddress.getAddressId(), networkAddress.getNetworkAddress(), response.status().name());
|
||||
logger.debug("save network address register info, address getApplicationId: {}, network address code: {}, status: {}", networkAddress.getAddressId(), networkAddress.getNetworkAddress(), response.status().name());
|
||||
}
|
||||
|
||||
@Override public void update(String id, int spanLayer, int serverType) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class ServiceNameRegisterEsDAO extends EsDAO implements IServiceNameRegis
|
|||
}
|
||||
|
||||
@Override public void save(ServiceName serviceName) {
|
||||
logger.debug("save service name register info, application getId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
|
||||
logger.debug("save service name register info, application getApplicationId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
|
||||
ElasticSearchClient client = getClient();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(ServiceNameTable.COLUMN_SERVICE_ID, serviceName.getServiceId());
|
||||
|
|
@ -58,6 +58,6 @@ public class ServiceNameRegisterEsDAO extends EsDAO implements IServiceNameRegis
|
|||
source.put(ServiceNameTable.COLUMN_SERVICE_NAME, serviceName.getServiceName());
|
||||
|
||||
IndexResponse response = client.prepareIndex(ServiceNameTable.TABLE, serviceName.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save service name register info, application getId: {}, service name: {}, status: {}", serviceName.getId(), serviceName.getServiceName(), response.status().name());
|
||||
logger.debug("save service name register info, application getApplicationId: {}, service name: {}, status: {}", serviceName.getId(), serviceName.getServiceName(), response.status().name());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.elasticsearch.script.Script;
|
|||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
|
||||
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders;
|
||||
|
||||
|
|
@ -88,17 +89,63 @@ public class ApplicationMetricEsUIDAO extends EsDAO implements IApplicationMetri
|
|||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
List<ApplicationTPS> applicationTPSs = new LinkedList<>();
|
||||
Terms serviceIdTerms = searchResponse.getAggregations().get(ApplicationMetricTable.COLUMN_APPLICATION_ID);
|
||||
serviceIdTerms.getBuckets().forEach(serviceIdTerm -> {
|
||||
int applicationId = serviceIdTerm.getKeyAsNumber().intValue();
|
||||
Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMetricTable.COLUMN_APPLICATION_ID);
|
||||
applicationIdTerms.getBuckets().forEach(applicationIdTerm -> {
|
||||
int applicationId = applicationIdTerm.getKeyAsNumber().intValue();
|
||||
|
||||
ApplicationTPS serviceMetric = new ApplicationTPS();
|
||||
InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_TPS);
|
||||
ApplicationTPS applicationTPS = new ApplicationTPS();
|
||||
InternalSimpleValue simpleValue = applicationIdTerm.getAggregations().get(AVG_TPS);
|
||||
|
||||
serviceMetric.setApplicationId(applicationId);
|
||||
serviceMetric.setTps((int)simpleValue.getValue());
|
||||
applicationTPSs.add(serviceMetric);
|
||||
applicationTPS.setApplicationId(applicationId);
|
||||
applicationTPS.setTps((int)simpleValue.getValue());
|
||||
applicationTPSs.add(applicationTPS);
|
||||
});
|
||||
return applicationTPSs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationMetric> getApplications(Step step, long startTimeBucket, long endTimeBucket,
|
||||
MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMetricTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
searchRequestBuilder.setTypes(ApplicationMetricTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(ApplicationMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue()));
|
||||
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationMetricTable.COLUMN_APPLICATION_ID).field(ApplicationMetricTable.COLUMN_APPLICATION_ID).size(100);
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM));
|
||||
|
||||
searchRequestBuilder.addAggregation(aggregationBuilder);
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
List<ApplicationMetric> applicationMetrics = new LinkedList<>();
|
||||
Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMetricTable.COLUMN_APPLICATION_ID);
|
||||
applicationIdTerms.getBuckets().forEach(applicationIdTerm -> {
|
||||
int applicationId = applicationIdTerm.getKeyAsNumber().intValue();
|
||||
|
||||
Sum calls = applicationIdTerm.getAggregations().get(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS);
|
||||
Sum errorCalls = applicationIdTerm.getAggregations().get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS);
|
||||
Sum durations = applicationIdTerm.getAggregations().get(ApplicationMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
|
||||
Sum errorDurations = applicationIdTerm.getAggregations().get(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM);
|
||||
|
||||
ApplicationMetric applicationMetric = new ApplicationMetric();
|
||||
applicationMetric.setId(applicationId);
|
||||
applicationMetric.setCalls((long)calls.getValue());
|
||||
applicationMetric.setErrorCalls((long)errorCalls.getValue());
|
||||
applicationMetric.setDurations((long)durations.getValue());
|
||||
applicationMetric.setErrorDurations((long)errorDurations.getValue());
|
||||
applicationMetrics.add(applicationMetric);
|
||||
});
|
||||
return applicationMetrics;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceM
|
|||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Call;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
|
|
@ -47,7 +46,8 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<Call> getFrontApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
@Override public List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE);
|
||||
|
||||
|
|
@ -63,32 +63,12 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100);
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
|
||||
|
||||
searchRequestBuilder.addAggregation(aggregationBuilder);
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
List<Call> nodes = new LinkedList<>();
|
||||
Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
|
||||
for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
|
||||
int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
Sum calls = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS);
|
||||
Sum responseTimes = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
|
||||
|
||||
Call call = new Call();
|
||||
call.setSource(frontApplicationId);
|
||||
call.setTarget(applicationId);
|
||||
call.setCalls((int)calls.getValue());
|
||||
call.setResponseTimes((int)responseTimes.getValue());
|
||||
nodes.add(call);
|
||||
}
|
||||
|
||||
return nodes;
|
||||
return buildMetrics(searchRequestBuilder);
|
||||
}
|
||||
|
||||
@Override public List<Call> getBehindApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE);
|
||||
|
||||
|
|
@ -104,32 +84,11 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100);
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
|
||||
|
||||
searchRequestBuilder.addAggregation(aggregationBuilder);
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
List<Call> nodes = new LinkedList<>();
|
||||
Terms behindApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
|
||||
for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) {
|
||||
int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS);
|
||||
Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
|
||||
|
||||
Call call = new Call();
|
||||
call.setTarget(behindApplicationId);
|
||||
call.setSource(applicationId);
|
||||
call.setCalls((int)calls.getValue());
|
||||
call.setResponseTimes((int)responseTimes.getValue());
|
||||
nodes.add(call);
|
||||
}
|
||||
|
||||
return nodes;
|
||||
return buildMetrics(searchRequestBuilder);
|
||||
}
|
||||
|
||||
@Override public List<Call> getApplications(Step step, long startTime, long endTime, MetricSource metricSource) {
|
||||
@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);
|
||||
|
|
@ -143,35 +102,46 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
searchRequestBuilder.setQuery(boolQuery);
|
||||
searchRequestBuilder.setSize(0);
|
||||
|
||||
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100)
|
||||
.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS));
|
||||
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
|
||||
return buildMetrics(searchRequestBuilder);
|
||||
}
|
||||
|
||||
searchRequestBuilder.addAggregation(aggregationBuilder);
|
||||
private List<ApplicationReferenceMetric> buildMetrics(SearchRequestBuilder searchRequestBuilder) {
|
||||
TermsAggregationBuilder frontAggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100);
|
||||
TermsAggregationBuilder behindAggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100);
|
||||
frontAggregationBuilder.subAggregation(behindAggregationBuilder);
|
||||
|
||||
behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS));
|
||||
behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS));
|
||||
behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
|
||||
behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM));
|
||||
|
||||
searchRequestBuilder.addAggregation(frontAggregationBuilder);
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
List<ApplicationReferenceMetric> referenceMetrics = new LinkedList<>();
|
||||
Terms sourceApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
|
||||
for (Terms.Bucket sourceApplicationIdBucket : sourceApplicationIdTerms.getBuckets()) {
|
||||
int sourceApplicationId = sourceApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
|
||||
List<Call> nodes = new LinkedList<>();
|
||||
Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
|
||||
for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
|
||||
int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
Terms targetApplicationIdTerms = sourceApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
|
||||
for (Terms.Bucket targetApplicationIdBucket : targetApplicationIdTerms.getBuckets()) {
|
||||
int targetApplicationId = targetApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
|
||||
Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
|
||||
for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) {
|
||||
int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
Sum calls = targetApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS);
|
||||
Sum errorCalls = targetApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS);
|
||||
Sum durations = targetApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
|
||||
Sum errorDurations = targetApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM);
|
||||
|
||||
Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS);
|
||||
Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
|
||||
|
||||
Call call = new Call();
|
||||
call.setResponseTimes((int)responseTimes.getValue());
|
||||
call.setSource(frontApplicationId);
|
||||
call.setTarget(behindApplicationId);
|
||||
call.setCalls((int)calls.getValue());
|
||||
nodes.add(call);
|
||||
ApplicationReferenceMetric referenceMetric = new ApplicationReferenceMetric();
|
||||
referenceMetric.setSource(sourceApplicationId);
|
||||
referenceMetric.setTarget(targetApplicationId);
|
||||
referenceMetric.setCalls((long)calls.getValue());
|
||||
referenceMetric.setErrorCalls((long)errorCalls.getValue());
|
||||
referenceMetric.setDurations((long)durations.getValue());
|
||||
referenceMetric.setErrorDurations((long)errorDurations.getValue());
|
||||
referenceMetrics.add(referenceMetric);
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
return referenceMetrics;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class SegmentDurationH2PersistenceDAO extends H2DAO implements ISegmentDu
|
|||
}
|
||||
|
||||
@Override public H2SqlEntity prepareBatchInsert(SegmentDuration data) {
|
||||
logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId());
|
||||
logger.debug("segment cost prepareBatchInsert, getApplicationId: {}", data.getId());
|
||||
H2SqlEntity entity = new H2SqlEntity();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(SegmentDurationTable.COLUMN_ID, data.getId());
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ServiceNameRegisterH2DAO extends H2DAO implements IServiceNameRegis
|
|||
|
||||
@Override
|
||||
public void save(ServiceName serviceName) {
|
||||
logger.debug("save service name register info, application getId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
|
||||
logger.debug("save service name register info, application getApplicationId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
|
||||
H2Client client = getClient();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(ServiceNameTable.COLUMN_ID, serviceName.getId());
|
||||
|
|
|
|||
|
|
@ -44,4 +44,9 @@ public class ApplicationMetricH2UIDAO extends H2DAO implements IApplicationMetri
|
|||
int topN, MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public List<ApplicationMetric> getApplications(Step step, long startTimeBucket,
|
||||
long endTimeBucket, MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Call;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -42,7 +41,8 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<Call> getFrontApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
@Override public List<ApplicationReferenceMetric> getFrontApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
H2Client client = getClient();
|
||||
JsonArray applicationReferenceMetricArray = new JsonArray();
|
||||
|
|
@ -74,12 +74,16 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override public List<Call> getBehindApplications(Step step, int applicationId, long startTime, long endTime,
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getBehindApplications(Step step, int applicationId, long startTime,
|
||||
long endTime,
|
||||
MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public List<Call> getApplications(Step step, long startTime, long endTime, MetricSource metricSource) {
|
||||
@Override
|
||||
public List<ApplicationReferenceMetric> getReferences(Step step, long startTime,
|
||||
long endTime, MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public class OverViewLayerQuery implements Query {
|
|||
}
|
||||
|
||||
public Topology getClusterTopology(Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getClusterTopologyService().getClusterTopology(duration.getStep(), start, end);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,20 +20,15 @@ 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.IApplicationReferenceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Call;
|
||||
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.collector.ui.utils.DurationUtils;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -66,64 +61,64 @@ public class ApplicationTopologyService {
|
|||
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<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);
|
||||
// });
|
||||
// });
|
||||
|
||||
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.setResponseTimePerSec(responseTimes / secondsBetween);
|
||||
});
|
||||
return topology;
|
||||
// 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.setResponseTimePerSec(responseTimes / secondsBetween);
|
||||
// });
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ 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.Call;
|
||||
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.collector.ui.utils.DurationUtils;
|
||||
|
|
@ -45,6 +45,7 @@ public class ClusterTopologyService {
|
|||
|
||||
private final IApplicationComponentUIDAO applicationComponentUIDAO;
|
||||
private final IApplicationMappingUIDAO applicationMappingUIDAO;
|
||||
private final IApplicationMetricUIDAO applicationMetricUIDAO;
|
||||
private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO;
|
||||
private final ModuleManager moduleManager;
|
||||
|
||||
|
|
@ -52,6 +53,7 @@ public class ClusterTopologyService {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -63,24 +65,14 @@ public class ClusterTopologyService {
|
|||
Map<Integer, String> components = new HashMap<>();
|
||||
applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
|
||||
|
||||
List<Call> callerCalls = applicationReferenceMetricUIDAO.getApplications(step, startTime, endTime, MetricSource.Caller);
|
||||
callerCalls.forEach(callerCall -> callerCall.setCallType(components.get(callerCall.getTarget())));
|
||||
List<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics = applicationMetricUIDAO.getApplications(step, startTime, endTime, MetricSource.Callee);
|
||||
|
||||
List<Call> calleeCalls = applicationReferenceMetricUIDAO.getApplications(step, startTime, endTime, MetricSource.Callee);
|
||||
|
||||
calleeCalls.forEach(calleeCall -> calleeCall.setCallType(components.get(calleeCall.getTarget())));
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> callerReferenceMetric = applicationReferenceMetricUIDAO.getReferences(step, startTime, endTime, MetricSource.Caller);
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric = applicationReferenceMetricUIDAO.getReferences(step, startTime, endTime, MetricSource.Callee);
|
||||
|
||||
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.setResponseTimePerSec(responseTimes / secondsBetween);
|
||||
});
|
||||
return topology;
|
||||
return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, secondsBetween);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
|||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
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.register.Application;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode;
|
||||
|
|
@ -52,58 +54,92 @@ class TopologyBuilder {
|
|||
}
|
||||
|
||||
Topology build(List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents,
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings, List<Call> callerCalls,
|
||||
List<Call> calleeCalls, long secondsBetween) {
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings,
|
||||
List<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics,
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> callerReferenceMetric,
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric, long secondsBetween) {
|
||||
Map<Integer, String> components = changeNodeComp2Map(applicationComponents);
|
||||
Map<String, String> mappings = changeMapping2Map(applicationMappings);
|
||||
Map<Integer, Integer> mappings = changeMapping2Map(applicationMappings);
|
||||
|
||||
List<Call> calls = buildCalls(callerCalls, calleeCalls);
|
||||
|
||||
Set<Integer> nodeIds = new HashSet<>();
|
||||
calls.forEach(call -> {
|
||||
String sourceName = applicationCacheService.getApplicationById(call.getSource()).getApplicationCode();
|
||||
String targetName = applicationCacheService.getApplicationById(call.getTarget()).getApplicationCode();
|
||||
|
||||
call.setSourceName(sourceName);
|
||||
call.setTargetName(targetName);
|
||||
|
||||
nodeIds.add(call.getSource());
|
||||
nodeIds.add(call.getTarget());
|
||||
});
|
||||
calleeReferenceMetric = calleeReferenceMetricFilter(calleeReferenceMetric);
|
||||
|
||||
List<Node> nodes = new LinkedList<>();
|
||||
nodeIds.forEach(nodeId -> {
|
||||
Application application = applicationCacheService.getApplicationById(nodeId);
|
||||
if (BooleanUtils.valueToBoolean(application.getAddressId())) {
|
||||
ConjecturalNode conjecturalNode = new ConjecturalNode();
|
||||
conjecturalNode.setId(nodeId);
|
||||
conjecturalNode.setName(application.getApplicationCode());
|
||||
conjecturalNode.setType(components.getOrDefault(application.getApplicationId(), Const.UNKNOWN));
|
||||
nodes.add(conjecturalNode);
|
||||
} else {
|
||||
if (nodeId == Const.NONE_APPLICATION_ID) {
|
||||
VisualUserNode node = new VisualUserNode();
|
||||
node.setId(nodeId);
|
||||
node.setName(Const.USER_CODE);
|
||||
node.setType(Const.USER_CODE.toUpperCase());
|
||||
nodes.add(node);
|
||||
} else {
|
||||
ApplicationNode applicationNode = new ApplicationNode();
|
||||
applicationNode.setId(nodeId);
|
||||
applicationNode.setName(application.getApplicationCode());
|
||||
applicationNode.setType(components.getOrDefault(application.getApplicationId(), Const.UNKNOWN));
|
||||
applicationMetrics.forEach(node -> {
|
||||
int id = node.getId();
|
||||
Application application = applicationCacheService.getApplicationById(id);
|
||||
ApplicationNode applicationNode = new ApplicationNode();
|
||||
applicationNode.setId(id);
|
||||
applicationNode.setName(application.getApplicationCode());
|
||||
applicationNode.setType(components.getOrDefault(application.getApplicationId(), Const.UNKNOWN));
|
||||
|
||||
calleeCalls.forEach(call -> {
|
||||
if (call.getTarget() == nodeId) {
|
||||
call.setCallsPerSec(call.getCalls() / secondsBetween);
|
||||
call.setResponseTimePerSec(call.getResponseTimes() / secondsBetween);
|
||||
}
|
||||
});
|
||||
applicationNode.setCallsPerSec(100L);
|
||||
applicationNode.setResponseTimePerSec(100L);
|
||||
nodes.add(applicationNode);
|
||||
}
|
||||
applicationNode.setSla(10);
|
||||
applicationNode.setCallsPerSec(100L);
|
||||
applicationNode.setResponseTimePerSec(100L);
|
||||
applicationNode.setApdex(10);
|
||||
applicationNode.setAlarm(false);
|
||||
applicationNode.setNumOfServer(1);
|
||||
applicationNode.setNumOfServerAlarm(1);
|
||||
applicationNode.setNumOfServiceAlarm(1);
|
||||
nodes.add(applicationNode);
|
||||
});
|
||||
|
||||
List<Call> calls = new LinkedList<>();
|
||||
callerReferenceMetric.forEach(referenceMetric -> {
|
||||
Application source = applicationCacheService.getApplicationById(referenceMetric.getSource());
|
||||
Application target = applicationCacheService.getApplicationById(referenceMetric.getTarget());
|
||||
|
||||
if (BooleanUtils.valueToBoolean(target.getIsAddress()) && !mappings.containsKey(target.getApplicationId())) {
|
||||
ConjecturalNode conjecturalNode = new ConjecturalNode();
|
||||
conjecturalNode.setId(target.getApplicationId());
|
||||
conjecturalNode.setName(target.getApplicationCode());
|
||||
conjecturalNode.setType(components.getOrDefault(target.getApplicationId(), Const.UNKNOWN));
|
||||
nodes.add(conjecturalNode);
|
||||
}
|
||||
|
||||
Call call = new Call();
|
||||
call.setSource(source.getApplicationId());
|
||||
call.setSourceName(source.getApplicationCode());
|
||||
|
||||
int actualTargetId = mappings.getOrDefault(target.getApplicationId(), target.getApplicationId());
|
||||
call.setTarget(actualTargetId);
|
||||
call.setTargetName(applicationCacheService.getApplicationById(actualTargetId).getApplicationCode());
|
||||
call.setAlert(true);
|
||||
call.setCallType("aaa");
|
||||
call.setCallsPerSec(1);
|
||||
call.setResponseTimePerSec(1);
|
||||
calls.add(call);
|
||||
});
|
||||
|
||||
calleeReferenceMetric.forEach(referenceMetric -> {
|
||||
Application source = applicationCacheService.getApplicationById(referenceMetric.getSource());
|
||||
Application target = applicationCacheService.getApplicationById(referenceMetric.getTarget());
|
||||
|
||||
if (source.getApplicationId() == Const.NONE_APPLICATION_ID) {
|
||||
VisualUserNode visualUserNode = new VisualUserNode();
|
||||
visualUserNode.setId(source.getApplicationId());
|
||||
visualUserNode.setName(Const.USER_CODE);
|
||||
visualUserNode.setType(Const.USER_CODE.toUpperCase());
|
||||
nodes.add(visualUserNode);
|
||||
}
|
||||
|
||||
if (BooleanUtils.valueToBoolean(source.getIsAddress())) {
|
||||
ConjecturalNode conjecturalNode = new ConjecturalNode();
|
||||
conjecturalNode.setId(source.getApplicationId());
|
||||
conjecturalNode.setName(source.getApplicationCode());
|
||||
conjecturalNode.setType(components.getOrDefault(source.getApplicationId(), Const.UNKNOWN));
|
||||
nodes.add(conjecturalNode);
|
||||
}
|
||||
|
||||
Call call = new Call();
|
||||
call.setSource(source.getApplicationId());
|
||||
call.setSourceName(source.getApplicationCode());
|
||||
call.setTarget(target.getApplicationId());
|
||||
call.setTargetName(target.getApplicationCode());
|
||||
call.setAlert(true);
|
||||
call.setCallType("aaa");
|
||||
call.setCallsPerSec(1);
|
||||
call.setResponseTimePerSec(1);
|
||||
calls.add(call);
|
||||
});
|
||||
|
||||
Topology topology = new Topology();
|
||||
|
|
@ -112,14 +148,24 @@ class TopologyBuilder {
|
|||
return topology;
|
||||
}
|
||||
|
||||
private Map<String, String> changeMapping2Map(
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings) {
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
applicationMappings.forEach(applicationMapping -> {
|
||||
String applicationCode = applicationCacheService.getApplicationById(applicationMapping.getApplicationId()).getApplicationCode();
|
||||
String address = applicationCacheService.getApplicationById(applicationMapping.getMappingApplicationId()).getApplicationCode();
|
||||
mappings.put(address, applicationCode);
|
||||
private List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetricFilter(
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric) {
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> filteredMetrics = new LinkedList<>();
|
||||
|
||||
calleeReferenceMetric.forEach(referenceMetric -> {
|
||||
Application source = applicationCacheService.getApplicationById(referenceMetric.getSource());
|
||||
if (BooleanUtils.valueToBoolean(source.getIsAddress()) || source.getApplicationId() == Const.NONE_APPLICATION_ID) {
|
||||
filteredMetrics.add(referenceMetric);
|
||||
}
|
||||
});
|
||||
|
||||
return filteredMetrics;
|
||||
}
|
||||
|
||||
private Map<Integer, Integer> changeMapping2Map(
|
||||
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings) {
|
||||
Map<Integer, Integer> mappings = new HashMap<>();
|
||||
applicationMappings.forEach(applicationMapping -> mappings.put(applicationMapping.getMappingApplicationId(), applicationMapping.getApplicationId()));
|
||||
return mappings;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue