Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] sermant-example & sermant-server-monitor code check #365

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
* @since 2022-01-22
*/
public class DemoFieldSetInterceptor extends AbstractInterceptor {
private final String localFieldName = "testLocal";
private final String memberFieldName = "testMember";
private final String staticFieldName = "testStatic";
private static final String LOCALFIELDNAME = "testLocal";
private static final String MEMEBERFIELDNAME = "testMember";
private static final String STATICFIELDNAME = "testStatic";

@Override
public ExecuteContext before(ExecuteContext context) throws Exception {
final Object localField = context.getLocalFieldValue(localFieldName);
final Object localField = context.getLocalFieldValue(LOCALFIELDNAME);
final int newLocalField = localField == null ? 1 : Integer.parseInt(localField.toString()) + 1;
context.setLocalFieldValue(localFieldName, newLocalField);
final Object memberField = context.getMemberFieldValue(memberFieldName);
final Object memberField = context.getMemberFieldValue(MEMEBERFIELDNAME);
final int newMemberField = memberField == null ? 1 : Integer.parseInt(memberField.toString()) + 1;
context.setMemberFieldValue(memberFieldName, newMemberField);
final Object staticField = context.getStaticFieldValue(staticFieldName);
final Object staticField = context.getStaticFieldValue(STATICFIELDNAME);
final int newStaticField = staticField == null ? 1 : Integer.parseInt(staticField.toString()) + 1;
context.setStaticFieldValue(staticFieldName, newStaticField);
return context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public ConnectionPoolController(ConnectionPoolService connectionPoolService) {
*
* @param start 开始时间
* @param end 结束时间
* @param peer database peer
* @return 满足条件的@link DataSourceDTO}实体列表
*/
@GetMapping("/data-sources/druid")
public List<DataSourceDTO> getDataSources(@RequestParam String start,
@RequestParam(required = false) String end,
@RequestParam(required = false) String peer) {
public List<DataSourceDTO> getDataSources(
@RequestParam String start,
@RequestParam(required = false) String end,
@RequestParam(required = false) String peer) {
if (StringUtils.hasText(peer)) {
return connectionPoolService.getDataSourcesByPeer(start, end, peer);
} else {
Expand All @@ -69,9 +71,10 @@ public List<DataSourceDTO> getDataSources(@RequestParam String start,
* @return 满足条件的@link DataSourceDTO}实体列表
*/
@GetMapping("/data-sources/druid/{service}")
public List<DataSourceDTO> getDataSourceOfService(@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service) {
public List<DataSourceDTO> getDataSourceOfService(
@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service) {
return connectionPoolService.getDataSourcesOfService(start, end, service);
}

Expand All @@ -85,10 +88,11 @@ public List<DataSourceDTO> getDataSourceOfService(@RequestParam String start,
* @return 满足条件的@link DataSourceDTO}实体列表
*/
@GetMapping("/data-sources/druid/{service}/{instance}")
public List<DataSourceDTO> getDataSourceOfServiceInstance(@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service,
@PathVariable("instance") String serviceInstance) {
public List<DataSourceDTO> getDataSourceOfServiceInstance(
@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service,
@PathVariable("instance") String serviceInstance) {
return connectionPoolService.getDataSourcesOfServiceInstance(start, end, service, serviceInstance);
}

Expand All @@ -103,11 +107,12 @@ public List<DataSourceDTO> getDataSourceOfServiceInstance(@RequestParam String s
* @return 满足条件的@link DataSourceDTO}实体列表
*/
@GetMapping("/data-sources/druid/{service}/{instance}/{name}")
public List<DataSourceDTO> getDataSourcesByNameInServiceInstance(@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service,
@PathVariable("instance") String serviceInstance,
@PathVariable("name") String name) {
public List<DataSourceDTO> getDataSourcesByNameInServiceInstance(
@RequestParam String start,
@RequestParam(required = false) String end,
@PathVariable("service") String service,
@PathVariable("instance") String serviceInstance,
@PathVariable("name") String name) {
return connectionPoolService.getDataSourcesByNameInServiceInstance(start, end, service, serviceInstance, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,58 @@ public IbmPoolController(IbmMemoryPoolService service) {
}

@GetMapping("/memory-pool/jcc")
public List<IbmMemoryPoolDTO> getJITCodeCachePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getJitCodeCachePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.JCC, start, end);
}

@GetMapping("/memory-pool/jdc")
public List<IbmMemoryPoolDTO> getJITDataCachePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getJitDataCachePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.JDC, start, end);
}

@GetMapping("/memory-pool/ts")
public List<IbmMemoryPoolDTO> getTenuredSOAPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getTenuredSoaPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.TS, start, end);
}

@GetMapping("/memory-pool/tl")
public List<IbmMemoryPoolDTO> getTenuredLOAPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getTenuredLoaPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.TL, start, end);
}

@GetMapping("/memory-pool/na")
public List<IbmMemoryPoolDTO> getNurseryAllocatePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getNurseryAllocatePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.NA, start, end);
}

