This is an automated email from the ASF dual-hosted git repository.
nwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push:
new eec8be6 Add SimulatorRunner for Streamlet API in Simulator package
(#3336)
eec8be6 is described below
commit eec8be6eaf20c85ed9b1a1801fc02a7ffaeb413b
Author: Ning Wang <[email protected]>
AuthorDate: Wed Sep 4 00:53:59 2019 -0700
Add SimulatorRunner for Streamlet API in Simulator package (#3336)
* Add SimulatorRunner in Streamlet API
* remove unused imports
---
heron/simulator/src/java/BUILD | 2 +-
.../apache/heron/simulator/SimulatorRunner.java | 49 ++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/heron/simulator/src/java/BUILD b/heron/simulator/src/java/BUILD
index 232e170..84569b3 100644
--- a/heron/simulator/src/java/BUILD
+++ b/heron/simulator/src/java/BUILD
@@ -14,7 +14,7 @@ java_doc(
simulator_deps_files = \
heron_java_proto_files() + [
- "//heron/api/src/java:api-java-low-level",
+ "//heron/api/src/java:api-java-low-level-functional",
"//heron/common/src/java:basics-java",
"//heron/common/src/java:config-java",
"//heron/common/src/java:utils-java",
diff --git
a/heron/simulator/src/java/org/apache/heron/simulator/SimulatorRunner.java
b/heron/simulator/src/java/org/apache/heron/simulator/SimulatorRunner.java
new file mode 100644
index 0000000..cfffa9f
--- /dev/null
+++ b/heron/simulator/src/java/org/apache/heron/simulator/SimulatorRunner.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.heron.simulator;
+
+import org.apache.heron.api.topology.TopologyBuilder;
+import org.apache.heron.streamlet.Builder;
+import org.apache.heron.streamlet.Config;
+import org.apache.heron.streamlet.impl.BuilderImpl;
+
+/**
+ * SimulatorRunner is used to run a topology with Heron simulator.
+ */
+public final class SimulatorRunner {
+ public SimulatorRunner() { }
+
+ /**
+ * Runs the computation
+ * @param name The name of the topology
+ * @param config Any config that is passed to the topology
+ * @param builder The builder used to keep track of the sources.
+ */
+ public void run(String name, Config config, Builder builder) {
+ BuilderImpl bldr = (BuilderImpl) builder;
+ TopologyBuilder topologyBuilder = bldr.build();
+
+ Simulator simulator = new Simulator();
+ simulator.submitTopology(name,
+ config.getHeronConfig(),
+ topologyBuilder.createTopology());
+ }
+}