From d0177818584ecb74adc7cef53a70cf998baa3f15 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 19 Feb 2022 14:29:24 +0100 Subject: [PATCH] Renamed metrics.service.files metric and added auto-fix. --- .../htmlize/FederationMetricGenericPage.java | 2 +- .../OrganizationMetricGenericPage.java | 2 +- .../htmlize/ServiceMetricGenericPage.java | 2 +- .../htmlize/serviceMetricGenericView.xhtml | 2 +- .../statoolinfos/metrics/PathCounters.java | 34 ++++++++++++++++++- .../devinsy/statoolinfos/metrics/Prober.java | 3 ++ .../metrics/util/DatafilesProber.java | 4 +-- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java index 132e2e4..6e45287 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java @@ -77,7 +77,7 @@ public class FederationMetricGenericPage FederationMetricHtmlizer.htmlize(data, "graphic.accounts.active", federation, view, period, "metrics.service.accounts.active", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "graphic.database.bytes", federation, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "graphic.files.bytes", federation, view, period, "metrics.service.files.bytes", ChartColor.GREEN); + FederationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", federation, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java index f5530f4..cc247be 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java @@ -77,7 +77,7 @@ public class OrganizationMetricGenericPage OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts", organization, view, period, "metrics.service.accounts", ChartColor.GREEN); OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.active", organization, view, period, "metrics.service.accounts.active", ChartColor.GREEN); OrganizationMetricHtmlizer.htmlize(data, "graphic.database.bytes", organization, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "graphic.files.bytes", organization, view, period, "metrics.service.files.bytes", ChartColor.GREEN); + OrganizationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", organization, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java index ab2c3f0..75ed3b6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java @@ -78,7 +78,7 @@ public class ServiceMetricGenericPage ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.active", service, view, period, "metrics.service.accounts.active", ChartColor.GREEN); ServiceMetricHtmlizer.htmlize(data, "graphic.database.bytes", service, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "graphic.files.bytes", service, view, period, "metrics.service.files.bytes", ChartColor.GREEN); + ServiceMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", service, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); // metrics.moderation.accounts.reported.* = // metrics.moderation.accounts.sanctioned.* = diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml index a15087f..243516c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml @@ -24,7 +24,7 @@

Données

-
+
diff --git a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java index 75a5458..d2d5d75 100644 --- a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java +++ b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -414,6 +414,38 @@ public class PathCounters extends HashMap } } + /** + * Rename path. + * + * @param oldPath + * the old path + * @param newPath + * the new path + * @return the long + */ + public long renamePath(final String oldPath, final String newPath) + { + long result; + + result = 0; + for (String key : new StringList(this.keySet())) + { + if (key.startsWith(oldPath)) + { + result += 1; + + PathCounter counter = get(key); + counter.setPath(counter.getPath().replace(oldPath, newPath)); + remove(key); + put(counter); + System.out.println("Renamed " + key + " to " + counter.getPath()); + } + } + + // + return result; + } + /** * Search by date. * diff --git a/src/fr/devinsy/statoolinfos/metrics/Prober.java b/src/fr/devinsy/statoolinfos/metrics/Prober.java index 0b6bb9c..4406d0f 100644 --- a/src/fr/devinsy/statoolinfos/metrics/Prober.java +++ b/src/fr/devinsy/statoolinfos/metrics/Prober.java @@ -243,6 +243,9 @@ public class Prober PathCounters previousCounters = readMetrics(target); logger.info("previous size={}", previousCounters.size()); + // Temporary fixed 2022-02. + previousCounters.renamePath("metrics.service.files", "metrics.service.datafiles"); + // Merge. logger.info("== Merging"); for (PathCounter counter : counters.values()) diff --git a/src/fr/devinsy/statoolinfos/metrics/util/DatafilesProber.java b/src/fr/devinsy/statoolinfos/metrics/util/DatafilesProber.java index 0d5d231..61c790b 100644 --- a/src/fr/devinsy/statoolinfos/metrics/util/DatafilesProber.java +++ b/src/fr/devinsy/statoolinfos/metrics/util/DatafilesProber.java @@ -90,11 +90,11 @@ public class DatafilesProber // metrics.service.datafiles.bytes long size = FileUtils.sizeOfDirectory(directory); - result.set(size, prefix + ".files.bytes", timemarks); + result.set(size, prefix + ".datafiles.bytes", timemarks); // metrics.service.datafiles.count long count = FilesUtils.listRecursively(directory.getAbsoluteFile()).size(); - result.set(count, prefix + ".files.count", timemarks); + result.set(count, prefix + ".datafiles.count", timemarks); } else {