Class StreamPlugThread
java.lang.Object
ecmwf.common.technical.ThreadService.ConfigurableRunnable
ecmwf.common.technical.StreamPlugThread
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
The Class StreamCloseable. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The Constant DEFAULT_BUFF_SIZE. -
Constructor Summary
ConstructorsConstructorDescriptionStreamPlugThread
(InputStream in, OutputStream out) Instantiates a new stream plug thread. -
Method Summary
Modifier and TypeMethodDescriptionboolean
alive()
Alive.void
close()
Close.static void
closeQuietly
(Closeable closeable) Close quietly.static void
closeQuietly
(AutoCloseable closeable) Close quietly.static void
closeQuietly
(Process process) Close quietly.static void
closeQuietly
(ServerSocket serverSocket) Close quietly.static void
closeQuietly
(Socket socket) Close quietly.static void
closeQuietly
(Scanner scanner) Close quietly.void
Configurable run.static long
consume
(InputStream in, int bufferSize) Just consume the input stream, but do nothing with it.static long
copy
(OutputStream out, InputStream in, int bufferSize) Copy.static long
copy
(OutputStream out, InputStream in, int bufferSize, long size) Copy.void
flush()
Flush the underlying output stream.int
Gets the buff size.static String
getExceptionMessage
(String input) Gets the exception message.boolean
getFlush()
Gets the flush.Gets the message.boolean
Gets the read fully.static void
plugTogether
(Socket source, InputStream in, OutputStream out, Closeable toClose) Plug together.static void
plugTogether
(Socket source, Socket target, Closeable... toClose) Plug together.static int
readFully
(InputStream in, byte[] b, int off, int len) Read fully.void
setBuffSize
(int buffSize) Sets the buff size.void
setFlush
(boolean flush) Sets the flush.void
setReadFully
(boolean readFully) Sets the read fully.void
Specify which Closeable object should be closed when the plug is closed.void
Specify which Closeable objects should be closed when the plug is closed.Methods inherited from class ecmwf.common.technical.ThreadService.ConfigurableRunnable
execute, execute, getContextClassLoader, getPriority, getThreadName, interrupt, interrupted, isAlive, isStarted, join, join, run, setContextClassLoader, setForceCookie, setInheritCookie, setPriority, setThreadNameAndCookie
-
Field Details
-
DEFAULT_BUFF_SIZE
public static final int DEFAULT_BUFF_SIZEThe Constant DEFAULT_BUFF_SIZE.
-
-
Constructor Details
-
StreamPlugThread
Instantiates a new stream plug thread.- Parameters:
in
- the inout
- the out
-
-
Method Details
-
setBuffSize
public void setBuffSize(int buffSize) Sets the buff size.- Parameters:
buffSize
- the new buff size
-
getBuffSize
public int getBuffSize()Gets the buff size.- Returns:
- the buff size
-
setFlush
public void setFlush(boolean flush) Sets the flush.- Parameters:
flush
- the new flush
-
getFlush
public boolean getFlush()Gets the flush.- Returns:
- the flush
-
setReadFully
public void setReadFully(boolean readFully) Sets the read fully.- Parameters:
readFully
- the new read fully
-
getReadFully
public boolean getReadFully()Gets the read fully.- Returns:
- the read fully
-
alive
public boolean alive()Alive.- Returns:
- true, if successful
-
close
public void close()Close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getMessage
-
plugTogether
public static void plugTogether(Socket source, Socket target, Closeable... toClose) throws IOException Plug together.- Parameters:
source
- the sourcetarget
- the targettoClose
- the to close- Throws:
IOException
- Signals that an I/O exception has occurred.
-
plugTogether
public static void plugTogether(Socket source, InputStream in, OutputStream out, Closeable toClose) throws IOException Plug together.- Parameters:
source
- the sourcein
- the inout
- the outtoClose
- the to close- Throws:
IOException
- Signals that an I/O exception has occurred.
-
readFully
Read fully.- Parameters:
in
- the inb
- the boff
- the offlen
- the len- Returns:
- the int
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
copy
Copy.- Parameters:
out
- the outin
- the inbufferSize
- the buffer size- Returns:
- the long
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
copy
public static long copy(OutputStream out, InputStream in, int bufferSize, long size) throws IOException Copy.- Parameters:
out
- the outin
- the inbufferSize
- the buffer sizesize
- the size- Returns:
- the long
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
consume
Just consume the input stream, but do nothing with it.- Parameters:
in
- the inbufferSize
- the buffer size- Returns:
- the long
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
closeQuietly
-
closeQuietly
-
closeQuietly
Close quietly.- Parameters:
closeable
- the closeable
-
closeQuietly
Close quietly.- Parameters:
closeable
- the closeable
-
closeQuietly
-
closeQuietly
Close quietly.- Parameters:
serverSocket
- the server socket
-
flush
Flush the underlying output stream.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
configurableRun
public void configurableRun()Configurable run. Configurable run.- Specified by:
configurableRun
in classThreadService.ConfigurableRunnable
-
getExceptionMessage
-
toClose
Specify which Closeable objects should be closed when the plug is closed.- Parameters:
toClose
- the close
-
toClose
Specify which Closeable object should be closed when the plug is closed.- Parameters:
toClose
- the to close
-