Fixed the bug which the memory max non heap metric value is -1 when using JDK 1.8.
This commit is contained in:
parent
6ba5453086
commit
41840ce851
|
|
@ -66,8 +66,14 @@ public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO {
|
|||
long max = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue();
|
||||
long used = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue();
|
||||
long times = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue();
|
||||
|
||||
trend.getMetrics().add((int)(used / times));
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
|
||||
if (max < 0) {
|
||||
trend.getMaxMetrics().add((int)(used / times));
|
||||
} else {
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
}
|
||||
} else {
|
||||
trend.getMetrics().add(0);
|
||||
trend.getMaxMetrics().add(0);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,12 @@ public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO {
|
|||
long used = rs.getLong(MemoryMetricTable.COLUMN_USED);
|
||||
long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES);
|
||||
trend.getMetrics().add((int)(used / times));
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
|
||||
if (max < 0) {
|
||||
trend.getMaxMetrics().add((int)(used / times));
|
||||
} else {
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
}
|
||||
} else {
|
||||
trend.getMetrics().add(0);
|
||||
trend.getMaxMetrics().add(0);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
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.InstanceCacheService;
|
||||
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.StringUtils;
|
||||
|
|
@ -59,7 +58,6 @@ public class ServerService {
|
|||
private final ICpuMetricUIDAO cpuMetricUIDAO;
|
||||
private final IGCMetricUIDAO gcMetricUIDAO;
|
||||
private final IMemoryMetricUIDAO memoryMetricUIDAO;
|
||||
private final InstanceCacheService instanceCacheService;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
private final SecondBetweenService secondBetweenService;
|
||||
|
||||
|
|
@ -69,18 +67,18 @@ public class ServerService {
|
|||
this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class);
|
||||
this.gcMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
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 startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.searchServer(keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
serverInfos.forEach(serverInfo -> {
|
||||
if (serverInfo.getId() == Const.NONE_INSTANCE_ID) {
|
||||
serverInfos.remove(serverInfo);
|
||||
|
||||
for (int i = serverInfos.size() - 1; i >= 0; i--) {
|
||||
if (serverInfos.get(i).getId() == Const.NONE_INSTANCE_ID) {
|
||||
serverInfos.remove(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildAppServerInfo(serverInfos);
|
||||
return serverInfos;
|
||||
|
|
@ -164,6 +162,8 @@ public class ServerService {
|
|||
private void buildAppServerInfo(List<AppServerInfo> serverInfos) {
|
||||
serverInfos.forEach(serverInfo -> {
|
||||
serverInfo.setApplicationCode(applicationCacheService.getApplicationById(serverInfo.getApplicationId()).getApplicationCode());
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
nameBuilder.append(serverInfo.getApplicationCode());
|
||||
if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) {
|
||||
JsonObject osInfoJson = gson.fromJson(serverInfo.getOsInfo(), JsonObject.class);
|
||||
if (osInfoJson.has("osName")) {
|
||||
|
|
@ -180,10 +180,14 @@ public class ServerService {
|
|||
JsonArray ipv4Array = osInfoJson.get("ipv4s").getAsJsonArray();
|
||||
|
||||
List<String> ipv4s = new LinkedList<>();
|
||||
ipv4Array.forEach(ipv4 -> ipv4s.add(ipv4.getAsString()));
|
||||
ipv4Array.forEach(ipv4 -> {
|
||||
ipv4s.add(ipv4.getAsString());
|
||||
nameBuilder.append(Const.ID_SPLIT).append(ipv4.getAsString());
|
||||
});
|
||||
serverInfo.setIpv4(ipv4s);
|
||||
}
|
||||
}
|
||||
serverInfo.setName(nameBuilder.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue