提交 9bde7b7b 编写于 作者: P peng-yongsheng

Remove the application named USER.

上级 8186365b
...@@ -32,7 +32,7 @@ public interface IInstanceUIDAO extends DAO { ...@@ -32,7 +32,7 @@ public interface IInstanceUIDAO extends DAO {
Long instanceLastHeartBeatTime(long applicationInstanceId); Long instanceLastHeartBeatTime(long applicationInstanceId);
List<Application> getApplications(long startTime, long endTime, int... applicationIds); List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, int... applicationIds);
Instance getInstance(int instanceId); Instance getInstance(int instanceId);
......
...@@ -97,14 +97,14 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { ...@@ -97,14 +97,14 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
return heartBeatTime; return heartBeatTime;
} }
@Override public List<Application> getApplications(long startTime, long endTime, int... applicationIds) { @Override public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, int... applicationIds) {
logger.debug("application list get, start time: {}, end time: {}", startTime, endTime); logger.debug("application list get, start time: {}, end time: {}", startSecondTimeBucket, endSecondTimeBucket);
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE);
searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startTime)); boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket));
boolQueryBuilder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); boolQueryBuilder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE));
if (applicationIds.length > 0) { if (applicationIds.length > 0) {
boolQueryBuilder.must().add(QueryBuilders.termsQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationIds)); boolQueryBuilder.must().add(QueryBuilders.termsQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationIds));
......
...@@ -88,12 +88,12 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { ...@@ -88,12 +88,12 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
} }
@Override @Override
public List<Application> getApplications(long startTime, long endTime, int... applicationIds) { public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, int... applicationIds) {
H2Client client = getClient(); H2Client client = getClient();
List<Application> applications = new LinkedList<>(); List<Application> applications = new LinkedList<>();
String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID, String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID,
InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_APPLICATION_ID); InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_APPLICATION_ID);
Object[] params = new Object[] {startTime}; Object[] params = new Object[] {startSecondTimeBucket};
try (ResultSet rs = client.executeQuery(sql, params)) { try (ResultSet rs = client.executeQuery(sql, params)) {
while (rs.next()) { while (rs.next()) {
Integer applicationId = rs.getInt(InstanceTable.COLUMN_APPLICATION_ID); Integer applicationId = rs.getInt(InstanceTable.COLUMN_APPLICATION_ID);
......
...@@ -69,10 +69,10 @@ public class ApplicationQuery implements Query { ...@@ -69,10 +69,10 @@ public class ApplicationQuery implements Query {
} }
public List<Application> getAllApplication(Duration duration) throws ParseException { public List<Application> getAllApplication(Duration duration) throws ParseException {
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
return getApplicationService().getApplications(start, end); return getApplicationService().getApplications(startSecondTimeBucket, endSecondTimeBucket);
} }
public Topology getApplicationTopology(int applicationId, Duration duration) throws ParseException { public Topology getApplicationTopology(int applicationId, Duration duration) throws ParseException {
......
...@@ -21,9 +21,7 @@ package org.apache.skywalking.apm.collector.ui.query; ...@@ -21,9 +21,7 @@ package org.apache.skywalking.apm.collector.ui.query;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
...@@ -101,26 +99,11 @@ public class OverViewLayerQuery implements Query { ...@@ -101,26 +99,11 @@ public class OverViewLayerQuery implements Query {
} }
public ClusterBrief getClusterBrief(Duration duration) throws ParseException { public ClusterBrief getClusterBrief(Duration duration) throws ParseException {
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
ClusterBrief clusterBrief = new ClusterBrief(); ClusterBrief clusterBrief = new ClusterBrief();
clusterBrief.setNumOfApplication(getApplicationService().getApplications(startSecondTimeBucket, endSecondTimeBucket).size());
List<Application> applications = getApplicationService().getApplications(start, end);
boolean containsUserApplication = false;
for (Application application : applications) {
if (application.getId() == Const.NONE_INSTANCE_ID) {
containsUserApplication = true;
break;
}
}
if (containsUserApplication) {
clusterBrief.setNumOfApplication(applications.size() - 1);
} else {
clusterBrief.setNumOfApplication(applications.size());
}
clusterBrief.setNumOfDatabase(getNetworkAddressService().getNumOfDatabase()); clusterBrief.setNumOfDatabase(getNetworkAddressService().getNumOfDatabase());
clusterBrief.setNumOfCache(getNetworkAddressService().getNumOfCache()); clusterBrief.setNumOfCache(getNetworkAddressService().getNumOfCache());
clusterBrief.setNumOfMQ(getNetworkAddressService().getNumOfMQ()); clusterBrief.setNumOfMQ(getNetworkAddressService().getNumOfMQ());
......
...@@ -24,6 +24,7 @@ import org.apache.skywalking.apm.collector.cache.CacheModule; ...@@ -24,6 +24,7 @@ import org.apache.skywalking.apm.collector.cache.CacheModule;
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
...@@ -60,8 +61,15 @@ public class ApplicationService { ...@@ -60,8 +61,15 @@ public class ApplicationService {
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
} }
public List<Application> getApplications(long startTime, long endTime, int... applicationIds) { public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
List<Application> applications = instanceDAO.getApplications(startTime, endTime, applicationIds); int... applicationIds) {
List<Application> applications = instanceDAO.getApplications(startSecondTimeBucket, endSecondTimeBucket, applicationIds);
applications.forEach(application -> {
if (application.getId() == Const.NONE_APPLICATION_ID) {
applications.remove(application);
}
});
applications.forEach(application -> { applications.forEach(application -> {
String applicationCode = applicationCacheService.getApplicationById(application.getId()).getApplicationCode(); String applicationCode = applicationCacheService.getApplicationById(application.getId()).getApplicationCode();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册