public class RpcServer extends AbstractRemotingServer
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
|
| 构造器和说明 |
|---|
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.
|
RpcServer(String ip,
int port)
Construct a rpc server.
|
RpcServer(String ip,
int port,
boolean manageConnection)
Construct a rpc server.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addConnectionEventProcessor(ConnectionEventType type,
ConnectionEventProcessor processor)
Add processor to process connection event.
|
protected void |
doInit() |
protected boolean |
doStart() |
protected boolean |
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)
Use UserProcessorRegisterHelper
UserProcessorRegisterHelper to help register user processor for server side. |
void |
setAddressParser(RemotingAddressParser addressParser)
Setter method for property addressParser.
|
conf, initWriteBufferWaterMark, netty_buffer_high_watermark, netty_buffer_low_watermark, switchesprotected RpcRemoting rpcRemoting
public RpcServer(int port)
Connection, for example invokeSync(Connection, Object, int) UnsupportedOperationException will be thrown.public RpcServer(String ip, int port)
Connection, for example invokeSync(Connection, Object, int) UnsupportedOperationException will be thrown.public RpcServer(int port,
boolean manageConnection)
String, Url, Connection methods.Connection, otherwise UnsupportedOperationException will be thrown.port - listened portmanageConnection - true to enable connection management featurepublic RpcServer(String ip, int port, boolean manageConnection)
String, Url, Connection methods.Connection, otherwise UnsupportedOperationException will be thrown.port - listened portmanageConnection - true to enable connection management featurepublic RpcServer(int port,
boolean manageConnection,
boolean syncStop)
port - listened portmanageConnection - manage connectionsyncStop - true to enable stop in synchronous wayprotected void doInit()
doInit 在类中 AbstractRemotingServerprotected boolean doStart()
throws InterruptedException
doStart 在类中 AbstractRemotingServerInterruptedExceptionprotected boolean doStop()
GlobalSwitch.SERVER_MANAGE_CONNECTION_SWITCH switch on, will close all connections.doStop 在类中 AbstractRemotingServerAbstractRemotingServer.doStop()protected void initRpcRemoting()
public void registerProcessor(byte protocolCode,
CommandCode cmd,
RemotingProcessor<?> processor)
RemotingServerprotocolCode - protocol codecmd - command codeprocessor - processorRemotingServer.registerProcessor(byte, com.alipay.remoting.CommandCode, com.alipay.remoting.RemotingProcessor)public void registerDefaultExecutor(byte protocolCode,
ExecutorService executor)
RemotingServerprotocolCode - protocol codeexecutor - the executor service for the protocol codeRemotingServer.registerDefaultExecutor(byte, ExecutorService)public void addConnectionEventProcessor(ConnectionEventType type, ConnectionEventProcessor processor)
type - connection event typeprocessor - connection event processorpublic void registerUserProcessor(UserProcessor<?> processor)
UserProcessorRegisterHelper to help register user processor for server side.processor - user processor which can be a single-interest processor or a multi-interest processorRemotingServer.registerUserProcessor(com.alipay.remoting.rpc.protocol.UserProcessor)public 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 © 2021. All rights reserved.