flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljoscha <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-1977] Rework Stream Operators to always...
Date Thu, 07 May 2015 14:08:17 GMT
Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/659#discussion_r29854686
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/operators/StreamSource.java
---
    @@ -17,33 +17,56 @@
     
     package org.apache.flink.streaming.api.operators;
     
    -import java.io.Serializable;
    +import java.util.Timer;
     
    -import org.apache.flink.streaming.api.functions.source.SourceFunction;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.streaming.api.functions.source.Source;
     
    -public class StreamSource<OUT> extends StreamOperator<OUT, OUT> implements
Serializable {
    +public class StreamSource<OUT> extends AbstractUdfStreamOperator<OUT, Source<OUT>>
implements StreamOperator<OUT> {
     
    -	private static final long serialVersionUID = 1L;
    +	private transient Timer timer;
    +	private boolean isRunning = true;
     
    -	public StreamSource(SourceFunction<OUT> sourceFunction) {
    +	public StreamSource(Source<OUT> sourceFunction) {
     		super(sourceFunction);
     	}
     
    -	@Override
    -	public void run() {
    -		callUserFunctionAndLogException();
    +	public void run() throws Exception {
    +		while (isRunning) {
    +
    +			synchronized (userFunction) {
    +				if (userFunction.reachedEnd()) {
    +					break;
    +				}
    +
    +				OUT result = userFunction.next();
    +
    +				output.collect(result);
    +			}
    +			Thread.yield();
    +		}
     	}
     
     	@Override
    -	@SuppressWarnings("unchecked")
    -	protected void callUserFunction() throws Exception {
    -		((SourceFunction<OUT>) userFunction).run(collector);
    +	public void open(Configuration parameters) throws Exception {
    +		super.open(parameters);
    +		timer = new Timer("punctuation timer");
    +//		timer.scheduleAtFixedRate(new TimerTask() {
    +//			@Override
    +//			public void run() {
    +//				synchronized (userFunction) {
    +//					Instant watermark = userFunction.getLowWatermark();
    +//					System.out.println("Emitting watermark: " + watermark);
    +//				}
    +//			}
    +//		}, 0, Duration.standardSeconds(1).getMillis());
    --- End diff --
    
    Leftover, since I started this whole thing to add watermarks. I could leave it in, since
in my upcoming work I will use this? :sweat_smile: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message