Merge branch 'master' into module/apm-backend-dist
This commit is contained in:
commit
28d2911749
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
|
|||
*/
|
||||
public interface IInstanceMetricUIDAO extends DAO {
|
||||
|
||||
List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween,
|
||||
int topN,
|
||||
MetricSource metricSource);
|
||||
List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
|
||||
int secondBetween, int topN, MetricSource metricSource);
|
||||
|
||||
List<Integer> getServerTPSTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public interface IInstanceUIDAO extends DAO {
|
|||
|
||||
Instance getInstance(int instanceId);
|
||||
|
||||
List<AppServerInfo> searchServer(String keyword, long start, long end);
|
||||
List<AppServerInfo> searchServer(String keyword, long startSecondTimeBucket, long endSecondTimeBucket);
|
||||
|
||||
List<AppServerInfo> getAllServer(int applicationId, long startSecondTimeBucket, long endSecondTimeBucket);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class AppServerInfo {
|
|||
private String applicationCode;
|
||||
private String osInfo;
|
||||
private String name;
|
||||
private int tps;
|
||||
private int callsPerSec;
|
||||
private String host;
|
||||
private int pid;
|
||||
private List<String> ipv4;
|
||||
|
|
@ -74,12 +74,12 @@ public class AppServerInfo {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public int getTps() {
|
||||
return tps;
|
||||
public int getCallsPerSec() {
|
||||
return callsPerSec;
|
||||
}
|
||||
|
||||
public void setTps(int tps) {
|
||||
this.tps = tps;
|
||||
public void setCallsPerSec(int callsPerSec) {
|
||||
this.callsPerSec = callsPerSec;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
|
|||
return heartBeatTime;
|
||||
}
|
||||
|
||||
@Override public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, int... applicationIds) {
|
||||
@Override public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
|
||||
int... applicationIds) {
|
||||
logger.debug("application list get, start time: {}, end time: {}", startSecondTimeBucket, endSecondTimeBucket);
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE);
|
||||
searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE);
|
||||
|
|
@ -150,19 +151,26 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override public List<AppServerInfo> searchServer(String keyword, long start, long end) {
|
||||
logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end);
|
||||
@Override
|
||||
public List<AppServerInfo> searchServer(String keyword, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE);
|
||||
searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
searchRequestBuilder.setSize(1000);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end));
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
boolQuery.must().add(QueryBuilders.queryStringQuery(keyword));
|
||||
}
|
||||
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE));
|
||||
|
||||
BoolQueryBuilder timeBoolQuery = QueryBuilders.boolQuery();
|
||||
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
|
||||
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
|
||||
|
||||
boolQuery.must().add(timeBoolQuery);
|
||||
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
|
@ -180,11 +188,14 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
|
|||
searchRequestBuilder.setSize(1000);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket));
|
||||
|
||||
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE));
|
||||
|
||||
BoolQueryBuilder timeBoolQuery = QueryBuilders.boolQuery();
|
||||
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
|
||||
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
|
||||
|
||||
boolQuery.must().add(timeBoolQuery);
|
||||
searchRequestBuilder.setQuery(boolQuery);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
|
||||
long secondBetween, int topN, MetricSource metricSource) {
|
||||
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
|
||||
int secondBetween, int topN, MetricSource metricSource) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
|
||||
|
|
@ -67,7 +67,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
|
|||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end));
|
||||
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
|
||||
if (applicationId != 0) {
|
||||
boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
|
|||
InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_TPS);
|
||||
|
||||
appServerInfo.setId(instanceId);
|
||||
appServerInfo.setTps((int)simpleValue.getValue());
|
||||
appServerInfo.setCallsPerSec((int)simpleValue.getValue());
|
||||
appServerInfos.add(appServerInfo);
|
||||
});
|
||||
return appServerInfos;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, int... applicationIds) {
|
||||
public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
|
||||
int... applicationIds) {
|
||||
H2Client client = getClient();
|
||||
List<Application> applications = new LinkedList<>();
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID,
|
||||
|
|
@ -131,20 +132,21 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override public List<AppServerInfo> searchServer(String keyword, long start, long end) {
|
||||
logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end);
|
||||
String dynamicSql = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?";
|
||||
String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS);
|
||||
Object[] params = new Object[] {keyword, start, end, BooleanUtils.FALSE};
|
||||
@Override
|
||||
public List<AppServerInfo> searchServer(String keyword, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
String dynamicSql = "select * from {0} where {1} like ? and (({2} >= ? and {2} <= ?) or ({3} >= ? and {3} <= ?)) and {4} = ?";
|
||||
String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_REGISTER_TIME, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS);
|
||||
Object[] params = new Object[] {keyword, startSecondTimeBucket, endSecondTimeBucket, startSecondTimeBucket, endSecondTimeBucket, BooleanUtils.FALSE};
|
||||
return buildAppServerInfo(sql, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppServerInfo> getAllServer(int applicationId, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
logger.debug("get instances info, applicationId: {}, startSecondTimeBucket: {}, endSecondTimeBucket: {}", applicationId, startSecondTimeBucket, endSecondTimeBucket);
|
||||
String dynamicSql = "select * from {0} where {1} = ? and {2} >= ? and {2} <= ? and {3} >= ? and {4} = ?";
|
||||
String dynamicSql = "select * from {0} where {1} = ? and (({2} >= ? and {2} <= ?) or ({3} >= ? and {3} <= ?)) and {4} = ?";
|
||||
String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.COLUMN_REGISTER_TIME, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS);
|
||||
Object[] params = new Object[] {applicationId, startSecondTimeBucket, endSecondTimeBucket, startSecondTimeBucket, BooleanUtils.FALSE};
|
||||
Object[] params = new Object[] {applicationId, startSecondTimeBucket, endSecondTimeBucket, startSecondTimeBucket, endSecondTimeBucket, BooleanUtils.FALSE};
|
||||
return buildAppServerInfo(sql, params);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
|
||||
long secondBetween, int topN, MetricSource metricSource) {
|
||||
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
|
||||
int secondBetween, int topN, MetricSource metricSource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,25 +76,34 @@ 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,
|
||||
Integer topN) 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 getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, topN);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
|
||||
return getApplicationService().getSlowService(applicationId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, topN);
|
||||
}
|
||||
|
||||
public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration,
|
||||
Integer topN) 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 getServerService().getServerThroughput(applicationId, duration.getStep(), start, end, topN);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
|
||||
return getServerService().getServerThroughput(applicationId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, topN);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,44 +53,44 @@ public class ServerQuery implements Query {
|
|||
}
|
||||
|
||||
public List<AppServerInfo> searchServer(String keyword, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
return getServerService().searchServer(keyword, start, end);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
return getServerService().searchServer(keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
}
|
||||
|
||||
public List<AppServerInfo> getAllServer(int applicationId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
return getServerService().getAllServer(applicationId, start, end);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
return getServerService().getAllServer(applicationId, startSecondTimeBucket, endSecondTimeBucket);
|
||||
}
|
||||
|
||||
public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getServerResponseTimeTrend(serverId, duration.getStep(), start, end);
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getServerResponseTimeTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getServerTPSTrend(serverId, duration.getStep(), start, end);
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getServerTPSTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public CPUTrend getCPUTrend(int serverId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getCPUTrend(serverId, duration.getStep(), start, end);
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getCPUTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public GCTrend getGCTrend(int serverId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getGCTrend(serverId, duration.getStep(), start, end);
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getGCTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
|
||||
public MemoryTrend getMemoryTrend(int serverId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getMemoryTrend(serverId, duration.getStep(), start, end);
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
return getServerService().getMemoryTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.ServerTypeDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.application.Application;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
|
||||
|
|
@ -39,18 +40,23 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalApp;
|
|||
import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationService.class);
|
||||
|
||||
private final IInstanceUIDAO instanceDAO;
|
||||
private final IServiceMetricUIDAO serviceMetricUIDAO;
|
||||
private final IApplicationMetricUIDAO applicationMetricUIDAO;
|
||||
private final INetworkAddressUIDAO networkAddressUIDAO;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
private final ServiceNameCacheService serviceNameCacheService;
|
||||
private final SecondBetweenService secondBetweenService;
|
||||
|
||||
public ApplicationService(ModuleManager moduleManager) {
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
|
|
@ -59,6 +65,7 @@ public class ApplicationService {
|
|||
this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
|
||||
this.secondBetweenService = new SecondBetweenService(moduleManager);
|
||||
}
|
||||
|
||||
public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
|
||||
|
|
@ -78,13 +85,18 @@ public class ApplicationService {
|
|||
return applications;
|
||||
}
|
||||
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Step step, long start, long end,
|
||||
Integer top) throws ParseException {
|
||||
List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, start, end, top, MetricSource.Callee);
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
|
||||
long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
|
||||
List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, startTimeBucket, endTimeBucket, topN, MetricSource.Callee);
|
||||
slowServices.forEach(slowService -> {
|
||||
slowService.setName(serviceNameCacheService.get(slowService.getId()).getServiceName());
|
||||
//TODO
|
||||
slowService.setCallsPerSec(1);
|
||||
ServiceName serviceName = serviceNameCacheService.get(slowService.getId());
|
||||
|
||||
try {
|
||||
slowService.setCallsPerSec((int)(slowService.getCalls() / secondBetweenService.calculate(serviceName.getApplicationId(), startSecondTimeBucket, endSecondTimeBucket)));
|
||||
} catch (ParseException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
slowService.setName(serviceName.getServiceName());
|
||||
});
|
||||
return slowServices;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class ServerService {
|
|||
private final IMemoryMetricUIDAO memoryMetricUIDAO;
|
||||
private final InstanceCacheService instanceCacheService;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
private final SecondBetweenService secondBetweenService;
|
||||
|
||||
public ServerService(ModuleManager moduleManager) {
|
||||
this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
|
|
@ -70,10 +71,11 @@ public class ServerService {
|
|||
this.memoryMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class);
|
||||
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
this.secondBetweenService = new SecondBetweenService(moduleManager);
|
||||
}
|
||||
|
||||
public List<AppServerInfo> searchServer(String keyword, long start, long end) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.searchServer(keyword, start, end);
|
||||
public List<AppServerInfo> searchServer(String keyword, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.searchServer(keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
serverInfos.forEach(serverInfo -> {
|
||||
if (serverInfo.getId() == Const.NONE_INSTANCE_ID) {
|
||||
serverInfos.remove(serverInfo);
|
||||
|
|
@ -84,25 +86,26 @@ public class ServerService {
|
|||
return serverInfos;
|
||||
}
|
||||
|
||||
public List<AppServerInfo> getAllServer(int applicationId, long start, long end) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.getAllServer(applicationId, start, end);
|
||||
public List<AppServerInfo> getAllServer(int applicationId, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.getAllServer(applicationId, startSecondTimeBucket, endSecondTimeBucket);
|
||||
buildAppServerInfo(serverInfos);
|
||||
return serverInfos;
|
||||
}
|
||||
|
||||
public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long start,
|
||||
long end) throws ParseException {
|
||||
public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long startTimeBucket,
|
||||
long endTimeBucket) throws ParseException {
|
||||
ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
|
||||
List<Integer> trends = instanceMetricUIDAO.getResponseTimeTrend(instanceId, step, durationPoints);
|
||||
responseTimeTrend.setTrendList(trends);
|
||||
return responseTimeTrend;
|
||||
}
|
||||
|
||||
public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start,
|
||||
long end, Integer topN) throws ParseException {
|
||||
//TODO
|
||||
List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, start, end, 1000, topN, MetricSource.Callee);
|
||||
public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket,
|
||||
long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
|
||||
int secondBetween = secondBetweenService.calculate(applicationId, startSecondTimeBucket, endSecondTimeBucket);
|
||||
|
||||
List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, startTimeBucket, endTimeBucket, secondBetween, topN, MetricSource.Callee);
|
||||
serverThroughput.forEach(appServerInfo -> {
|
||||
String applicationCode = applicationCacheService.getApplicationById(applicationId).getApplicationCode();
|
||||
appServerInfo.setApplicationCode(applicationCode);
|
||||
|
|
@ -114,25 +117,28 @@ public class ServerService {
|
|||
return serverThroughput;
|
||||
}
|
||||
|
||||
public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long start, long end) throws ParseException {
|
||||
public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long startTimeBucket,
|
||||
long endTimeBucket) throws ParseException {
|
||||
ThroughputTrend throughputTrend = new ThroughputTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
|
||||
List<Integer> trends = instanceMetricUIDAO.getServerTPSTrend(instanceId, step, durationPoints);
|
||||
throughputTrend.setTrendList(trends);
|
||||
return throughputTrend;
|
||||
}
|
||||
|
||||
public CPUTrend getCPUTrend(int instanceId, Step step, long start, long end) throws ParseException {
|
||||
public CPUTrend getCPUTrend(int instanceId, Step step, long startTimeBucket,
|
||||
long endTimeBucket) throws ParseException {
|
||||
CPUTrend cpuTrend = new CPUTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
|
||||
List<Integer> trends = cpuMetricUIDAO.getCPUTrend(instanceId, step, durationPoints);
|
||||
cpuTrend.setCost(trends);
|
||||
return cpuTrend;
|
||||
}
|
||||
|
||||
public GCTrend getGCTrend(int instanceId, Step step, long start, long end) throws ParseException {
|
||||
public GCTrend getGCTrend(int instanceId, Step step, long startTimeBucket,
|
||||
long endTimeBucket) throws ParseException {
|
||||
GCTrend gcTrend = new GCTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
|
||||
List<Integer> youngGCTrend = gcMetricUIDAO.getYoungGCTrend(instanceId, step, durationPoints);
|
||||
gcTrend.setYoungGC(youngGCTrend);
|
||||
List<Integer> oldGCTrend = gcMetricUIDAO.getOldGCTrend(instanceId, step, durationPoints);
|
||||
|
|
@ -140,9 +146,9 @@ public class ServerService {
|
|||
return gcTrend;
|
||||
}
|
||||
|
||||
public MemoryTrend getMemoryTrend(int instanceId, Step step, long start, long end) throws ParseException {
|
||||
public MemoryTrend getMemoryTrend(int instanceId, Step step, long startTimeBucket, long endTimeBucket) throws ParseException {
|
||||
MemoryTrend memoryTrend = new MemoryTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
|
||||
IMemoryMetricUIDAO.Trend heapMemoryTrend = memoryMetricUIDAO.getHeapMemoryTrend(instanceId, step, durationPoints);
|
||||
memoryTrend.setHeap(heapMemoryTrend.getMetrics());
|
||||
memoryTrend.setMaxHeap(heapMemoryTrend.getMaxMetrics());
|
||||
|
|
|
|||
|
|
@ -139,11 +139,11 @@ public enum DurationUtils {
|
|||
return dateTime;
|
||||
}
|
||||
|
||||
public List<DurationPoint> getDurationPoints(Step step, long start, long end) throws ParseException {
|
||||
DateTime dateTime = parseToDateTime(step, start);
|
||||
public List<DurationPoint> getDurationPoints(Step step, long startTimeBucket, long endTimeBucket) throws ParseException {
|
||||
DateTime dateTime = parseToDateTime(step, startTimeBucket);
|
||||
|
||||
List<DurationPoint> durations = new LinkedList<>();
|
||||
durations.add(new DurationPoint(start, secondsBetween(step, dateTime)));
|
||||
durations.add(new DurationPoint(startTimeBucket, secondsBetween(step, dateTime)));
|
||||
|
||||
int i = 0;
|
||||
do {
|
||||
|
|
@ -176,10 +176,10 @@ public enum DurationUtils {
|
|||
}
|
||||
i++;
|
||||
if (i > 500) {
|
||||
throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + start + ", end: " + end);
|
||||
throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + startTimeBucket + ", end: " + endTimeBucket);
|
||||
}
|
||||
}
|
||||
while (end != durations.get(durations.size() - 1).getPoint());
|
||||
while (endTimeBucket != durations.get(durations.size() - 1).getPoint());
|
||||
|
||||
return durations;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ type AppServerInfo {
|
|||
name: String!
|
||||
applicationId: Int!
|
||||
applicationCode: String
|
||||
tps: Int!
|
||||
callsPerSec: Int!
|
||||
host: String
|
||||
pid: Int
|
||||
ipv4: [String!]!
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
|
@ -46,6 +47,9 @@ import static org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig.C
|
|||
*/
|
||||
public class DiscoveryRestServiceClient implements Runnable {
|
||||
private static final ILog logger = LogManager.getLogger(DiscoveryRestServiceClient.class);
|
||||
private static final int HTTP_CONNECT_TIMEOUT = 2000;
|
||||
private static final int HTTP_CONNECTION_REQUEST_TIMEOUT = 1000;
|
||||
private static final int HTTP_SOCKET_TIMEOUT = 2000;
|
||||
private String[] serverList;
|
||||
private volatile int selectedServer = -1;
|
||||
|
||||
|
|
@ -133,7 +137,11 @@ public class DiscoveryRestServiceClient implements Runnable {
|
|||
return null;
|
||||
}
|
||||
HttpGet httpGet = new HttpGet("http://" + serverList[selectedServer] + Config.Collector.DISCOVERY_SERVICE_NAME);
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(HTTP_CONNECT_TIMEOUT)
|
||||
.setConnectionRequestTimeout(HTTP_CONNECTION_REQUEST_TIMEOUT)
|
||||
.setSocketTimeout(HTTP_SOCKET_TIMEOUT).build();
|
||||
httpGet.setConfig(requestConfig);
|
||||
return httpGet;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue