phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From karanmehta93 <...@git.apache.org>
Subject [GitHub] phoenix pull request #315: PHOENIX-3655 Global Phoenix Client Metrics for PQ...
Date Fri, 27 Jul 2018 21:13:14 GMT
Github user karanmehta93 commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/315#discussion_r205901029
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
---
    @@ -204,6 +219,39 @@ private static void resetGlobalMetrics() {
             }
         }
     
    +    private boolean verifyMetricsFromSink() throws InterruptedException {
    +        Map<String, Long> expectedMetrics = new HashMap<>();
    +        for (GlobalMetric m : PhoenixRuntime.getGlobalPhoenixClientMetrics()) {
    +            expectedMetrics.put(m.getMetricType().name(), m.getTotalSum());
    +        }
    +
    +        for (int i = 0; i < MAX_RETRIES; i++) {
    +            LOG.info("Verifying Global Metrics from Hadoop Sink, Retry: " + (i + 1));
    +            if (verifyMetricsFromSinkOnce(expectedMetrics)) {
    +                LOG.info("Values from Hadoop Metrics Sink match actual values");
    +                return true;
    +            }
    +            Thread.sleep(1000);
    +        }
    +        return false;
    +    }
    +
    +    private boolean verifyMetricsFromSinkOnce(Map<String, Long> expectedMetrics)
{
    +        synchronized (GlobalPhoenixMetricsTestSink.lock) {
    +            for (AbstractMetric metric : GlobalPhoenixMetricsTestSink.metrics) {
    +                if (expectedMetrics.containsKey(metric.name())) {
    --- End diff --
    
    I will also soon add a test that disables these metrics as well.
    > I'd switch this around to iterate over your expectations, ensuring that they all
exist.
    
    The reason why I didn't do it that way because I didn't wanted to iterate over the it
for every expected metric. It doesn't really matter since its a test though. One approach
can be to remove each entry from the map and check if the size is 0 at the end. How does that
sound?


---

Mime
View raw message