From 69ceb8d1539974ca718338efa2a3b743b57b3972 Mon Sep 17 00:00:00 2001 From: Lars Johansson <lars.johansson@ess.eu> Date: Tue, 19 Mar 2024 14:52:35 +0100 Subject: [PATCH] Remove non-audit table functionality Focus on metrics, verification. Work in progress. Note that commit is sixth step in introducing audit tables. --- .../controller/VerificationController.java | 4 - .../names/service/MetricsService.java | 203 ++---------------- 2 files changed, 21 insertions(+), 186 deletions(-) diff --git a/src/main/java/org/openepics/names/rest/controller/VerificationController.java b/src/main/java/org/openepics/names/rest/controller/VerificationController.java index e27f3264..cac763cc 100644 --- a/src/main/java/org/openepics/names/rest/controller/VerificationController.java +++ b/src/main/java/org/openepics/names/rest/controller/VerificationController.java @@ -331,7 +331,6 @@ public class VerificationController { prepareLogReport(report, addSpaceUntilSize("# devicetype:", SPACE_UNTIL_SIZE_48) + deviceTypes.size()); prepareLogReport(report, addSpaceUntilSize("# sum:", SPACE_UNTIL_SIZE_48) + sumStructures); prepareLogReport(report, DIVIDER_96); - // <TMP> prepareLogReport(report, addSpaceUntilSize("# tmp systemgroup:", SPACE_UNTIL_SIZE_48) + holderITmpRepositories.systemGroupRepository().findAll().size()); prepareLogReport(report, addSpaceUntilSize("# tmp system:", SPACE_UNTIL_SIZE_48) + holderITmpRepositories.systemRepository().findAll().size()); prepareLogReport(report, addSpaceUntilSize("# tmp subsystem:", SPACE_UNTIL_SIZE_48) + holderITmpRepositories.subsystemRepository().findAll().size()); @@ -345,7 +344,6 @@ public class VerificationController { prepareLogReport(report, addSpaceUntilSize("# tmp audit devicegroup:", SPACE_UNTIL_SIZE_48) + holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICEGROUP, null)); prepareLogReport(report, addSpaceUntilSize("# tmp audit devicetype:", SPACE_UNTIL_SIZE_48) + holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICETYPE, null)); prepareLogReport(report, DIVIDER_96); - // </TMP> // utility // interpret lists into hashmaps for faster retrieval in for loop below @@ -633,11 +631,9 @@ public class VerificationController { prepareLogReport(report, addSpaceUntilSize("# devicerevision:", SPACE_UNTIL_SIZE_48) + deviceRevisions.size()); prepareLogReport(report, addSpaceUntilSize("# name:", SPACE_UNTIL_SIZE_48) + names.size()); prepareLogReport(report, DIVIDER_96); - // <TMP> prepareLogReport(report, addSpaceUntilSize("# tmp name:", SPACE_UNTIL_SIZE_48) + holderITmpRepositories.nameRepository().findAll().size()); prepareLogReport(report, addSpaceUntilSize("# tmp audit name:", SPACE_UNTIL_SIZE_48) + holderTmpRepositories.auditNameRepository().countAuditNames(null)); prepareLogReport(report, DIVIDER_96); - // </TMP> // utility // interpret lists into hashmaps for faster retrieval in for loop below diff --git a/src/main/java/org/openepics/names/service/MetricsService.java b/src/main/java/org/openepics/names/service/MetricsService.java index bd180652..d76821a4 100644 --- a/src/main/java/org/openepics/names/service/MetricsService.java +++ b/src/main/java/org/openepics/names/service/MetricsService.java @@ -18,13 +18,6 @@ package org.openepics.names.service; -import org.openepics.names.repository.DeviceGroupRepository; -import org.openepics.names.repository.DeviceTypeRepository; -import org.openepics.names.repository.DisciplineRepository; -import org.openepics.names.repository.NameRepository; -import org.openepics.names.repository.SubsystemRepository; -import org.openepics.names.repository.SystemGroupRepository; -import org.openepics.names.repository.SystemRepository; import org.openepics.names.repository.tmp.TmpAuditNameRepository; import org.openepics.names.repository.tmp.TmpAuditStructureRepository; import org.openepics.names.repository.tmp.TmpDeviceGroupRepository; @@ -35,7 +28,6 @@ import org.openepics.names.repository.tmp.TmpSubsystemRepository; import org.openepics.names.repository.tmp.TmpSystemGroupRepository; import org.openepics.names.repository.tmp.TmpSystemRepository; import org.openepics.names.rest.beans.Type; -import org.openepics.names.util.HolderRepositories; import org.openepics.names.util.HolderTmpRepositories; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -59,26 +51,15 @@ public class MetricsService { private static final String[] METRICS_NAME = { "ce.naming.name.count", "Count of name entries"}; private static final String[] METRICS_STRUCTURE = { "ce.naming.structure.count", "Count of structure entries"}; - private static final String[] METRICS_TMP_NAME = { "ce.naming.tmp.name.count", "Count of name entries"}; - private static final String[] METRICS_TMP_STRUCTURE = { "ce.naming.tmp.structure.count", "Count of structure entries"}; - private static final String TYPE = "type"; private static final String STATUS = "status"; private static final String[] STATUS_METRICS = {"history", "active", "deleted"}; - private HolderRepositories holderRepositories; private HolderTmpRepositories holderTmpRepositories; @Autowired public MetricsService( MeterRegistry meterRegistry, - NameRepository nameRepository, - SystemGroupRepository systemGroupRepository, - SystemRepository systemRepository, - SubsystemRepository subsystemRepository, - DisciplineRepository disciplineRepository, - DeviceGroupRepository deviceGroupRepository, - DeviceTypeRepository deviceTypeRepository, TmpNameRepository tmpNameRepository, TmpSystemGroupRepository tmpSystemGroupRepository, TmpSystemRepository tmpSystemRepository, @@ -88,14 +69,6 @@ public class MetricsService { TmpDeviceTypeRepository tmpDeviceTypeRepository, TmpAuditNameRepository tmpAuditNameRepository, TmpAuditStructureRepository tmpAuditStructureRepository) { - this.holderRepositories = new HolderRepositories( - nameRepository, - systemGroupRepository, - systemRepository, - subsystemRepository, - disciplineRepository, - deviceGroupRepository, - deviceTypeRepository); this.holderTmpRepositories = new HolderTmpRepositories( tmpNameRepository, tmpSystemGroupRepository, @@ -118,36 +91,18 @@ public class MetricsService { // deleted Gauge.builder(METRICS_NAME[0], - () -> holderRepositories.nameRepository().countNamesHistory(null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.auditNameRepository().countAuditNames(null)) .description(METRICS_NAME[1]) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_NAME[0], - () -> holderRepositories.nameRepository().countNames(Boolean.FALSE, null, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.nameRepository().countNames(Boolean.FALSE, null, null, null, null, null, null, null, null)) .description(METRICS_NAME[1]) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_NAME[0], - () -> holderRepositories.nameRepository().countNames(Boolean.TRUE, null, null, null, null, null, null, null, null, null)) - .description(METRICS_NAME[1]) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - // ---------- - - Gauge.builder(METRICS_TMP_NAME[0], - () -> holderTmpRepositories.auditNameRepository().countAuditNames(null)) - .description(METRICS_TMP_NAME[1]) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_NAME[0], - () -> holderTmpRepositories.nameRepository().countNames(Boolean.FALSE, null, null, null, null, null, null, null, null)) - .description(METRICS_TMP_NAME[1]) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_NAME[0], () -> holderTmpRepositories.nameRepository().countNames(Boolean.TRUE, null, null, null, null, null, null, null, null)) - .description(METRICS_TMP_NAME[1]) + .description(METRICS_NAME[1]) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); @@ -157,231 +112,115 @@ public class MetricsService { // deleted Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemGroupRepository().countSystemGroupsHistory(null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SYSTEMGROUP, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEMGROUP.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemGroupRepository().countSystemGroups(Boolean.FALSE, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.systemGroupRepository().countSystemGroups(Boolean.FALSE, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEMGROUP.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemGroupRepository().countSystemGroups(Boolean.TRUE, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.systemGroupRepository().countSystemGroups(Boolean.TRUE, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEMGROUP.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemRepository().countSystemsHistory(null, null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SYSTEM, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEM.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemRepository().countSystems(Boolean.FALSE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.systemRepository().countSystems(Boolean.FALSE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEM.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.systemRepository().countSystems(Boolean.TRUE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.systemRepository().countSystems(Boolean.TRUE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SYSTEM.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.subsystemRepository().countSubsystemsHistory(null, null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SUBSYSTEM, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SUBSYSTEM.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.subsystemRepository().countSubsystems(Boolean.FALSE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.subsystemRepository().countSubsystems(Boolean.FALSE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SUBSYSTEM.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.subsystemRepository().countSubsystems(Boolean.TRUE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.subsystemRepository().countSubsystems(Boolean.TRUE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.SUBSYSTEM.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.disciplineRepository().countDisciplinesHistory(null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DISCIPLINE, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DISCIPLINE.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.disciplineRepository().countDisciplines(Boolean.FALSE, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.disciplineRepository().countDisciplines(Boolean.FALSE, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DISCIPLINE.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.disciplineRepository().countDisciplines(Boolean.TRUE, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.disciplineRepository().countDisciplines(Boolean.TRUE, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DISCIPLINE.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceGroupRepository().countDeviceGroupsHistory(null, null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICEGROUP, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICEGROUP.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceGroupRepository().countDeviceGroups(Boolean.FALSE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.deviceGroupRepository().countDeviceGroups(Boolean.FALSE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICEGROUP.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceGroupRepository().countDeviceGroups(Boolean.TRUE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.deviceGroupRepository().countDeviceGroups(Boolean.TRUE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICEGROUP.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceTypeRepository().countDeviceTypesHistory(null, null, null, null, null, null, null)) + () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICETYPE, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICETYPE.toString()) .tag(STATUS, STATUS_METRICS[0]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceTypeRepository().countDeviceTypes(Boolean.FALSE, null, null, null, null, null, null, null, null)) + () -> holderTmpRepositories.deviceTypeRepository().countDeviceTypes(Boolean.FALSE, null, null, null, null, null, null, null)) .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICETYPE.toString()) .tag(STATUS, STATUS_METRICS[1]) .register(meterRegistry); Gauge.builder(METRICS_STRUCTURE[0], - () -> holderRepositories.deviceTypeRepository().countDeviceTypes(Boolean.TRUE, null, null, null, null, null, null, null, null)) - .description(METRICS_STRUCTURE[1]) - .tag(TYPE, Type.DEVICETYPE.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - // ---------- - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SYSTEMGROUP, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEMGROUP.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.systemGroupRepository().countSystemGroups(Boolean.FALSE, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEMGROUP.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.systemGroupRepository().countSystemGroups(Boolean.TRUE, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEMGROUP.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SYSTEM, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.systemRepository().countSystems(Boolean.FALSE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.systemRepository().countSystems(Boolean.TRUE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.SUBSYSTEM, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SUBSYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.subsystemRepository().countSubsystems(Boolean.FALSE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SUBSYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.subsystemRepository().countSubsystems(Boolean.TRUE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.SUBSYSTEM.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DISCIPLINE, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DISCIPLINE.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.disciplineRepository().countDisciplines(Boolean.FALSE, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DISCIPLINE.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.disciplineRepository().countDisciplines(Boolean.TRUE, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DISCIPLINE.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICEGROUP, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DEVICEGROUP.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.deviceGroupRepository().countDeviceGroups(Boolean.FALSE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DEVICEGROUP.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.deviceGroupRepository().countDeviceGroups(Boolean.TRUE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DEVICEGROUP.toString()) - .tag(STATUS, STATUS_METRICS[2]) - .register(meterRegistry); - - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.auditStructureRepository().countTmpAuditStructures(Type.DEVICETYPE, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DEVICETYPE.toString()) - .tag(STATUS, STATUS_METRICS[0]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], - () -> holderTmpRepositories.deviceTypeRepository().countDeviceTypes(Boolean.FALSE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) - .tag(TYPE, Type.DEVICETYPE.toString()) - .tag(STATUS, STATUS_METRICS[1]) - .register(meterRegistry); - Gauge.builder(METRICS_TMP_STRUCTURE[0], () -> holderTmpRepositories.deviceTypeRepository().countDeviceTypes(Boolean.TRUE, null, null, null, null, null, null, null)) - .description(METRICS_TMP_STRUCTURE[1]) + .description(METRICS_STRUCTURE[1]) .tag(TYPE, Type.DEVICETYPE.toString()) .tag(STATUS, STATUS_METRICS[2]) .register(meterRegistry); -- GitLab