[NO ISSUE][RT] Minor interface refactoring for IActiveEventListener
- user model changes: no
- storage format changes: no
- interface changes: yes
Details:
Add getStatsName() method for IActiveEventListener to enable different
activeEventListeners to provide customized label for their stats.
Change-Id: Ife21078aa06bb14c2c733b48f3eaa8e02b9be905
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2003
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/IActiveEntityEventsListener.java b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/IActiveEntityEventsListener.java
index 03b0cfc..37120e4 100644
--- a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/IActiveEntityEventsListener.java
+++ b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/IActiveEntityEventsListener.java
@@ -96,4 +96,10 @@
* Get the job failure for the last failed run
*/
Exception getJobFailure();
+
+ /**
+ * Get the stats name that's used to form the stats JSON for the active entity
+ * @return the customized stats name for current active entity
+ */
+ String getDisplayName() throws HyracksDataException;
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ActiveStatsApiServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ActiveStatsApiServlet.java
index 15f0ace..9e085a3 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ActiveStatsApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/ActiveStatsApiServlet.java
@@ -44,7 +44,7 @@
private static final int DEFAULT_EXPIRE_TIME = 2000;
private final ActiveNotificationHandler activeNotificationHandler;
- public ActiveStatsApiServlet(ConcurrentMap<String, Object> ctx, String[] paths, ICcApplicationContext appCtx) {
+ public ActiveStatsApiServlet(ICcApplicationContext appCtx, ConcurrentMap<String, Object> ctx, String... paths) {
super(ctx, paths);
this.activeNotificationHandler = (ActiveNotificationHandler) appCtx.getActiveNotificationHandler();
}
@@ -80,7 +80,7 @@
}
long currentTime = System.currentTimeMillis();
for (int iter1 = 0; iter1 < listeners.length; iter1++) {
- resNode.putPOJO(listeners[iter1].getEntityId().toString(),
+ resNode.putPOJO(listeners[iter1].getDisplayName(),
constructNode(om, listeners[iter1], currentTime, expireTime));
}
// Construct Response
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
index 368c2da..c1e772c 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
@@ -553,4 +553,9 @@
getDatasets().add(dataset);
}
}
+
+ @Override
+ public String getDisplayName() throws HyracksDataException {
+ return this.getEntityId().toString();
+ }
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
index 3870065..96cfe91 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
@@ -319,7 +319,7 @@
case Servlets.DIAGNOSTICS:
return new DiagnosticsApiServlet(appCtx, ctx, paths);
case Servlets.ACTIVE_STATS:
- return new ActiveStatsApiServlet(ctx, paths, appCtx);
+ return new ActiveStatsApiServlet(appCtx, ctx, paths);
default:
throw new IllegalStateException(String.valueOf(key));
}