@GetMapping("/memory-pool/ns")
public List<IbmMemoryPoolDTO> getNurserySurvivorPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getNurserySurvivorPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.NS, start, end);
}

@GetMapping("/memory-pool/cs")
public List<IbmMemoryPoolDTO> getClassStoragePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getClassStoragePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.CS, start, end);
}

@GetMapping("/memory-pool/mnhs")
public List<IbmMemoryPoolDTO> getMiscellaneousNonHeapStoragePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<IbmMemoryPoolDTO> getMiscellaneousNonHeapStoragePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return service.getMemoryPools(IbmPoolType.MNHS, start, end);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,74 +55,86 @@ public OpenJdkJvmController(OpenJdkMemoryService memoryService,
}

@GetMapping("/cpu")
public List<CpuDTO> getCpuMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<CpuDTO> getCpuMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return jvmMetricService.getCpuMetrics(start, end);
}

@GetMapping("/thread")
public List<ThreadDTO> getThreadMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<ThreadDTO> getThreadMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return jvmMetricService.getThreadMetrics(start, end);
}

@GetMapping("/gc/young")
public List<GcDTO> getYoungGcMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<GcDTO> getYoungGcMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return jvmMetricService.getGcMetrics(start, end, GcDTO.GcType.YOUNG);
}

@GetMapping("/gc/old")
public List<GcDTO> getOldGcMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<GcDTO> getOldGcMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return jvmMetricService.getGcMetrics(start, end, GcDTO.GcType.OLD);
}

@GetMapping("/memory/heap")
public List<OpenJdkMemoryDTO> getHeapMemoryMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryDTO> getHeapMemoryMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryService.getMemoryMetrics(OpenJdkMemoryDTO.OracleMemoryType.HEAP, start, end);
}

@GetMapping("/memory/non-heap")
public List<OpenJdkMemoryDTO> getNonHeapMemoryMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryDTO> getNonHeapMemoryMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryService.getMemoryMetrics(OpenJdkMemoryDTO.OracleMemoryType.NON_HEAP, start, end);
}

@GetMapping("/memory-pool/code-cache")
public List<OpenJdkMemoryPoolDTO> getCodeCachePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getCodeCachePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.CODE_CACHE, start, end);
}

@GetMapping("/memory-pool/new-gen")
public List<OpenJdkMemoryPoolDTO> getNewGenPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getNewGenPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.NEW_GEN, start, end);
}

@GetMapping("/memory-pool/old-gen")
public List<OpenJdkMemoryPoolDTO> getOldGenPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getOldGenPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.OLD_GEN, start, end);
}

@GetMapping("/memory-pool/survivor")
public List<OpenJdkMemoryPoolDTO> getSurvivorPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getSurvivorPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.SURVIVOR, start, end);
}

@GetMapping("/memory-pool/perm-gen")
public List<OpenJdkMemoryPoolDTO> getPermGenPoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getPermGenPoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.PERM_GEN, start, end);
}

@GetMapping("/memory-pool/metaspace")
public List<OpenJdkMemoryPoolDTO> getMetaspacePoolMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<OpenJdkMemoryPoolDTO> getMetaspacePoolMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return memoryPoolService.getMemoryPools(OpenJdkMemoryPoolDTO.OraclePoolType.METASPACE, start, end);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,44 @@ public ServerMetricController(ServerMetricService serverMetricService) {
}

@GetMapping("/cpu")
public List<CpuDTO> getCpuMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<CpuDTO> getCpuMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getCpuMetrics(start, end);
}

@GetMapping("/memory")
public List<MemoryDTO> getMemoryMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<MemoryDTO> getMemoryMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getMemoryMetrics(start, end);
}

@GetMapping("/network")
public List<NetworkDTO> getNetworkMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<NetworkDTO> getNetworkMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getNetworkMetrics(start, end);
}

@GetMapping("/disk/read-rate")
public List<DiskDTO> getDiskReadRateMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<DiskDTO> getDiskReadRateMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getDiskMetrics(DiskDTO.ValueType.READ_RATE, start, end);
}

@GetMapping("/disk/write-rate")
public List<DiskDTO> getDiskWriteRateMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<DiskDTO> getDiskWriteRateMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getDiskMetrics(DiskDTO.ValueType.WRITE_RATE, start, end);
}

@GetMapping("/disk/io-spent-percentage")
public List<DiskDTO> getDiskIoSpentMetrics(@RequestParam String start,
@RequestParam(required = false) String end) {
public List<DiskDTO> getDiskIoSpentMetrics(
@RequestParam String start,
@RequestParam(required = false) String end) {
return serverMetricService.getDiskMetrics(DiskDTO.ValueType.IO_SPENT_PERCENTAGE, start, end);
}
}
Loading