public class SocketTextStreamFunction extends RichSourceFunction<String>
SourceFunction.SourceContext<T>| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
SocketTextStreamFunction(String hostname,
int port,
char delimiter,
long maxRetry) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the source.
|
void |
open(org.apache.flink.configuration.Configuration parameters) |
void |
run(SourceFunction.SourceContext<String> ctx)
Starts the source.
|
void |
streamFromSocket(SourceFunction.SourceContext<String> ctx,
Socket socket) |
public SocketTextStreamFunction(String hostname, int port, char delimiter, long maxRetry)
public void open(org.apache.flink.configuration.Configuration parameters)
throws Exception
open in interface org.apache.flink.api.common.functions.RichFunctionopen in class org.apache.flink.api.common.functions.AbstractRichFunctionExceptionpublic void run(SourceFunction.SourceContext<String> ctx) throws Exception
SourceFunctionCollector parameter to emit
elements. Sources that implement
Checkpointed must lock on the
checkpoint lock (using a synchronized block) before updating internal state and/or emitting
elements. Also, the update of state and emission of elements must happen in the same
synchronized block.ctx - The context for interaction with the outside world.Exceptionpublic void streamFromSocket(SourceFunction.SourceContext<String> ctx, Socket socket) throws Exception
Exceptionpublic void cancel()
SourceFunctionSourceFunction.run(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext<T>) method. You need to ensure that the source will break out of this loop. This
can be achieved by having a volatile field "isRunning" that is checked in the loop and that
is set to false in this method.Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.