You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2019/10/28 20:53:37 UTC
[helix] branch wagedRebalancer updated: Implement increment()
method in CountMetric class. (#537)
This is an automated email from the ASF dual-hosted git repository.
jiajunwang pushed a commit to branch wagedRebalancer
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/wagedRebalancer by this push:
new 9f41adb Implement increment() method in CountMetric class. (#537)
9f41adb is described below
commit 9f41adbabbbf0c5c2b70e5878595c15812fb457e
Author: Huizhi L <ih...@gmail.com>
AuthorDate: Mon Oct 28 13:53:32 2019 -0700
Implement increment() method in CountMetric class. (#537)
Abstract method increaseCount() in CountMetric is a generic method used in inherited classes. We should implement this method in CountMetric to reduce duplicate code in inherited classes.
Change list:
1. Move increaseCount() to CountMetric.
2. Change the name to increment() and implement the method.
---
.../rebalancer/waged/WagedRebalancer.java | 6 +++---
.../metrics/implementation/RebalanceCounter.java | 7 +-----
.../implementation/RebalanceFailureCount.java | 25 +++++++++++++++++-----
.../monitoring/metrics/model/CountMetric.java | 4 +++-
4 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
index 9dacfbe..1e96b1e 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
@@ -185,7 +185,7 @@ public class WagedRebalancer {
CountMetric rebalanceFailureCount = _metricCollector.getMetric(
WagedRebalancerMetricCollector.WagedRebalancerMetricNames.RebalanceFailureCounter.name(),
CountMetric.class);
- rebalanceFailureCount.increaseCount(1L);
+ rebalanceFailureCount.increment(1L);
HelixRebalanceException.Type failureType = ex.getFailureType();
if (failureType.equals(HelixRebalanceException.Type.INVALID_REBALANCER_STATUS) || failureType
@@ -332,7 +332,7 @@ public class WagedRebalancer {
CountMetric globalBaselineCalcCounter = _metricCollector.getMetric(
WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcCounter.name(),
CountMetric.class);
- globalBaselineCalcCounter.increaseCount(1L);
+ globalBaselineCalcCounter.increment(1L);
LatencyMetric globalBaselineCalcLatency = _metricCollector.getMetric(
WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcLatencyGauge
@@ -379,7 +379,7 @@ public class WagedRebalancer {
CountMetric partialRebalanceCounter = _metricCollector.getMetric(
WagedRebalancerMetricCollector.WagedRebalancerMetricNames.PartialRebalanceCounter.name(),
CountMetric.class);
- partialRebalanceCounter.increaseCount(1L);
+ partialRebalanceCounter.increment(1L);
LatencyMetric partialRebalanceLatency = _metricCollector.getMetric(
WagedRebalancerMetricCollector.WagedRebalancerMetricNames.PartialRebalanceLatencyGauge
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceCounter.java b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceCounter.java
index fc370a8..8ecce7c 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceCounter.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceCounter.java
@@ -27,15 +27,10 @@ import org.apache.helix.monitoring.metrics.model.CountMetric;
*/
public class RebalanceCounter extends CountMetric {
/**
- * Instantiates a new count metric.
+ * Instantiates a new rebalance count metric.
* @param metricName the metric name
*/
public RebalanceCounter(String metricName) {
super(metricName, 0L);
}
-
- @Override
- public void increaseCount(long count) {
- updateValue(getValue() + count);
- }
}
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceFailureCount.java b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceFailureCount.java
index 3764645..fd335f2 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceFailureCount.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceFailureCount.java
@@ -1,7 +1,27 @@
package org.apache.helix.monitoring.metrics.implementation;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
import org.apache.helix.monitoring.metrics.model.CountMetric;
+
public class RebalanceFailureCount extends CountMetric {
/**
* Instantiates a new Simple dynamic metric.
@@ -11,9 +31,4 @@ public class RebalanceFailureCount extends CountMetric {
public RebalanceFailureCount(String metricName) {
super(metricName, 0L);
}
-
- @Override
- public void increaseCount(long count) {
- updateValue(getValue() + count);
- }
}
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/model/CountMetric.java b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/model/CountMetric.java
index 81aa001..c64f761 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/metrics/model/CountMetric.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/metrics/model/CountMetric.java
@@ -43,7 +43,9 @@ public abstract class CountMetric extends SimpleDynamicMetric<Long> implements M
*
* @param count
*/
- public abstract void increaseCount(long count);
+ public void increment(long count) {
+ updateValue(getValue() + count);
+ }
@Override
public String getMetricName() {