public class SocketTextStreamFunction extends Object implements SourceFunction<String>
The function strips trailing carriage return characters (\r) when the delimiter is the newline character (\n).
The function can be set to reconnect to the server socket in case that the stream is closed on the server side.
SourceFunction.SourceContext<T>| Constructor and Description |
|---|
SocketTextStreamFunction(String hostname,
int port,
char delimiter,
long maxNumRetries) |
SocketTextStreamFunction(String hostname,
int port,
char delimiter,
long maxNumRetries,
long delayBetweenRetries) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the source.
|
void |
run(SourceFunction.SourceContext<String> ctx)
Starts the source.
|
public SocketTextStreamFunction(String hostname, int port, char delimiter, long maxNumRetries)
public SocketTextStreamFunction(String hostname, int port, char delimiter, long maxNumRetries, long delayBetweenRetries)
public 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.run in interface SourceFunction<String>ctx - The context for interaction with the outside world.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.cancel in interface SourceFunction<String>Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.