Skip to content

Commit

Permalink
Issue #3136 Allow acceptor threads
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Wilkins <[email protected]>
  • Loading branch information
gregw committed Nov 22, 2018
1 parent 910665a commit 065cccd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,32 @@ public UnixSocketConnector(
this(server, null, null, null, -1, AbstractConnectionFactory.getFactories(sslContextFactory, factories));
}

/** Generic Server Connection.
* @param server
* The server this connector will be accept connection for.
* @param executor
* An executor used to run tasks for handling requests, acceptors and selectors.
* If null then use the servers executor
* @param scheduler
* A scheduler used to schedule timeouts. If null then use the servers scheduler
* @param bufferPool
* A ByteBuffer pool used to allocate buffers. If null then create a private pool with default configuration.
* @param selectors
* the number of selector threads, or &lt;=0 for a default value(1). Selectors notice and schedule established connection that can make IO progress.
* @param factories
* Zero or more {@link ConnectionFactory} instances used to create and configure connections.
*/
public UnixSocketConnector(
@Name("server") Server server,
@Name("executor") Executor executor,
@Name("scheduler") Scheduler scheduler,
@Name("bufferPool") ByteBufferPool bufferPool,
@Name("selectors") int selectors,
@Name("factories") ConnectionFactory... factories)
{
this(server, executor, scheduler, bufferPool, 0, selectors, factories);
}

/** Generic Server Connection.
* @param server
* The server this connector will be accept connection for.
Expand All @@ -178,6 +204,8 @@ public UnixSocketConnector(
* A scheduler used to schedule timeouts. If null then use the servers scheduler
* @param bufferPool
* A ByteBuffer pool used to allocate buffers. If null then create a private pool with default configuration.
* @param acceptors
* the number of acceptor threads, or &lt;=0 for a default value(1). Acceptors accept new connections. If there are no acceptors, then accepting is done asynchronously by the selector.
* @param selectors
* the number of selector threads, or &lt;=0 for a default value(1). Selectors notice and schedule established connection that can make IO progress.
* @param factories
Expand All @@ -188,14 +216,14 @@ public UnixSocketConnector(
@Name("executor") Executor executor,
@Name("scheduler") Scheduler scheduler,
@Name("bufferPool") ByteBufferPool bufferPool,
@Name("acceptors") int acceptors,
@Name("selectors") int selectors,
@Name("factories") ConnectionFactory... factories)
{
super(server,executor,scheduler,bufferPool,0,factories);
super(server,executor,scheduler,bufferPool,acceptors,factories);
_manager = newSelectorManager(getExecutor(), getScheduler(),
selectors>0?selectors:1);
addBean(_manager, true);
setAcceptorPriorityDelta(-2);
}

@ManagedAttribute
Expand Down Expand Up @@ -307,7 +335,7 @@ public void close()
@Override
public void accept(int acceptorID) throws IOException
{
LOG.debug("Blocking UnixSocket accept used. Might not be able to be interrupted!");
LOG.warn("Blocking UnixSocket accept used. Might not be able to be interrupted!");
UnixServerSocketChannel serverChannel = _acceptChannel;
if (serverChannel != null && serverChannel.isOpen())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ protected void doNonErrorHandle( String target, Request baseRequest, HttpServlet
log.debug( "response from server: {}", contentResponse.getContentAsString() );

assertThat(contentResponse.getContentAsString(), containsString( "Hello World" ));
log.info( "UnixSocketTest: complete" );
}

@Test
Expand Down

0 comments on commit 065cccd

Please sign in to comment.