Class SurefireForkChannel
java.lang.Object
org.apache.maven.surefire.extensions.ForkChannel
org.apache.maven.plugin.surefire.extensions.SurefireForkChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
The TCP/IP server accepting only one client connection. The forked JVM connects to the server using the
The objects
The channel is closed after the forked JVM has finished normally or the shutdown hook is executed in the plugin.
connection string
.
The main purpose of this class is to conect with tthe client
, bind the
command reader
to the internal socket's
InputStream
, and bind the
event handler
writing the event
objects to the event handler
.
The objects
WritableByteChannel
and ReadableByteChannel
are forked process streams
(standard input and output). Both are ignored in this implementation but they are used in LegacyForkChannel
.
The channel is closed after the forked JVM has finished normally or the shutdown hook is executed in the plugin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SurefireForkChannel.Bindings
private CloseableDaemonThread
private CloseableDaemonThread
private final String
private final int
private LineConsumerThread
private final AsynchronousServerSocketChannel
private Future<AsynchronousSocketChannel>
private final String
private static final ExecutorService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindCommandReader
(CommandReader commands, WritableByteChannel stdIn) Binds command handler to the channel.void
bindEventHandler
(EventHandler<Event> eventHandler, CountdownCloseable countdown, ReadableByteChannel stdOut) Starts a Thread reading the events.void
close()
void
disable()
private AsynchronousSocketChannel
int
the permits inCountdownCloseable
.This is server related class, which if binds to a TCP port, determines the connection string for the client.private final void
setTrueOptions
(SocketOption<Boolean>... options) void
Asynchronously connects to the client.private void
Methods inherited from class org.apache.maven.surefire.extensions.ForkChannel
getArguments
-
Field Details
-
THREAD_POOL
-
server
-
localHost
-
localPort
private final int localPort -
sessionId
-
bindings
-
session
-
out
-
commandReaderBindings
-
eventHandlerBindings
-
eventBindings
-
commandBindings
-
-
Constructor Details
-
SurefireForkChannel
SurefireForkChannel(@Nonnull ForkNodeArguments arguments) throws IOException - Throws:
IOException
-
-
Method Details
-
tryConnectToClient
public void tryConnectToClient()Description copied from class:ForkChannel
Asynchronously connects to the client.- Specified by:
tryConnectToClient
in classForkChannel
-
getForkNodeConnectionString
Description copied from class:ForkChannel
This is server related class, which if binds to a TCP port, determines the connection string for the client.- Specified by:
getForkNodeConnectionString
in classForkChannel
- Returns:
- a connection string utilized by the client in the fork JVM
-
getCountdownCloseablePermits
public int getCountdownCloseablePermits()Description copied from class:ForkChannel
the permits inCountdownCloseable
.- Specified by:
getCountdownCloseablePermits
in classForkChannel
-
bindCommandReader
public void bindCommandReader(@Nonnull CommandReader commands, WritableByteChannel stdIn) throws IOException, InterruptedException Description copied from class:ForkChannel
Binds command handler to the channel. Starts a Thread streaming out the commands.- Specified by:
bindCommandReader
in classForkChannel
- Parameters:
commands
- command reader, seeCommandReader.readNextCommand()
stdIn
- optional standard input stream of the JVM to write the encoded commands into it- Throws:
IOException
- if an error in the fork channelInterruptedException
- channel interrupted
-
bindEventHandler
public void bindEventHandler(@Nonnull EventHandler<Event> eventHandler, @Nonnull CountdownCloseable countdown, ReadableByteChannel stdOut) throws IOException, InterruptedException Description copied from class:ForkChannel
Starts a Thread reading the events.- Specified by:
bindEventHandler
in classForkChannel
- Parameters:
eventHandler
- event eventHandlercountdown
- count down of the final call ofCloseable.close()
stdOut
- optional standard output stream of the JVM- Throws:
IOException
- if an error in the fork channelInterruptedException
- channel interrupted
-
disable
public void disable()- Specified by:
disable
in classForkChannel
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classForkChannel
- Throws:
IOException
-
verifySessionId
- Throws:
InterruptedException
IOException
-
setTrueOptions
- Throws:
IOException
-
getChannel
- Throws:
InterruptedException
IOException
-