public abstract class AbstractAsyncServer extends Object implements ProtocolServer
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_IO_WORKER_COUNT |
Constructor and Description |
---|
AbstractAsyncServer() |
Modifier and Type | Method and Description |
---|---|
void |
bind()
Start the server
|
protected void |
configureBootstrap(org.jboss.netty.bootstrap.ServerBootstrap bootstrap)
Configure the bootstrap before it get bound
|
protected Executor |
createBossExecutor()
Create a new
Executor used for dispatch messages to the workers. |
protected abstract org.jboss.netty.channel.ChannelPipelineFactory |
createPipelineFactory(org.jboss.netty.channel.group.ChannelGroup group)
Create ChannelPipelineFactory to use by this Server implementation
|
protected org.jboss.netty.channel.socket.ServerSocketChannelFactory |
createSocketChannelFactory() |
protected Executor |
createWorkerExecutor()
Create a new
Executor used for workers. |
int |
getBacklog()
Return the backlog for the socket
|
int |
getIoWorkerCount()
Return the IO worker thread count to use
|
List<InetSocketAddress> |
getListenAddresses()
Return the ips on which the server listen for connections
|
int |
getTimeout()
Return the read/write timeout in seconds for the socket.
|
boolean |
isBound()
return true if the server is bound
|
void |
setBacklog(int backlog)
Set the Backlog for the socket.
|
void |
setIoWorkerCount(int ioWorker)
Set the IO-worker thread count to use.
|
void |
setListenAddresses(InetSocketAddress... addresses) |
void |
setTimeout(int timeout)
Set the read/write timeout for the server.
|
void |
unbind()
Stop the server
|
public void setListenAddresses(InetSocketAddress... addresses)
public void setIoWorkerCount(int ioWorker)
ioWorker
- public int getIoWorkerCount()
public void bind() throws Exception
ProtocolServer
bind
in interface ProtocolServer
Exception
protected void configureBootstrap(org.jboss.netty.bootstrap.ServerBootstrap bootstrap)
bootstrap
- protected org.jboss.netty.channel.socket.ServerSocketChannelFactory createSocketChannelFactory()
public void unbind()
ProtocolServer
unbind
in interface ProtocolServer
public List<InetSocketAddress> getListenAddresses()
ProtocolServer
getListenAddresses
in interface ProtocolServer
protected abstract org.jboss.netty.channel.ChannelPipelineFactory createPipelineFactory(org.jboss.netty.channel.group.ChannelGroup group)
public void setTimeout(int timeout)
IllegalStateException
if the
server is running.timeout
- public void setBacklog(int backlog)
IllegalStateException
if the server is running.backlog
- public int getBacklog()
ProtocolServer
getBacklog
in interface ProtocolServer
public int getTimeout()
ProtocolServer
getTimeout
in interface ProtocolServer
protected Executor createBossExecutor()
Executor
used for dispatch messages to the workers. One Thread will be used per port which is bound.
This can get overridden if needed, by default it use a Executors.newCachedThreadPool()
protected Executor createWorkerExecutor()
Executor
used for workers. This can get overridden if needed, by default it use a Executors.newCachedThreadPool()
public boolean isBound()
ProtocolServer
isBound
in interface ProtocolServer
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.