You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2025/11/26 11:50:31 UTC
(sling-org-apache-sling-commons-metrics-rrd4j) branch master updated (51dd53f -> 2ed6af6)
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics-rrd4j.git
from 51dd53f SLING-12866 - Restrict force pushes, auto-delete branches on merge
new 707610b SLING-13013 Update to Parent 62
new 2ed6af6 SLING-13013 apply spotless formatting
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.sling-module.json | 5 +
pom.xml | 41 +++++---
.../rrd4j/impl/CodahaleMetricsReporter.java | 115 ++++++++++-----------
.../rrd4j/impl/CopyMetricRegistryListener.java | 3 +-
.../commons/metrics/rrd4j/impl/RRD4JReporter.java | 92 ++++++++++-------
.../metrics/rrd4j/impl/InvalidParamsTest.java | 89 ++++++++++------
.../metrics/rrd4j/impl/RRD4JReporterTest.java | 6 +-
.../commons/metrics/rrd4j/impl/ReporterTest.java | 5 +-
.../commons/metrics/rrd4j/impl/RestartTest.java | 11 +-
9 files changed, 204 insertions(+), 163 deletions(-)
create mode 100644 .sling-module.json
(sling-org-apache-sling-commons-metrics-rrd4j) 01/02: SLING-13013 Update to Parent 62
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics-rrd4j.git
commit 707610b6d5e0abfa59e112c90943fc95d730346c
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Nov 26 12:04:49 2025 +0100
SLING-13013 Update to Parent 62
---
.sling-module.json | 5 +++++
pom.xml | 23 ++++++++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..cfad4d2
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+ "jenkins": {
+ "jdks": [17, 21]
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index dcec77c..b9e0b44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>38</version>
+ <version>62</version>
<relativePath />
</parent>
@@ -47,6 +47,21 @@
</scm>
<dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.framework</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -73,15 +88,17 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
- <version>2.3.2</version>
+ <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
+ <version>3.5.4</version>
<scope>test</scope>
</dependency>
</dependencies>
(sling-org-apache-sling-commons-metrics-rrd4j) 02/02: SLING-13013 apply spotless formatting
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics-rrd4j.git
commit 2ed6af68a22012b87aa05ea6ed9e5dc7cedf81e9
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Nov 26 12:05:30 2025 +0100
SLING-13013 apply spotless formatting
---
pom.xml | 18 ++--
.../rrd4j/impl/CodahaleMetricsReporter.java | 115 ++++++++++-----------
.../rrd4j/impl/CopyMetricRegistryListener.java | 3 +-
.../commons/metrics/rrd4j/impl/RRD4JReporter.java | 92 ++++++++++-------
.../metrics/rrd4j/impl/InvalidParamsTest.java | 89 ++++++++++------
.../metrics/rrd4j/impl/RRD4JReporterTest.java | 6 +-
.../commons/metrics/rrd4j/impl/ReporterTest.java | 5 +-
.../commons/metrics/rrd4j/impl/RestartTest.java | 11 +-
8 files changed, 179 insertions(+), 160 deletions(-)
diff --git a/pom.xml b/pom.xml
index b9e0b44..79d4541 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -31,20 +31,18 @@
<version>1.0.7-SNAPSHOT</version>
<name>Apache Sling Commons Metrics RRD4J</name>
- <description>
- Stores Metrics to the local filesystem using RRD4J.
- </description>
-
- <properties>
- <sling.java.version>8</sling.java.version>
- </properties>
+ <description>Stores Metrics to the local filesystem using RRD4J.</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics-rrd4j.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics-rrd4j.git</developerConnection>
+ <tag>HEAD</tag>
<url>https://github.com/apache/sling-org-apache-sling-commons-metrics-rrd4j.git</url>
- <tag>HEAD</tag>
- </scm>
+ </scm>
+
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ </properties>
<dependencies>
<dependency>
diff --git a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CodahaleMetricsReporter.java b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CodahaleMetricsReporter.java
index 1c24c8a..3080c42 100644
--- a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CodahaleMetricsReporter.java
+++ b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CodahaleMetricsReporter.java
@@ -18,9 +18,19 @@
*/
package org.apache.sling.commons.metrics.rrd4j.impl;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
-
import org.apache.felix.inventory.Format;
import org.apache.felix.inventory.InventoryPrinter;
import org.apache.felix.inventory.ZipAttachmentProvider;
@@ -38,17 +48,6 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
import static org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.DEFAULT_PATH;
import static org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.DEFAULT_STEP;
@@ -57,11 +56,10 @@ import static org.apache.sling.commons.metrics.rrd4j.impl.RRD4JReporter.DEFAULT_
configurationPolicy = ConfigurationPolicy.REQUIRE,
service = {InventoryPrinter.class, ZipAttachmentProvider.class},
property = {
- InventoryPrinter.NAME + "=rrd4j-reporter",
- InventoryPrinter.TITLE + "=Sling Metrics RRD4J reporter",
- InventoryPrinter.FORMAT + "=TEXT"
- }
-)
+ InventoryPrinter.NAME + "=rrd4j-reporter",
+ InventoryPrinter.TITLE + "=Sling Metrics RRD4J reporter",
+ InventoryPrinter.FORMAT + "=TEXT"
+ })
@Designate(ocd = CodahaleMetricsReporter.Configuration.class)
public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentProvider {
@@ -73,53 +71,48 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
private Map<String, CopyMetricRegistryListener> listeners = new ConcurrentHashMap<>();
- @ObjectClassDefinition(name = "Apache Sling Metrics reporter writing to RRD4J",
- description = "For syntax details on RRD data-source and round " +
- "robin archive definitions see " +
- "https://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html and " +
- "https://github.com/rrd4j/rrd4j/wiki/Tutorial. Changing " +
- "any attribute in this configuration will replace an " +
- "existing RRD file with a empty one!")
+ @ObjectClassDefinition(
+ name = "Apache Sling Metrics reporter writing to RRD4J",
+ description = "For syntax details on RRD data-source and round " + "robin archive definitions see "
+ + "https://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html and "
+ + "https://github.com/rrd4j/rrd4j/wiki/Tutorial. Changing "
+ + "any attribute in this configuration will replace an "
+ + "existing RRD file with a empty one!")
public @interface Configuration {
@AttributeDefinition(
name = "Data sources",
- description = "RRDTool data source definitions " +
- "(e.g. 'DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U'). " +
- "Replace colon characters in the metric name with an " +
- "underscore!"
- )
+ description =
+ "RRDTool data source definitions " + "(e.g. 'DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U'). "
+ + "Replace colon characters in the metric name with an "
+ + "underscore!")
String[] datasources() default {};
@AttributeDefinition(
name = "Step",
- description = "The base interval in seconds with which data " +
- "will be fed into the RRD"
- )
+ description = "The base interval in seconds with which data " + "will be fed into the RRD")
int step() default DEFAULT_STEP;
@AttributeDefinition(
name = "Archives",
- description = "RRDTool round robin archive definitions. The " +
- "default configuration defines four archives based " +
- "on a default step of five seconds: " +
- "1) per minute averages for six hours, " +
- "2) per five minute averages 48 hours, " +
- "3) per hour averages for four weeks, " +
- "4) per day averages for one year."
- )
+ description = "RRDTool round robin archive definitions. The "
+ + "default configuration defines four archives based "
+ + "on a default step of five seconds: "
+ + "1) per minute averages for six hours, "
+ + "2) per five minute averages 48 hours, "
+ + "3) per hour averages for four weeks, "
+ + "4) per day averages for one year.")
String[] archives() default {
"RRA:AVERAGE:0.5:12:360", "RRA:AVERAGE:0.5:60:576", "RRA:AVERAGE:0.5:720:336", "RRA:AVERAGE:0.5:17280:365"
};
@AttributeDefinition(
name = "Path",
- description = "Path of the RRD file where metrics are stored. " +
- "If the path is relative, it is resolved relative to " +
- "the value of the framework property 'sling.home' when " +
- "available, otherwise relative to the current working " +
- "directory."
- )
+ description = "Path of the RRD file where metrics are stored. "
+ + "If the path is relative, it is resolved relative to "
+ + "the value of the framework property 'sling.home' when "
+ + "available, otherwise relative to the current working "
+ + "directory.")
String path() default DEFAULT_PATH;
}
@@ -140,8 +133,12 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
reporter.start(config.step(), TimeUnit.SECONDS);
LOG.info("Started RRD4J Metrics reporter: {}.", reporter);
} else {
- LOG.warn("Illegal config will not start the RRD reporter. [path={}, datasources={}, archives={}, step={}].",
- rrd.getPath(), config.datasources(), config.archives(), config.step());
+ LOG.warn(
+ "Illegal config will not start the RRD reporter. [path={}, datasources={}, archives={}, step={}].",
+ rrd.getPath(),
+ config.datasources(),
+ config.archives(),
+ config.step());
}
}
@@ -176,8 +173,7 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
service = MetricRegistry.class,
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC)
- synchronized void addMetricRegistry(MetricRegistry metricRegistry,
- Map<String, Object> properties) {
+ synchronized void addMetricRegistry(MetricRegistry metricRegistry, Map<String, Object> properties) {
String name = (String) properties.get("name");
if (name == null) {
name = metricRegistry.toString();
@@ -185,24 +181,23 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
CopyMetricRegistryListener listener = new CopyMetricRegistryListener(this.metricRegistry, name);
listener.start(metricRegistry);
this.listeners.put(name, listener);
- LOG.info("Bound Metrics Registry {} ",name);
+ LOG.info("Bound Metrics Registry {} ", name);
}
- synchronized void removeMetricRegistry(MetricRegistry metricRegistry,
- Map<String, Object> properties) {
+ synchronized void removeMetricRegistry(MetricRegistry metricRegistry, Map<String, Object> properties) {
String name = (String) properties.get("name");
if (name == null) {
name = metricRegistry.toString();
}
CopyMetricRegistryListener metricRegistryListener = listeners.get(name);
- if ( metricRegistryListener != null) {
+ if (metricRegistryListener != null) {
metricRegistryListener.stop(metricRegistry);
this.listeners.remove(name);
}
- LOG.info("Unbound Metrics Registry {} ",name);
+ LOG.info("Unbound Metrics Registry {} ", name);
}
- //------------------------< InventoryPrinter >------------------------------
+ // ------------------------< InventoryPrinter >------------------------------
@Override
public void print(PrintWriter pw, Format format, boolean isZip) {
@@ -215,11 +210,10 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
}
}
- //----------------------< ZipAttachmentProvider >---------------------------
+ // ----------------------< ZipAttachmentProvider >---------------------------
@Override
- public void addAttachments(ZipOutputStream zos, String namePrefix)
- throws IOException {
+ public void addAttachments(ZipOutputStream zos, String namePrefix) throws IOException {
if (rrd.exists()) {
appendFile(zos, rrd, namePrefix + configuration.path());
}
@@ -229,8 +223,7 @@ public class CodahaleMetricsReporter implements InventoryPrinter, ZipAttachmentP
}
}
- private void appendFile(ZipOutputStream zos, File file, String name)
- throws IOException {
+ private void appendFile(ZipOutputStream zos, File file, String name) throws IOException {
ZipEntry entry = new ZipEntry(name);
entry.setSize(file.length());
zos.putNextEntry(entry);
diff --git a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CopyMetricRegistryListener.java b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CopyMetricRegistryListener.java
index fbb20aa..6904c59 100644
--- a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CopyMetricRegistryListener.java
+++ b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/CopyMetricRegistryListener.java
@@ -43,7 +43,7 @@ class CopyMetricRegistryListener implements MetricRegistryListener {
void stop(MetricRegistry metricRegistry) {
metricRegistry.removeListener(this);
- for(String name : metricRegistry.getMetrics().keySet()) {
+ for (String name : metricRegistry.getMetrics().keySet()) {
removeMetric(name);
}
}
@@ -109,5 +109,4 @@ class CopyMetricRegistryListener implements MetricRegistryListener {
public void onTimerRemoved(String s) {
removeMetric(s);
}
-
}
diff --git a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporter.java b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporter.java
index 8b4d1da..0a34844 100644
--- a/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporter.java
+++ b/src/main/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporter.java
@@ -18,23 +18,6 @@
*/
package org.apache.sling.commons.metrics.rrd4j.impl;
-import com.codahale.metrics.Clock;
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.Timer;
-
-import org.rrd4j.core.Archive;
-import org.rrd4j.core.RrdDb;
-import org.rrd4j.core.RrdDef;
-import org.rrd4j.core.Sample;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -51,6 +34,22 @@ import java.util.Set;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
+import com.codahale.metrics.Clock;
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.MetricFilter;
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.ScheduledReporter;
+import com.codahale.metrics.Timer;
+import org.rrd4j.core.Archive;
+import org.rrd4j.core.RrdDb;
+import org.rrd4j.core.RrdDef;
+import org.rrd4j.core.Sample;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import static java.lang.String.join;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
@@ -82,7 +81,7 @@ class RRD4JReporter extends ScheduledReporter {
private final List<String> archives = new ArrayList<>();
private int step = DEFAULT_STEP;
- Builder(MetricRegistry metricRegistry ) {
+ Builder(MetricRegistry metricRegistry) {
this.metricRegistry = metricRegistry;
}
@@ -167,8 +166,15 @@ class RRD4JReporter extends ScheduledReporter {
if (indexedDS.isEmpty() || archives.isEmpty()) {
return null;
}
- return new RRD4JReporter(metricRegistry, "RRD4JReporter", MetricFilter.ALL, ratesUnit, durationUnit,
- dictionary, createDef(), clock);
+ return new RRD4JReporter(
+ metricRegistry,
+ "RRD4JReporter",
+ MetricFilter.ALL,
+ ratesUnit,
+ durationUnit,
+ dictionary,
+ createDef(),
+ clock);
}
private String checkDataSource(String ds) throws IllegalArgumentException {
@@ -193,14 +199,16 @@ class RRD4JReporter extends ScheduledReporter {
}
}
- RRD4JReporter(MetricRegistry registry,
- String name,
- MetricFilter filter,
- TimeUnit rateUnit,
- TimeUnit durationUnit,
- Map<String, Integer> dictionary,
- RrdDef rrdDef,
- Clock clock) throws IOException {
+ RRD4JReporter(
+ MetricRegistry registry,
+ String name,
+ MetricFilter filter,
+ TimeUnit rateUnit,
+ TimeUnit durationUnit,
+ Map<String, Integer> dictionary,
+ RrdDef rrdDef,
+ Clock clock)
+ throws IOException {
super(registry, name, filter, rateUnit, durationUnit);
this.dictionary.putAll(dictionary);
this.rrdDB = createDB(rrdDef);
@@ -211,7 +219,7 @@ class RRD4JReporter extends ScheduledReporter {
@Override
public void close() {
- super.close();
+ super.close();
try {
// write an unknown sample before closing the DB
if (!rrdDB.isClosed()) {
@@ -224,11 +232,12 @@ class RRD4JReporter extends ScheduledReporter {
}
@Override
- public void report(SortedMap<String, Gauge> gauges,
- SortedMap<String, Counter> counters,
- SortedMap<String, Histogram> histograms,
- SortedMap<String, Meter> meters,
- SortedMap<String, Timer> timers) {
+ public void report(
+ SortedMap<String, Gauge> gauges,
+ SortedMap<String, Counter> counters,
+ SortedMap<String, Histogram> histograms,
+ SortedMap<String, Meter> meters,
+ SortedMap<String, Timer> timers) {
long sampleTime = clock.getTime() / 1000;
if (sampleTime <= lastSampleTime) {
// sample at most once a second
@@ -264,8 +273,11 @@ class RRD4JReporter extends ScheduledReporter {
} finally {
lastSampleTime = sampleTime;
time = System.nanoTime() - time;
- LOGGER.debug("{} out of {} metrics reported in {} \u03bcs",
- reported, total, TimeUnit.NANOSECONDS.toMicros(time));
+ LOGGER.debug(
+ "{} out of {} metrics reported in {} \u03bcs",
+ reported,
+ total,
+ TimeUnit.NANOSECONDS.toMicros(time));
}
}
@@ -345,7 +357,7 @@ class RRD4JReporter extends ScheduledReporter {
private void storeDictionary(String path) throws IOException {
File dictFile = new File(path);
- if (dictFile.exists() && ! dictFile.delete()) {
+ if (dictFile.exists() && !dictFile.delete()) {
throw new IOException("Unable to delete dictionary file: " + dictFile.getPath());
}
Properties dict = new Properties();
@@ -377,8 +389,7 @@ class RRD4JReporter extends ScheduledReporter {
// definition changed -> re-create DB
db.close();
File renamed = renameDB(dbFile);
- LOGGER.info("Configuration changed, renamed existing RRD file to: {}",
- renamed.getPath());
+ LOGGER.info("Configuration changed, renamed existing RRD file to: {}", renamed.getPath());
db = null;
}
}
@@ -397,7 +408,8 @@ class RRD4JReporter extends ScheduledReporter {
// rename rrd file
rename(dbFile.toPath(), dbFile.getName() + suffix(idx));
// rename properties file
- rename(dbFile.toPath().resolveSibling(dbFile.getName() + PROPERTIES_SUFFIX),
+ rename(
+ dbFile.toPath().resolveSibling(dbFile.getName() + PROPERTIES_SUFFIX),
dbFile.getName() + suffix(idx) + PROPERTIES_SUFFIX);
return new File(dbFile.getParentFile(), dbFile.getName() + suffix(idx));
diff --git a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/InvalidParamsTest.java b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/InvalidParamsTest.java
index 3a69b43..65e8f31 100644
--- a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/InvalidParamsTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/InvalidParamsTest.java
@@ -18,20 +18,19 @@
*/
package org.apache.sling.commons.metrics.rrd4j.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.util.Set;
+import com.codahale.metrics.MetricRegistry;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import com.codahale.metrics.MetricRegistry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
public class InvalidParamsTest {
@@ -46,11 +45,15 @@ public class InvalidParamsTest {
assertFalse(rrd.exists());
int step = -1;
- String[] datasources = { "DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U" };
- String[] archives = { "RRA:AVERAGE:0.5:12:360" };
-
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).withStep(step).build();
+ String[] datasources = {"DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U"};
+ String[] archives = {"RRA:AVERAGE:0.5:12:360"};
+
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .withStep(step)
+ .build();
assertNotNull(reporter);
assertTrue(rrd.exists());
assertTrue(reporter.getStep() == 5);
@@ -66,10 +69,13 @@ public class InvalidParamsTest {
assertFalse(rrd.exists());
String[] datasources = null;
- String[] archives = { "RRA:AVERAGE:0.5:12:360" };
+ String[] archives = {"RRA:AVERAGE:0.5:12:360"};
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNull(reporter);
assertFalse(rrd.exists());
}
@@ -79,11 +85,14 @@ public class InvalidParamsTest {
File rrd = new File(folder.newFolder("InvalidParamsTest"), "metrics.rrd");
assertFalse(rrd.exists());
- String[] datasources = { "malformed:input" };
- String[] archives = { "RRA:AVERAGE:0.5:12:360" };
+ String[] datasources = {"malformed:input"};
+ String[] archives = {"RRA:AVERAGE:0.5:12:360"};
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNull(reporter);
assertFalse(rrd.exists());
}
@@ -93,11 +102,14 @@ public class InvalidParamsTest {
File rrd = new File(folder.newFolder("InvalidParamsTest"), "metrics.rrd");
assertFalse(rrd.exists());
- String[] datasources = { "DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U", "malformed:input" };
- String[] archives = { "RRA:AVERAGE:0.5:12:360" };
+ String[] datasources = {"DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U", "malformed:input"};
+ String[] archives = {"RRA:AVERAGE:0.5:12:360"};
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNotNull(reporter);
assertTrue(rrd.exists());
@@ -111,11 +123,14 @@ public class InvalidParamsTest {
File rrd = new File(folder.newFolder("InvalidParamsTest"), "metrics.rrd");
assertFalse(rrd.exists());
- String[] datasources = { "DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U" };
+ String[] datasources = {"DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U"};
String[] archives = null;
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNull(reporter);
assertFalse(rrd.exists());
}
@@ -125,11 +140,14 @@ public class InvalidParamsTest {
File rrd = new File(folder.newFolder("InvalidParamsTest"), "metrics.rrd");
assertFalse(rrd.exists());
- String[] datasources = { "DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U" };
- String[] archives = { "malformed:input" };
+ String[] datasources = {"DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U"};
+ String[] archives = {"malformed:input"};
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNull(reporter);
assertFalse(rrd.exists());
}
@@ -139,11 +157,14 @@ public class InvalidParamsTest {
File rrd = new File(folder.newFolder("InvalidParamsTest"), "metrics.rrd");
assertFalse(rrd.exists());
- String[] datasources = { "DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U" };
- String[] archives = { "RRA:AVERAGE:0.5:12:360", "malformed:input" };
+ String[] datasources = {"DS:oak_SESSION_LOGIN_COUNTER:COUNTER:300:0:U"};
+ String[] archives = {"RRA:AVERAGE:0.5:12:360", "malformed:input"};
- RRD4JReporter reporter = RRD4JReporter.forRegistry(registry).withPath(rrd).withDatasources(datasources)
- .withArchives(archives).build();
+ RRD4JReporter reporter = RRD4JReporter.forRegistry(registry)
+ .withPath(rrd)
+ .withDatasources(datasources)
+ .withArchives(archives)
+ .build();
assertNotNull(reporter);
assertTrue(rrd.exists());
Set<String> archs = reporter.getArchives();
diff --git a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporterTest.java b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporterTest.java
index 922500a..fa8548a 100644
--- a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporterTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RRD4JReporterTest.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -41,8 +40,8 @@ public class RRD4JReporterTest {
registry.register("myMetric", new TestGauge(42));
reporter = RRD4JReporter.forRegistry(registry)
.withPath(RRD)
- .withArchives(new String[]{"RRA:AVERAGE:0.5:1:60"})
- .withDatasources(new String[]{"DS:sling_myMetric:GAUGE:300:0:U"})
+ .withArchives(new String[] {"RRA:AVERAGE:0.5:1:60"})
+ .withDatasources(new String[] {"DS:sling_myMetric:GAUGE:300:0:U"})
.withStep(1)
.build();
}
@@ -73,4 +72,3 @@ public class RRD4JReporterTest {
}
}
}
-
diff --git a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/ReporterTest.java b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/ReporterTest.java
index 00f5a8e..7e48893 100644
--- a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/ReporterTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/ReporterTest.java
@@ -24,7 +24,6 @@ import java.util.Map;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
-
import org.apache.sling.testing.mock.osgi.MockOsgi;
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
import org.junit.Before;
@@ -110,8 +109,8 @@ public class ReporterTest {
private static Map<String, Object> newConfig() {
Map<String, Object> properties = new HashMap<>();
properties.put("step", 1L);
- properties.put("datasources", new String[]{"DS:sling_myMetric:GAUGE:300:0:U"});
- properties.put("archives", new String[]{"RRA:AVERAGE:0.5:1:60"});
+ properties.put("datasources", new String[] {"DS:sling_myMetric:GAUGE:300:0:U"});
+ properties.put("archives", new String[] {"RRA:AVERAGE:0.5:1:60"});
properties.put("path", RRD.getPath());
return properties;
}
diff --git a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RestartTest.java b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RestartTest.java
index 7dd4c88..25c1deb 100644
--- a/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RestartTest.java
+++ b/src/test/java/org/apache/sling/commons/metrics/rrd4j/impl/RestartTest.java
@@ -26,7 +26,6 @@ import java.util.concurrent.atomic.AtomicLong;
import com.codahale.metrics.Clock;
import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricRegistry;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -95,9 +94,9 @@ public class RestartTest {
// check DB
RrdDb db = new RrdDb(RRD.getPath());
try {
- double[] values = db.createFetchRequest(
- db.getArchive(0).getConsolFun(), start, end)
- .fetchData().getValues("0");
+ double[] values = db.createFetchRequest(db.getArchive(0).getConsolFun(), start, end)
+ .fetchData()
+ .getValues("0");
for (double v : values) {
if (Double.isNaN(v)) {
continue;
@@ -117,8 +116,8 @@ public class RestartTest {
private RRD4JReporter createReporter() throws IOException {
return RRD4JReporter.forRegistry(registry)
.withPath(RRD)
- .withArchives(new String[]{"RRA:AVERAGE:0.5:1:60"})
- .withDatasources(new String[]{"DS:myCounter:COUNTER:300:0:U"})
+ .withArchives(new String[] {"RRA:AVERAGE:0.5:1:60"})
+ .withDatasources(new String[] {"DS:myCounter:COUNTER:300:0:U"})
.withStep(1)
.withClock(clock)
.build();