public final class SocketSource extends Object implements Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>, ResultTypeQueryable<RowData>
SocketSource
opens a socket and consumes bytes.
It splits records by the given byte delimiter (`\n` by default) and delegates the decoding to
a pluggable DeserializationSchema
.
Note: This is only an example and should not be used in production. The source is not fault-tolerant and can only work with a parallelism of 1.
Modifier and Type | Class and Description |
---|---|
static class |
SocketSource.DummyCheckpoint
Placeholder because the SocketSource does not support fault-tolerance and thus does not
require actual checkpointing.
|
static class |
SocketSource.DummySplit
Placeholder because the socket itself implicitly represents the only split and does not
require an actual split object.
|
Constructor and Description |
---|
SocketSource(String hostname,
int port,
byte byteDelimiter,
DeserializationSchema<RowData> deserializer) |
public SocketSource(String hostname, int port, byte byteDelimiter, DeserializationSchema<RowData> deserializer)
public TypeInformation<RowData> getProducedType()
ResultTypeQueryable
TypeInformation
) produced by this function or input format.getProducedType
in interface ResultTypeQueryable<RowData>
public Boundedness getBoundedness()
Source
getBoundedness
in interface Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>
public SplitEnumerator<SocketSource.DummySplit,SocketSource.DummyCheckpoint> createEnumerator(SplitEnumeratorContext<SocketSource.DummySplit> enumContext) throws Exception
Source
createEnumerator
in interface Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>
enumContext
- The context
for the split enumerator.Exception
- The implementor is free to forward all exceptions directly. Exceptions
thrown from this method cause JobManager failure/recovery.public SplitEnumerator<SocketSource.DummySplit,SocketSource.DummyCheckpoint> restoreEnumerator(SplitEnumeratorContext<SocketSource.DummySplit> enumContext, SocketSource.DummyCheckpoint checkpoint) throws Exception
Source
restoreEnumerator
in interface Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>
enumContext
- The context
for the restored split
enumerator.checkpoint
- The checkpoint to restore the SplitEnumerator from.Exception
- The implementor is free to forward all exceptions directly. Exceptions
thrown from this method cause JobManager failure/recovery.public SimpleVersionedSerializer<SocketSource.DummySplit> getSplitSerializer()
Source
getSplitSerializer
in interface Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>
public SimpleVersionedSerializer<SocketSource.DummyCheckpoint> getEnumeratorCheckpointSerializer()
Source
SplitEnumerator
checkpoint. The serializer is used for
the result of the SplitEnumerator.snapshotState(long)
method.getEnumeratorCheckpointSerializer
in interface Source<RowData,SocketSource.DummySplit,SocketSource.DummyCheckpoint>
public SourceReader<RowData,SocketSource.DummySplit> createReader(SourceReaderContext readerContext) throws Exception
SourceReaderFactory
createReader
in interface SourceReaderFactory<RowData,SocketSource.DummySplit>
readerContext
- The context
for the source reader.Exception
- The implementor is free to forward all exceptions directly. Exceptions
thrown from this method cause task failure/recovery.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.