You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by GitBox <gi...@apache.org> on 2018/12/17 17:24:35 UTC

[GitHub] nwangtw closed pull request #3126: Add util function for registerTopologyTimerEvents in Config

nwangtw closed pull request #3126: Add util function for registerTopologyTimerEvents in Config
URL: https://github.com/apache/incubator-heron/pull/3126
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/heron/api/src/java/org/apache/heron/api/Config.java b/heron/api/src/java/org/apache/heron/api/Config.java
index 1607e39451..3ee4b47db1 100644
--- a/heron/api/src/java/org/apache/heron/api/Config.java
+++ b/heron/api/src/java/org/apache/heron/api/Config.java
@@ -630,6 +630,33 @@ public static void setEnvironment(Map<String, Object> conf, Map env) {
     conf.put(Config.TOPOLOGY_ENVIRONMENT, env);
   }
 
+  /**
+   * Registers a timer event that executes periodically
+   * @param conf the map with the existing topology configs
+   * @param name the name of the timer
+   * @param interval the frequency in which to run the task
+   * @param task the task to run
+   */
+  @SuppressWarnings("unchecked")
+  public static void registerTopologyTimerEvents(Map<String, Object> conf,
+                                                 String name, Duration interval,
+                                                 Runnable task) {
+    if (interval.isZero() || interval.isNegative()) {
+      throw new IllegalArgumentException("Timer duration needs to be positive");
+    }
+    if (!conf.containsKey(Config.TOPOLOGY_TIMER_EVENTS)) {
+      conf.put(Config.TOPOLOGY_TIMER_EVENTS, new HashMap<String, Pair<Duration, Runnable>>());
+    }
+
+    Map<String, Pair<Duration, Runnable>> timers
+        = (Map<String, Pair<Duration, Runnable>>) conf.get(Config.TOPOLOGY_TIMER_EVENTS);
+
+    if (timers.containsKey(name)) {
+      throw new IllegalArgumentException("Timer with name " + name + " already exists");
+    }
+    timers.put(name, Pair.of(interval, task));
+  }
+
   public void setDebug(boolean isOn) {
     setDebug(this, isOn);
   }
@@ -811,31 +838,8 @@ public void setMetricsmgrRam(ByteAmount ramInBytes) {
     setMetricsmgrRam(this, ramInBytes);
   }
 
-  /**
-   * Registers a timer event that executes periodically
-   * @param conf the map with the existing topology configs
-   * @param name the name of the timer
-   * @param interval the frequency in which to run the task
-   * @param task the task to run
-   */
-  @SuppressWarnings("unchecked")
-  public static void registerTopologyTimerEvents(Map<String, Object> conf,
-                                                 String name, Duration interval,
-                                                 Runnable task) {
-    if (interval.isZero() || interval.isNegative()) {
-      throw new IllegalArgumentException("Timer duration needs to be positive");
-    }
-    if (!conf.containsKey(Config.TOPOLOGY_TIMER_EVENTS)) {
-      conf.put(Config.TOPOLOGY_TIMER_EVENTS, new HashMap<String, Pair<Duration, Runnable>>());
-    }
-
-    Map<String, Pair<Duration, Runnable>> timers
-        = (Map<String, Pair<Duration, Runnable>>) conf.get(Config.TOPOLOGY_TIMER_EVENTS);
-
-    if (timers.containsKey(name)) {
-      throw new IllegalArgumentException("Timer with name " + name + " already exists");
-    }
-    timers.put(name, Pair.of(interval, task));
+  public void registerTopologyTimerEvents(String name, Duration interval, Runnable task) {
+    registerTopologyTimerEvents(this, name, interval, task);
   }
 
   public void setTopologyRemoteDebugging(boolean isOn) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services