Merge branch 'master' into add-http-time-out
This commit is contained in:
commit
880bc8b544
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,17 +87,23 @@ public class ApplicationQuery implements Query {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!]!
|
||||
|
|
|
|||
Loading…
Reference in New Issue