public class CommunicationServer extends Object
| Modifier and Type | Field and Description |
|---|---|
protected io.netty.bootstrap.ServerBootstrap |
bootstrap
netty bootstrap
|
protected io.netty.channel.EventLoopGroup |
bossGroup
netty io thread pool
|
protected List<ThreadPool> |
customThreadPools |
protected String |
host
host to bind
|
protected int |
port
port to bind
|
protected Protocol |
protocol |
protected RpcServerOptions |
rpcServerOptions |
protected ServerStatus |
serverStatus |
protected List<Object> |
serviceList |
protected ServiceManager |
serviceManager |
protected AtomicBoolean |
stop |
protected ThreadPool |
threadPool |
protected io.netty.util.Timer |
timeoutTimer |
protected io.netty.channel.EventLoopGroup |
workerGroup |
| Constructor and Description |
|---|
CommunicationServer(int port) |
CommunicationServer(int port,
RpcServerOptions options) |
CommunicationServer(String host,
int port) |
CommunicationServer(String host,
int port,
RpcServerOptions options) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Request request,
Response response) |
Protocol |
getProtocol() |
boolean |
isShutdown() |
void |
registerService(Object service) |
void |
registerService(Object service,
Class targetClass,
NamingOptions namingOptions) |
void |
registerService(Object service,
Class targetClass,
NamingOptions namingOptions,
RpcServerOptions serverOptions)
register service which can be accessed by client
|
void |
registerService(Object service,
NamingOptions namingOptions) |
void |
registerService(Object service,
RpcServerOptions serverOptions) |
<T> AsyncAwareFuture<T> |
sendServerPush(Request request) |
void |
setProtocol(Protocol protocol) |
boolean |
shutdown() |
void |
start() |
protected RpcServerOptions rpcServerOptions
protected String host
protected int port
protected io.netty.bootstrap.ServerBootstrap bootstrap
protected io.netty.channel.EventLoopGroup bossGroup
protected io.netty.channel.EventLoopGroup workerGroup
protected Protocol protocol
protected ThreadPool threadPool
protected List<ThreadPool> customThreadPools
protected ServerStatus serverStatus
protected AtomicBoolean stop
protected io.netty.util.Timer timeoutTimer
protected ServiceManager serviceManager
public CommunicationServer(int port)
public CommunicationServer(String host, int port)
public CommunicationServer(int port,
RpcServerOptions options)
public CommunicationServer(String host, int port, RpcServerOptions options)
public void registerService(Object service)
public void registerService(Object service, NamingOptions namingOptions)
public void registerService(Object service, Class targetClass, NamingOptions namingOptions)
public void registerService(Object service, RpcServerOptions serverOptions)
public void registerService(Object service, Class targetClass, NamingOptions namingOptions, RpcServerOptions serverOptions)
service - the service object which implement rpc interface.namingOptions - register center infoserverOptions - service own custom RpcServerOptions
if not null, the service will not use the shared thread pool.public void start()
public boolean shutdown()
public boolean isShutdown()
public Protocol getProtocol()
public void setProtocol(Protocol protocol)
public <T> AsyncAwareFuture<T> sendServerPush(Request request)
public void execute(Request request, Response response) throws RpcException
RpcExceptionCopyright © 2020 Baidu, Inc.. All rights reserved.