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/09/25 23:17:13 UTC
[GitHub] huijunwu closed pull request #3034: Nwang/remove stateful from
streamletoperator
huijunwu closed pull request #3034: Nwang/remove stateful from streamletoperator
URL: https://github.com/apache/incubator-heron/pull/3034
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/streamlet/impl/operators/StreamletOperator.java b/heron/api/src/java/org/apache/heron/streamlet/impl/operators/StreamletOperator.java
index d2451d2f7f..27e6cd00cd 100644
--- a/heron/api/src/java/org/apache/heron/streamlet/impl/operators/StreamletOperator.java
+++ b/heron/api/src/java/org/apache/heron/streamlet/impl/operators/StreamletOperator.java
@@ -20,11 +20,7 @@
package org.apache.heron.streamlet.impl.operators;
-import java.io.Serializable;
-
import org.apache.heron.api.bolt.BaseRichBolt;
-import org.apache.heron.api.state.State;
-import org.apache.heron.api.topology.IStatefulComponent;
import org.apache.heron.api.topology.OutputFieldsDeclarer;
import org.apache.heron.api.tuple.Fields;
@@ -32,17 +28,10 @@
* The Bolt interface that other operators of the streamlet packages extend.
* The only common stuff amongst all of them is the output streams
*/
-public abstract class StreamletOperator extends BaseRichBolt
- implements IStatefulComponent<Serializable, Serializable> {
+public abstract class StreamletOperator extends BaseRichBolt {
private static final long serialVersionUID = 8524238140745238942L;
private static final String OUTPUT_FIELD_NAME = "output";
- @Override
- public void initState(State<Serializable, Serializable> state) { }
-
- @Override
- public void preSave(String checkpointId) { }
-
/**
* The operators implementing streamlet functionality have some properties.
* 1. They all output only one stream
diff --git a/heron/api/src/java/org/apache/heron/streamlet/impl/operators/TransformOperator.java b/heron/api/src/java/org/apache/heron/streamlet/impl/operators/TransformOperator.java
index b552680597..e588f8bc99 100644
--- a/heron/api/src/java/org/apache/heron/streamlet/impl/operators/TransformOperator.java
+++ b/heron/api/src/java/org/apache/heron/streamlet/impl/operators/TransformOperator.java
@@ -25,6 +25,7 @@
import org.apache.heron.api.bolt.OutputCollector;
import org.apache.heron.api.state.State;
+import org.apache.heron.api.topology.IStatefulComponent;
import org.apache.heron.api.topology.TopologyContext;
import org.apache.heron.api.tuple.Tuple;
import org.apache.heron.api.tuple.Values;
@@ -38,7 +39,8 @@
* It calls the transformFunction setup/cleanup at the beginning/end of the
* processing. And for every tuple, it applies the transformFunction, and emits the resulting value
*/
-public class TransformOperator<R, T> extends StreamletOperator {
+public class TransformOperator<R, T> extends StreamletOperator
+ implements IStatefulComponent<Serializable, Serializable> {
private static final long serialVersionUID = 429297144878185182L;
private SerializableTransformer<? super R, ? extends T> serializableTransformer;
@@ -55,6 +57,10 @@ public void initState(State<Serializable, Serializable> startupState) {
this.state = startupState;
}
+ @Override
+ public void preSave(String checkpointId) {
+ }
+
@Override
public void cleanup() {
serializableTransformer.cleanup();
@@ -62,7 +68,8 @@ public void cleanup() {
@SuppressWarnings("rawtypes")
@Override
- public void prepare(Map<String, Object> map, TopologyContext topologyContext,
+ public void prepare(Map<String, Object> map,
+ TopologyContext topologyContext,
OutputCollector outputCollector) {
collector = outputCollector;
Context context = new ContextImpl(topologyContext, map, state);
diff --git a/heron/api/src/java/org/apache/heron/streamlet/impl/sinks/ComplexSink.java b/heron/api/src/java/org/apache/heron/streamlet/impl/sinks/ComplexSink.java
index 0b4a6b5151..ab4dbc4cd4 100644
--- a/heron/api/src/java/org/apache/heron/streamlet/impl/sinks/ComplexSink.java
+++ b/heron/api/src/java/org/apache/heron/streamlet/impl/sinks/ComplexSink.java
@@ -25,6 +25,7 @@
import org.apache.heron.api.bolt.OutputCollector;
import org.apache.heron.api.state.State;
+import org.apache.heron.api.topology.IStatefulComponent;
import org.apache.heron.api.topology.TopologyContext;
import org.apache.heron.api.tuple.Tuple;
import org.apache.heron.streamlet.Context;
@@ -36,7 +37,8 @@
* ConsumerSink is a very simple Sink that basically invokes a user supplied
* consume function for every tuple.
*/
-public class ComplexSink<R> extends StreamletOperator {
+public class ComplexSink<R> extends StreamletOperator
+ implements IStatefulComponent<Serializable, Serializable> {
private static final long serialVersionUID = 8717991188885786658L;
private Sink<R> sink;
private OutputCollector collector;
@@ -51,6 +53,10 @@ public void initState(State<Serializable, Serializable> startupState) {
this.state = startupState;
}
+ @Override
+ public void preSave(String checkpointId) {
+ }
+
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map<String, Object> map, TopologyContext topologyContext,
----------------------------------------------------------------
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