You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by zm...@apache.org on 2016/08/22 18:45:42 UTC
aurora git commit: Reduce static method exposure for Stats.
Repository: aurora
Updated Branches:
refs/heads/master 370813f11 -> 9b34a4036
Reduce static method exposure for Stats.
`org.apache.aurora.common.stats.Stats` has several static methods that are not
used in our codebase. This patch deletes the unused methods and reduces the
visability of other static methods where possible.
Reviewed at https://reviews.apache.org/r/51264/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/9b34a403
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/9b34a403
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/9b34a403
Branch: refs/heads/master
Commit: 9b34a4036ab84f560ca80dfce9bdcd831efdeb30
Parents: 370813f
Author: Zameer Manji <zm...@apache.org>
Authored: Mon Aug 22 11:45:18 2016 -0700
Committer: Zameer Manji <zm...@apache.org>
Committed: Mon Aug 22 11:45:18 2016 -0700
----------------------------------------------------------------------
.../org/apache/aurora/common/stats/Stats.java | 81 +++-----------------
1 file changed, 12 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/9b34a403/commons/src/main/java/org/apache/aurora/common/stats/Stats.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/stats/Stats.java b/commons/src/main/java/org/apache/aurora/common/stats/Stats.java
index bb0af69..538e807 100644
--- a/commons/src/main/java/org/apache/aurora/common/stats/Stats.java
+++ b/commons/src/main/java/org/apache/aurora/common/stats/Stats.java
@@ -29,7 +29,6 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.MapMaker;
-import com.google.common.util.concurrent.AtomicDouble;
import org.apache.aurora.common.base.MorePreconditions;
import org.slf4j.Logger;
@@ -192,7 +191,7 @@ public class Stats {
* @return A reference back to {@code var}, or the variable that was already registered under the
* same name as {@code var}.
*/
- public static Stat<String> exportString(Stat<String> var) {
+ static Stat<String> exportString(Stat<String> var) {
return exportStatic(var);
}
@@ -201,20 +200,20 @@ public class Stats {
*
* @param vars The variables to add.
*/
- public static void exportAll(Iterable<Stat<? extends Number>> vars) {
+ static void exportAll(Iterable<Stat<? extends Number>> vars) {
for (Stat<? extends Number> var : vars) {
export(var);
}
}
/**
- * Exports an {@link AtomicInteger}, which will be included in time series tracking.
+ * Creates and exports an {@link AtomicInteger}.
*
* @param name The name to export the stat with.
- * @param intVar The variable to export.
- * @return A reference to the {@link AtomicInteger} provided.
+ * @return A reference to the {@link AtomicInteger} created.
*/
- public static AtomicInteger export(final String name, final AtomicInteger intVar) {
+ public static AtomicInteger exportInt(final String name) {
+ final AtomicInteger intVar = new AtomicInteger(0);
export(new SampledStat<Integer>(name, 0) {
@Override public Integer doSample() { return intVar.get(); }
});
@@ -223,75 +222,18 @@ public class Stats {
}
/**
- * Creates and exports an {@link AtomicInteger}.
- *
- * @param name The name to export the stat with.
- * @return A reference to the {@link AtomicInteger} created.
- */
- public static AtomicInteger exportInt(String name) {
- return exportInt(name, 0);
- }
-
- /**
- * Creates and exports an {@link AtomicInteger} with initial value.
- *
- * @param name The name to export the stat with.
- * @param initialValue The initial stat value.
- * @return A reference to the {@link AtomicInteger} created.
- */
- public static AtomicInteger exportInt(String name, int initialValue) {
- return export(name, new AtomicInteger(initialValue));
- }
-
- /**
- * Exports an {@link AtomicLong}, which will be included in time series tracking.
- *
- * @param name The name to export the stat with.
- * @param longVar The variable to export.
- * @return A reference to the {@link AtomicLong} provided.
- */
- public static AtomicLong export(String name, final AtomicLong longVar) {
- export(new StatImpl<Long>(name) {
- @Override public Long read() { return longVar.get(); }
- });
-
- return longVar;
- }
-
- /**
* Creates and exports an {@link AtomicLong}.
*
* @param name The name to export the stat with.
* @return A reference to the {@link AtomicLong} created.
*/
public static AtomicLong exportLong(String name) {
- return exportLong(name, 0L);
- }
-
- /**
- * Creates and exports an {@link AtomicLong} with initial value.
- *
- * @param name The name to export the stat with.
- * @param initialValue The initial stat value.
- * @return A reference to the {@link AtomicLong} created.
- */
- public static AtomicLong exportLong(String name, long initialValue) {
- return export(name, new AtomicLong(initialValue));
- }
-
- /**
- * Exports an {@link AtomicDouble}, which will be included in time series tracking.
- *
- * @param name The name to export the stat with.
- * @param doubleVar The variable to export.
- * @return A reference to the {@link AtomicDouble} provided.
- */
- public static AtomicDouble export(String name, final AtomicDouble doubleVar) {
- export(new StatImpl<Double>(name) {
- @Override public Double read() { return doubleVar.doubleValue(); }
+ final AtomicLong longVar = new AtomicLong(0L);
+ export(new StatImpl<Long>(name) {
+ @Override public Long read() { return longVar.get(); }
});
- return doubleVar;
+ return longVar;
}
/**
@@ -314,7 +256,7 @@ public class Stats {
* @param var Variable to statically export.
* @return A reference back to the provided {@link Stat}.
*/
- public static <T> Stat<T> exportStatic(Stat<T> var) {
+ static <T> Stat<T> exportStatic(Stat<T> var) {
String validatedName = validateName(MorePreconditions.checkNotBlank(var.getName()));
exportStaticInternal(validatedName, var);
return var;
@@ -346,6 +288,7 @@ public class Stats {
NUMERIC_STATS.invalidateAll();
}
+ @VisibleForTesting
public static <T> Stat<T> getVariable(String name) {
MorePreconditions.checkNotBlank(name);
@SuppressWarnings("unchecked")