public class SocketReceiver<T> extends Receiver<T> implements Logging
Constructor and Description |
---|
SocketReceiver(String host,
int port,
scala.Function1<java.io.InputStream,scala.collection.Iterator<T>> bytesToObjects,
StorageLevel storageLevel,
scala.reflect.ClassTag<T> evidence$2) |
Modifier and Type | Method and Description |
---|---|
static scala.collection.Iterator<String> |
bytesToLines(java.io.InputStream inputStream)
This methods translates the data from an inputstream (say, from a socket)
to '\n' delimited strings and returns an iterator to access the strings.
|
void |
onStart()
This method is called by the system when the receiver is started.
|
void |
onStop()
This method is called by the system when the receiver is stopped.
|
void |
receive()
Create a socket connection and receive data until receiver is stopped
|
attachExecutor, executor_, isStarted, isStopped, preferredLocation, reportError, restart, restart, restart, setReceiverId, stop, stop, storageLevel, store, store, store, store, store, store, store, store, store, streamId
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public SocketReceiver(String host, int port, scala.Function1<java.io.InputStream,scala.collection.Iterator<T>> bytesToObjects, StorageLevel storageLevel, scala.reflect.ClassTag<T> evidence$2)
public static scala.collection.Iterator<String> bytesToLines(java.io.InputStream inputStream)
public void onStart()
Receiver
store(data)
.
If there are errors in threads started here, then following options can be done
(i) reportError(...)
can be called to report the error to the driver.
The receiving of data will continue uninterrupted.
(ii) stop(...)
can be called to stop receiving data. This will call onStop()
to
clear up all resources allocated (threads, buffers, etc.) during onStart()
.
(iii) restart(...)
can be called to restart the receiver. This will call onStop()
immediately, and then onStart()
after a delay.
public void onStop()
Receiver
onStart()
must be cleaned up in this method.public void receive()