[NO ISSUE][HYR] Support modifying Tracer categories after init
Change-Id: Id209ade0cd20022ad9ae2c9d0c49689081f112a7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2105
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/ITracer.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/ITracer.java
index 4f1c2b9..908dc1c 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/ITracer.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/ITracer.java
@@ -63,6 +63,11 @@
}
@Override
+ public void setCategories(String... categories) {
+ // nothing to do here
+ }
+
+ @Override
public boolean isEnabled(long cat) {
return false;
}
@@ -92,6 +97,8 @@
ITraceCategoryRegistry getRegistry();
+ void setCategories(String... categories);
+
boolean isEnabled(long cat);
long durationB(String name, long cat, String args);
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
index 72a9989..4c6f234 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
@@ -57,6 +57,10 @@
public Tracer(String name, String[] categories, TraceCategoryRegistry registry) {
this(name, ITraceCategoryRegistry.CATEGORIES_ALL, registry);
+ setCategories(categories);
+ }
+
+ public void setCategories(String... categories) {
LOGGER.info("Set categories for Tracer " + this.traceLog.getName() + " to " + Arrays.toString(categories));
this.categories = getRegistry().get(categories);
}
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java b/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
index 4b36013..02bf41c 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
@@ -74,5 +74,17 @@
for (String line : lines) {
Assert.assertFalse(validate(line).get("cat").equals("CAT3"));
}
+ tracer.setCategories("CAT1", "CAT3");
+ os.reset();
+
+ tracer.instant("test1", cat1, ITracer.Scope.p, null);
+ tracer.instant("test2", cat2, ITracer.Scope.p, null);
+ tracer.instant("test3", cat3, ITracer.Scope.p, null);
+
+ handler.flush();
+ lines = os.toString().split("\n");
+ for (String line : lines) {
+ Assert.assertFalse(validate(line).get("cat").equals("CAT2"));
+ }
}
}