as suggested by Tom in I76ce2e1600e8f99eb735aac4c29c423cc01c59ee review.
Change-Id: Iba7bda3f51594764c21ba8d4dd7dc69f824f5125
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.infrautils.metrics;
-
-/**
- * Metric which can be {@link #close()}'d.
- *
- * <p>OSGi bundles using metrics must close() them when unloading the bundle
- * (typically e.g. via Blueprint {@literal @}PreDstroy), or if they are dynamic
- * metrics (e.g. for devices) when they are no longer needed.
- *
- * <p>Metrics that are closed can no longer be used, and will throw an IllegalStateException if they are.
- *
- * @author Michael Vorburger.ch
- */
-public interface CloseableMetric {
-
- void close();
-
-}
*/
package org.opendaylight.infrautils.metrics;
+import org.opendaylight.infrautils.utils.UncheckedCloseable;
+
/**
* Counter metric, which is a simple incrementing and decrementing number.
*
* <p>Note that if you find you only use its <tt>increase()</tt> and never <tt>decrease()</tt>
* methods, then you probably want to use {@link Meter} with <tt>mark()</tt> instead of this.
*/
-public interface Counter extends CloseableMetric {
+public interface Counter extends UncheckedCloseable {
default void increment() {
increment(1);
*/
package org.opendaylight.infrautils.metrics;
+import org.opendaylight.infrautils.utils.UncheckedCloseable;
+
/**
* Meter metric, which measures throughput.
*
* <p>Note that this with <tt>mark()</tt> measures the rate at which a set of events occur;
* whereas {@link Counter} is for things which will <tt>increase()</tt> - and can also <tt>decrease()</tt>.
*/
-public interface Meter extends CloseableMetric {
+public interface Meter extends UncheckedCloseable {
/**
* Mark the occurrence of an event.
*/
package org.opendaylight.infrautils.metrics;
+import org.opendaylight.infrautils.utils.UncheckedCloseable;
import org.opendaylight.infrautils.utils.function.CheckedCallable;
import org.opendaylight.infrautils.utils.function.CheckedRunnable;
/**
* A timer metric which aggregates timing durations.
*/
-public interface Timer extends CloseableMetric {
+public interface Timer extends UncheckedCloseable {
/**
* Times and records the duration of event which returns a value.
import java.lang.management.ManagementFactory;
import javax.annotation.PreDestroy;
import javax.inject.Singleton;
-import org.opendaylight.infrautils.metrics.CloseableMetric;
import org.opendaylight.infrautils.metrics.MetricProvider;
+import org.opendaylight.infrautils.utils.UncheckedCloseable;
import org.opendaylight.infrautils.utils.function.CheckedCallable;
import org.opendaylight.infrautils.utils.function.CheckedRunnable;
import org.ops4j.pax.cdi.api.OsgiServiceProvider;
}
}
- private abstract class CloseableMetricImpl implements CloseableMetric {
+ private abstract class CloseableMetricImpl implements UncheckedCloseable {
private volatile boolean isClosed = false;
private final String id;