public class RpcServer extends RemotingServer
RpcServer(int), RpcServer(int, boolean), RpcServer(int, boolean, boolean)
Then call start() to start a rpc server, and call stop() to stop a rpc server.
Notice:
Once rpc server has been stopped, it can never be start again. You should init another instance of RpcServer to use.| 限定符和类型 | 字段和说明 |
|---|---|
protected RpcRemoting |
rpcRemoting
rpc remoting
|
port| 构造器和说明 |
|---|
RpcServer(int port)
Construct a rpc server.
|
RpcServer(int port,
boolean manageConnection)
Construct a rpc server.
|
RpcServer(int port,
boolean manageConnection,
boolean syncStop)
Construct a rpc server.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addConnectionEventProcessor(ConnectionEventType type,
ConnectionEventProcessor processor)
Add processor to process connection event.
|
protected void |
doInit()
Inject initialize logic here.
|
protected boolean |
doStart()
Inject start logic here.
|
protected boolean |
doStart(String ip)
Inject start logic here.
|
protected void |
doStop()
Notice: only
GlobalSwitch.SERVER_MANAGE_CONNECTION_SWITCH switch on, will close all connections. |
RemotingAddressParser |
getAddressParser()
Getter method for property addressParser.
|
DefaultConnectionManager |
getConnectionManager()
Getter method for property connectionManager.
|
protected void |
initRpcRemoting()
init rpc remoting
|
Object |
invokeSync(Connection conn,
Object request,
int timeoutMillis)
Synchronous invocation using a
Connection Notice: DO NOT modify the request object concurrently when this method is called. |
Object |
invokeSync(Connection conn,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Synchronous invocation with a
InvokeContext, common api notice please see invokeSync(Connection, Object, int) |
Object |
invokeSync(String addr,
Object request,
int timeoutMillis)
Synchronous invocation using a string address, address format example - 127.0.0.1:12200?
|
Object |
invokeSync(String addr,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Synchronous invocation with a
InvokeContext, common api notice please see invokeSync(String, Object, int) |
Object |
invokeSync(Url url,
Object request,
int timeoutMillis)
Synchronous invocation using a parsed
Url Notice: DO NOT modify the request object concurrently when this method is called. |
Object |
invokeSync(Url url,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Synchronous invocation with a
InvokeContext, common api notice please see invokeSync(Url, Object, int) |
void |
invokeWithCallback(Connection conn,
Object request,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation using a
Connection You can specify an implementation of InvokeCallback to get the result. |
void |
invokeWithCallback(Connection conn,
Object request,
InvokeContext invokeContext,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation with a
InvokeContext, common api notice please see invokeWithCallback(Connection, Object, InvokeCallback, int) |
void |
invokeWithCallback(String addr,
Object request,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation using a string address, address format example - 127.0.0.1:12200?
|
void |
invokeWithCallback(String addr,
Object request,
InvokeContext invokeContext,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation with a
InvokeContext, common api notice please see invokeWithCallback(String, Object, InvokeCallback, int) |
void |
invokeWithCallback(Url url,
Object request,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation using a parsed
Url You can specify an implementation of InvokeCallback to get the result. |
void |
invokeWithCallback(Url url,
Object request,
InvokeContext invokeContext,
InvokeCallback invokeCallback,
int timeoutMillis)
Callback invocation with a
InvokeContext, common api notice please see invokeWithCallback(Url, Object, InvokeCallback, int) |
RpcResponseFuture |
invokeWithFuture(Connection conn,
Object request,
int timeoutMillis)
|
RpcResponseFuture |
invokeWithFuture(Connection conn,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Future invocation with a
InvokeContext, common api notice please see invokeWithFuture(Connection, Object, int) |
RpcResponseFuture |
invokeWithFuture(String addr,
Object request,
int timeoutMillis)
Future invocation using a string address, address format example - 127.0.0.1:12200?
|
RpcResponseFuture |
invokeWithFuture(String addr,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Future invocation with a
InvokeContext, common api notice please see invokeWithFuture(String, Object, int) |
RpcResponseFuture |
invokeWithFuture(Url url,
Object request,
int timeoutMillis)
|
RpcResponseFuture |
invokeWithFuture(Url url,
Object request,
InvokeContext invokeContext,
int timeoutMillis)
Future invocation with a
InvokeContext, common api notice please see invokeWithFuture(Url, Object, int) |
boolean |
isConnected(String remoteAddr)
check whether a client address connected
|
boolean |
isConnected(Url url)
check whether a
Url connected |
void |
oneway(Connection conn,
Object request)
One way invocation using a
Connection Notice: DO NOT modify the request object concurrently when this method is called. |
void |
oneway(Connection conn,
Object request,
InvokeContext invokeContext)
One way invocation with a
InvokeContext, common api notice please see oneway(Connection, Object) |
void |
oneway(String addr,
Object request)
One way invocation using a string address, address format example - 127.0.0.1:12200?
|
void |
oneway(String addr,
Object request,
InvokeContext invokeContext)
One way invocation with a
InvokeContext, common api notice please see oneway(String, Object) |
void |
oneway(Url url,
Object request)
One way invocation using a parsed
Url Notice: DO NOT modify the request object concurrently when this method is called. |
void |
oneway(Url url,
Object request,
InvokeContext invokeContext)
One way invocation with a
InvokeContext, common api notice please see oneway(Url, Object) |
void |
registerDefaultExecutor(byte protocolCode,
ExecutorService executor)
Register default executor service for server.
|
void |
registerProcessor(byte protocolCode,
CommandCode cmd,
RemotingProcessor<?> processor)
Register processor for command with the command code.
|
void |
registerUserProcessor(UserProcessor<?> processor)
Register user processor.
|
void |
setAddressParser(RemotingAddressParser addressParser)
Setter method for property addressParser.
|
protected RpcRemoting rpcRemoting
public RpcServer(int port)
Connection, for example invokeSync(Connection, Object, int) UnsupportedOperationException will be thrown.port - public RpcServer(int port,
boolean manageConnection)
String, Url, Connection methods.Connection, otherwise UnsupportedOperationException will be thrown.port - manageConnection - true to enable connection management featurepublic RpcServer(int port,
boolean manageConnection,
boolean syncStop)
port - manageConnection - syncStop - true to enable stop in synchronous wayprotected void doInit()
RemotingServerdoInit 在类中 RemotingServerprotected boolean doStart()
throws InterruptedException
RemotingServerdoStart 在类中 RemotingServerInterruptedExceptionRemotingServer.doStart()protected boolean doStart(String ip) throws InterruptedException
RemotingServerdoStart 在类中 RemotingServerInterruptedExceptionRemotingServer.doStart(String)protected void doStop()
GlobalSwitch.SERVER_MANAGE_CONNECTION_SWITCH switch on, will close all connections.doStop 在类中 RemotingServerRemotingServer.doStop()protected void initRpcRemoting()
public void registerProcessor(byte protocolCode,
CommandCode cmd,
RemotingProcessor<?> processor)
RemotingServerpublic void registerDefaultExecutor(byte protocolCode,
ExecutorService executor)
RemotingServerpublic void addConnectionEventProcessor(ConnectionEventType type, ConnectionEventProcessor processor)
type - processor - public void registerUserProcessor(UserProcessor<?> processor)
RemotingServerpublic void oneway(String addr, Object request) throws RemotingException, InterruptedException
Notice:
addr - request - RemotingExceptionInterruptedExceptionpublic void oneway(String addr, Object request, InvokeContext invokeContext) throws RemotingException, InterruptedException
InvokeContext, common api notice please see oneway(String, Object)addr - request - invokeContext - RemotingExceptionInterruptedExceptionpublic void oneway(Url url, Object request) throws RemotingException, InterruptedException
Url
Notice:
Url to find a available client connection, if none then throw exceptionurl - request - RemotingExceptionInterruptedExceptionpublic void oneway(Url url, Object request, InvokeContext invokeContext) throws RemotingException, InterruptedException
InvokeContext, common api notice please see oneway(Url, Object)url - request - invokeContext - RemotingExceptionInterruptedExceptionpublic void oneway(Connection conn, Object request) throws RemotingException
Connection
Notice:
DO NOT modify the request object concurrently when this method is called.
conn - request - RemotingExceptionpublic void oneway(Connection conn, Object request, InvokeContext invokeContext) throws RemotingException
InvokeContext, common api notice please see oneway(Connection, Object)conn - request - invokeContext - RemotingExceptionpublic Object invokeSync(String addr, Object request, int timeoutMillis) throws RemotingException, InterruptedException
Notice:
addr - request - timeoutMillis - RemotingExceptionInterruptedExceptionpublic Object invokeSync(String addr, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeSync(String, Object, int)addr - request - invokeContext - timeoutMillis - RemotingExceptionInterruptedExceptionpublic Object invokeSync(Url url, Object request, int timeoutMillis) throws RemotingException, InterruptedException
Url
Notice:
Url to find a available client connection, if none then throw exceptionurl - request - timeoutMillis - RemotingExceptionInterruptedExceptionpublic Object invokeSync(Url url, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeSync(Url, Object, int)url - request - invokeContext - timeoutMillis - RemotingExceptionInterruptedExceptionpublic Object invokeSync(Connection conn, Object request, int timeoutMillis) throws RemotingException, InterruptedException
Connection
Notice:
DO NOT modify the request object concurrently when this method is called.
conn - request - timeoutMillis - RemotingExceptionInterruptedExceptionpublic Object invokeSync(Connection conn, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeSync(Connection, Object, int)conn - request - invokeContext - timeoutMillis - RemotingExceptionInterruptedExceptionpublic RpcResponseFuture invokeWithFuture(String addr, Object request, int timeoutMillis) throws RemotingException, InterruptedException
RpcResponseFuture.
Notice:
addr - request - timeoutMillis - RemotingExceptionInterruptedExceptionpublic RpcResponseFuture invokeWithFuture(String addr, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeWithFuture(String, Object, int)addr - request - invokeContext - timeoutMillis - RemotingExceptionInterruptedExceptionpublic RpcResponseFuture invokeWithFuture(Url url, Object request, int timeoutMillis) throws RemotingException, InterruptedException
Url RpcResponseFuture.
Notice:
Url to find a available client connection, if none then throw exceptionurl - request - timeoutMillis - RemotingExceptionInterruptedExceptionpublic RpcResponseFuture invokeWithFuture(Url url, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeWithFuture(Url, Object, int)url - request - invokeContext - timeoutMillis - RemotingExceptionInterruptedExceptionpublic RpcResponseFuture invokeWithFuture(Connection conn, Object request, int timeoutMillis) throws RemotingException
Connection RpcResponseFuture.
Notice:
DO NOT modify the request object concurrently when this method is called.
conn - request - timeoutMillis - RemotingExceptionpublic RpcResponseFuture invokeWithFuture(Connection conn, Object request, InvokeContext invokeContext, int timeoutMillis) throws RemotingException
InvokeContext, common api notice please see invokeWithFuture(Connection, Object, int)conn - request - invokeContext - timeoutMillis - RemotingExceptionpublic void invokeWithCallback(String addr, Object request, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException, InterruptedException
InvokeCallback to get the result.
Notice:
addr - request - invokeCallback - timeoutMillis - RemotingExceptionInterruptedExceptionpublic void invokeWithCallback(String addr, Object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeWithCallback(String, Object, InvokeCallback, int)addr - request - invokeContext - invokeCallback - timeoutMillis - RemotingExceptionInterruptedExceptionpublic void invokeWithCallback(Url url, Object request, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException, InterruptedException
Url InvokeCallback to get the result.
Notice:
Url to find a available client connection, if none then throw exceptionurl - request - invokeCallback - timeoutMillis - RemotingExceptionInterruptedExceptionpublic void invokeWithCallback(Url url, Object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException, InterruptedException
InvokeContext, common api notice please see invokeWithCallback(Url, Object, InvokeCallback, int)url - request - invokeContext - invokeCallback - timeoutMillis - RemotingExceptionInterruptedExceptionpublic void invokeWithCallback(Connection conn, Object request, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException
Connection InvokeCallback to get the result.
Notice:
DO NOT modify the request object concurrently when this method is called.
conn - request - invokeCallback - timeoutMillis - RemotingExceptionpublic void invokeWithCallback(Connection conn, Object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) throws RemotingException
InvokeContext, common api notice please see invokeWithCallback(Connection, Object, InvokeCallback, int)conn - request - invokeCallback - timeoutMillis - RemotingExceptionpublic boolean isConnected(String remoteAddr)
remoteAddr - public RemotingAddressParser getAddressParser()
public void setAddressParser(RemotingAddressParser addressParser)
addressParser - value to be assigned to property addressParserpublic DefaultConnectionManager getConnectionManager()
Copyright © 2018. All rights reserved.