heron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] jerrypeng closed pull request #2832: allow storm topologies to use the heron state interface
Date Tue, 03 Apr 2018 01:52:41 GMT
jerrypeng closed pull request #2832: allow storm topologies to use the heron state interface
URL: https://github.com/apache/incubator-heron/pull/2832
 
 
   

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/storm-compatibility/src/java/org/apache/storm/topology/TopologyBuilder.java b/storm-compatibility/src/java/org/apache/storm/topology/TopologyBuilder.java
index a9594a0faa..aa90708f3c 100644
--- a/storm-compatibility/src/java/org/apache/storm/topology/TopologyBuilder.java
+++ b/storm-compatibility/src/java/org/apache/storm/topology/TopologyBuilder.java
@@ -25,6 +25,7 @@
 
 import com.twitter.heron.api.HeronTopology;
 import com.twitter.heron.api.bolt.WindowedBoltExecutor;
+import com.twitter.heron.api.topology.IStatefulComponent;
 
 public class TopologyBuilder {
   private com.twitter.heron.api.topology.TopologyBuilder delegate =
@@ -40,9 +41,14 @@ public BoltDeclarer setBolt(String id, IRichBolt bolt) {
   }
 
   public BoltDeclarer setBolt(String id, IRichBolt bolt, Number parallelismHint) {
-    IRichBoltDelegate boltImpl = new IRichBoltDelegate(bolt);
-    com.twitter.heron.api.topology.BoltDeclarer declarer =
-        delegate.setBolt(id, boltImpl, parallelismHint);
+    com.twitter.heron.api.bolt.IRichBolt boltImpl;
+    if (bolt instanceof IStatefulComponent) {
+      boltImpl = new IRichStatefulBoltDelagate(bolt);
+    } else {
+      boltImpl = new IRichBoltDelegate(bolt);
+    }
+    com.twitter.heron.api.topology.BoltDeclarer declarer
+        = delegate.setBolt(id, boltImpl, parallelismHint);;
     return new BoltDeclarerImpl(declarer);
   }
 
@@ -72,9 +78,14 @@ public SpoutDeclarer setSpout(String id, IRichSpout spout) {
   }
 
   public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelismHint) {
-    IRichSpoutDelegate spoutImpl = new IRichSpoutDelegate(spout);
-    com.twitter.heron.api.topology.SpoutDeclarer declarer =
-        delegate.setSpout(id, spoutImpl, parallelismHint);
+    com.twitter.heron.api.spout.IRichSpout spoutImpl;
+    if (spout instanceof IStatefulComponent) {
+      spoutImpl = new IRichStatefulSpoutDelegate(spout);
+    } else {
+      spoutImpl = new IRichSpoutDelegate(spout);
+    }
+    com.twitter.heron.api.topology.SpoutDeclarer declarer
+        = delegate.setSpout(id, spoutImpl, parallelismHint);
     return new SpoutDeclarerImpl(declarer);
   }
 }
diff --git a/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java b/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
index 614d43f8d8..7dcd6721d6 100644
--- a/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
+++ b/storm-compatibility/src/java/org/apache/storm/utils/ConfigUtils.java
@@ -174,19 +174,21 @@ private static void doStormTranslation(Config heronConfig) {
    * @param heron the heron config object to receive the results.
    */
   private static void doTopologyLevelTranslation(Config heronConfig) {
-    if (heronConfig.containsKey(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS)) {
-      Integer nAckers =
-          Utils.getInt(heronConfig.get(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS));
-      if (nAckers > 0) {
-        com.twitter.heron.api.Config.setTopologyReliabilityMode(heronConfig,
-                 com.twitter.heron.api.Config.TopologyReliabilityMode.ATLEAST_ONCE);
+    if (!heronConfig.containsKey(Config.TOPOLOGY_RELIABILITY_MODE)) {
+      if (heronConfig.containsKey(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS)) {
+        Integer nAckers =
+            Utils.getInt(heronConfig.get(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS));
+        if (nAckers > 0) {
+          com.twitter.heron.api.Config.setTopologyReliabilityMode(heronConfig,
+              com.twitter.heron.api.Config.TopologyReliabilityMode.ATLEAST_ONCE);
+        } else {
+          com.twitter.heron.api.Config.setTopologyReliabilityMode(heronConfig,
+              com.twitter.heron.api.Config.TopologyReliabilityMode.ATMOST_ONCE);
+        }
       } else {
         com.twitter.heron.api.Config.setTopologyReliabilityMode(heronConfig,
-                 com.twitter.heron.api.Config.TopologyReliabilityMode.ATMOST_ONCE);
+            com.twitter.heron.api.Config.TopologyReliabilityMode.ATMOST_ONCE);
       }
-    } else {
-      com.twitter.heron.api.Config.setTopologyReliabilityMode(heronConfig,
-               com.twitter.heron.api.Config.TopologyReliabilityMode.ATMOST_ONCE);
     }
   }
 }


 

----------------------------------------------------------------
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

Mime
View raw message