This is an automated email from the ASF dual-hosted git repository.
jlli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 7e9af40 Add mark and count methods in PinotMeter interface (#6621)
7e9af40 is described below
commit 7e9af405d9d6f212f97ffab755f8a7325d3724ac
Author: Jialiang Li <[email protected]>
AuthorDate: Sat Feb 27 20:38:01 2021 -0800
Add mark and count methods in PinotMeter interface (#6621)
Co-authored-by: Jack Li(Analytics Engineering) <[email protected]>
---
.../pinot/common/metrics/yammer/YammerMeter.java | 10 ++++++++++
.../pinot/common/metrics/MetricsHelperTest.java | 22 +++++++++++++++++-----
.../org/apache/pinot/spi/metrics/PinotMeter.java | 20 +++++++++++++++++++-
3 files changed, 46 insertions(+), 6 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/metrics/yammer/YammerMeter.java
b/pinot-common/src/main/java/org/apache/pinot/common/metrics/yammer/YammerMeter.java
index d480b43..92a350b 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/metrics/yammer/YammerMeter.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/metrics/yammer/YammerMeter.java
@@ -31,11 +31,21 @@ public class YammerMeter extends YammerMetered implements
PinotMeter {
}
@Override
+ public void mark() {
+ _meter.mark();
+ }
+
+ @Override
public void mark(long unitCount) {
_meter.mark(unitCount);
}
@Override
+ public long count() {
+ return _meter.count();
+ }
+
+ @Override
public Object getMetric() {
return _meter;
}
diff --git
a/pinot-common/src/test/java/org/apache/pinot/common/metrics/MetricsHelperTest.java
b/pinot-common/src/test/java/org/apache/pinot/common/metrics/MetricsHelperTest.java
index 5afe60d..24507c9 100644
---
a/pinot-common/src/test/java/org/apache/pinot/common/metrics/MetricsHelperTest.java
+++
b/pinot-common/src/test/java/org/apache/pinot/common/metrics/MetricsHelperTest.java
@@ -18,15 +18,14 @@
*/
package org.apache.pinot.common.metrics;
-import static org.testng.Assert.assertTrue;
-
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-
import org.apache.pinot.common.exception.InvalidConfigException;
+import org.apache.pinot.spi.metrics.PinotMeter;
import org.apache.pinot.spi.metrics.PinotMetricsRegistry;
import org.apache.pinot.spi.env.PinotConfiguration;
+import org.testng.Assert;
import org.testng.annotations.Test;
@@ -73,7 +72,20 @@ public class MetricsHelperTest {
TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
// Check that the two listeners fired
- assertTrue(listenerOneOkay);
- assertTrue(listenerTwoOkay);
+ Assert.assertTrue(listenerOneOkay);
+ Assert.assertTrue(listenerTwoOkay);
+ }
+
+ @Test
+ public void testMetricValue() {
+ PinotMetricsRegistry registry = PinotMetricUtils.getPinotMetricsRegistry();
+ PinotMeter pinotMeter = MetricsHelper
+ .newMeter(registry,
PinotMetricUtils.generatePinotMetricName(MetricsHelperTest.class, "testMeter"),
"testMeter",
+ TimeUnit.MILLISECONDS);
+ pinotMeter.mark();
+ Assert.assertEquals(pinotMeter.count(), 1L);
+
+ pinotMeter.mark(2L);
+ Assert.assertEquals(pinotMeter.count(), 3L);
}
}
diff --git
a/pinot-spi/src/main/java/org/apache/pinot/spi/metrics/PinotMeter.java
b/pinot-spi/src/main/java/org/apache/pinot/spi/metrics/PinotMeter.java
index f7b9c94..21c4a44 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/metrics/PinotMeter.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/metrics/PinotMeter.java
@@ -20,11 +20,29 @@ package org.apache.pinot.spi.metrics;
/**
* A meter metric which measures mean throughput and one-, five-, and
fifteen-minute
- * exponentially-weighted moving average throughputs.
+ * exponentially-weighted moving average throughput.
*
* @see <a
href="http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average">EMA</a>
*/
public interface PinotMeter {
+
+ /**
+ * Mark the occurrence of an event.
+ */
+ void mark();
+
+ /**
+ * Mark the occurrence of a given number of events.
+ *
+ * @param unitCount the number of events
+ */
void mark(final long unitCount);
+
+ /**
+ * Returns the number of events which have been marked.
+ *
+ * @return the number of events which have been marked
+ */
+ long count();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]