public class RpcClient extends AbstractConfigurableInstance
| 限定符和类型 | 字段和说明 |
|---|---|
protected RpcRemoting |
rpcRemoting
rpc remoting
|
| 构造器和说明 |
|---|
RpcClient() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addConnectionEventProcessor(ConnectionEventType type,
ConnectionEventProcessor processor)
Add processor to process connection event.
|
boolean |
checkConnection(String addr)
check connection, the address format example - 127.0.0.1:12200?
|
void |
closeConnection(String addr)
Close all connections of a address
|
void |
closeConnection(Url url)
Close all connections of a
Url |
void |
closeStandaloneConnection(Connection conn)
Close a standalone connection
|
Connection |
createStandaloneConnection(String addr,
int connectTimeout)
Create a stand alone connection using address, address format example - 127.0.0.1:12200
Notice: Each time you can this method, will create a new connection. |
Connection |
createStandaloneConnection(String ip,
int port,
int connectTimeout)
Create a stand alone connection using ip and port.
|
void |
disableConnectionMonitorSwitch()
disable connection monitor switch off
Notice: This api should be called before
init() |
void |
disableConnHeartbeat(String addr)
Disable heart beat for a certain connection.
|
void |
disableConnHeartbeat(Url url)
Disable heart beat for a certain connection.
|
void |
disableReconnectSwith()
disable connection reconnect switch off
Notice: This api should be called before
init() |
void |
enableConnectionMonitorSwitch()
enable connection monitor switch on
|
void |
enableConnHeartbeat(String addr)
Enable heart beat for a certain connection.
|
void |
enableConnHeartbeat(Url url)
Enable heart beat for a certain connection.
|
void |
enableReconnectSwitch()
enable connection reconnect switch on
Notice: This api should be called before
init() |
RemotingAddressParser |
getAddressParser()
Getter method for property addressParser.
|
Map<String,List<Connection>> |
getAllManagedConnections()
get all connections managed by rpc client
|
Connection |
getConnection(String addr,
int connectTimeout)
Get a connection using address, address format example - 127.0.0.1:12200?
|
Connection |
getConnection(Url url,
int connectTimeout)
Get a connection using a
Url. |
protected DefaultConnectionManager |
getConnectionManager() |
void |
init() |
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 |
isConnectionMonitorSwitchOn()
is connection monitor switch on
|
boolean |
isReconnectSwitchOn()
is reconnect switch on
|
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)
Oneway 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)
Oneway invocation with a
InvokeContext, common api notice please see oneway(Connection, 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)
Oneway invocation with a
InvokeContext, common api notice please see oneway(Url, Object) |
void |
registerUserProcessor(UserProcessor<?> processor)
Use UserProcessorRegisterHelper
UserProcessorRegisterHelper to help register user processor for client side. |
void |
setAddressParser(RemotingAddressParser addressParser)
Setter method for property addressParser.
|
void |
setMonitorStrategy(ConnectionMonitorStrategy monitorStrategy)
Setter method for property monitorStrategy.
|
void |
shutdown()
Shutdown.
|
conf, initWriteBufferWaterMark, netty_buffer_high_watermark, netty_buffer_low_watermark, switchesprotected RpcRemoting rpcRemoting
public void init()
public void shutdown()
Notice:
public void oneway(String addr, Object request) throws RemotingException, InterruptedException
Notice:
RpcConfigs.CONNECT_TIMEOUT_KEY to specify connection timeout, time unit is milliseconds, e.g [127.0.0.1:12200?_CONNECTTIMEOUT=3000]
RpcConfigs.CONNECTION_NUM_KEY to specify connection number for each ip and port, e.g [127.0.0.1:12200?_CONNECTIONNUM=30]
RpcConfigs.CONNECTION_WARMUP_KEY to specify whether need warmup all connections for the first time you call this method, e.g [127.0.0.1:12200?_CONNECTIONWARMUP=false]
closeConnection(String addr) to close it if you want.
addr - request - RemotingExceptionInterruptedExceptionpublic void oneway(String addr, Object request, InvokeContext invokeContext) throws RemotingException, InterruptedException
InvokeContext, common api notice please see oneway(Connection, Object)addr - request - invokeContext - RemotingExceptionInterruptedExceptionpublic void oneway(Url url, Object request) throws RemotingException, InterruptedException
Url
Notice:
Url to find a available connection, if none then create one.Url.setConnectTimeout(int) to specify connection timeout, time unit is milliseconds.
Url.setConnNum(int) to specify connection number for each ip and port.
Url.setConnWarmup(boolean) to specify whether need warmup all connections for the first time you call this method.
closeConnection(Url url) to close it if you want.
url - 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:
RpcConfigs.CONNECT_TIMEOUT_KEY to specify connection timeout, time unit is milliseconds, e.g [127.0.0.1:12200?_CONNECTTIMEOUT=3000]
RpcConfigs.CONNECTION_NUM_KEY to specify connection number for each ip and port, e.g [127.0.0.1:12200?_CONNECTIONNUM=30]
RpcConfigs.CONNECTION_WARMUP_KEY to specify whether need warmup all connections for the first time you call this method, e.g [127.0.0.1:12200?_CONNECTIONWARMUP=false]
closeConnection(String addr) to close it if you want.
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 connection, if none then create one.Url.setConnectTimeout(int) to specify connection timeout, time unit is milliseconds.
Url.setConnNum(int) to specify connection number for each ip and port.
Url.setConnWarmup(boolean) to specify whether need warmup all connections for the first time you call this method.
closeConnection(Url url) to close it if you want.
url - 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:
RpcConfigs.CONNECT_TIMEOUT_KEY to specify connection timeout, time unit is milliseconds, e.g [127.0.0.1:12200?_CONNECTTIMEOUT=3000]
RpcConfigs.CONNECTION_NUM_KEY to specify connection number for each ip and port, e.g [127.0.0.1:12200?_CONNECTIONNUM=30]
RpcConfigs.CONNECTION_WARMUP_KEY to specify whether need warmup all connections for the first time you call this method, e.g [127.0.0.1:12200?_CONNECTIONWARMUP=false]
closeConnection(String addr) to close it if you want.
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 connection, if none then create one.Url.setConnectTimeout(int) to specify connection timeout, time unit is milliseconds.
Url.setConnNum(int) to specify connection number for each ip and port.
Url.setConnWarmup(boolean) to specify whether need warmup all connections for the first time you call this method.
closeConnection(Url url) to close it if you want.
url - 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:
RpcConfigs.CONNECT_TIMEOUT_KEY to specify connection timeout, time unit is milliseconds, e.g [127.0.0.1:12200?_CONNECTTIMEOUT=3000]
RpcConfigs.CONNECTION_NUM_KEY to specify connection number for each ip and port, e.g [127.0.0.1:12200?_CONNECTIONNUM=30]
RpcConfigs.CONNECTION_WARMUP_KEY to specify whether need warmup all connections for the first time you call this method, e.g [127.0.0.1:12200?_CONNECTIONWARMUP=false]
closeConnection(String addr) to close it if you want.
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 connection, if none then create one.Url.setConnectTimeout(int) to specify connection timeout, time unit is milliseconds.
Url.setConnNum(int) to specify connection number for each ip and port.
Url.setConnWarmup(boolean) to specify whether need warmup all connections for the first time you call this method.
closeConnection(Url url) to close it if you want.
url - 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 - invokeContext - invokeCallback - timeoutMillis - RemotingExceptionpublic void addConnectionEventProcessor(ConnectionEventType type, ConnectionEventProcessor processor)
type - processor - public void registerUserProcessor(UserProcessor<?> processor)
UserProcessorRegisterHelper to help register user processor for client side.processor - RemotingExceptionpublic Connection createStandaloneConnection(String ip, int port, int connectTimeout) throws RemotingException
Notice:
closeStandaloneConnection(com.alipay.remoting.Connection) to close it.ip - port - connectTimeout - RemotingExceptionpublic Connection createStandaloneConnection(String addr, int connectTimeout) throws RemotingException
Notice:
closeStandaloneConnection(com.alipay.remoting.Connection) to close it.
addr - connectTimeout - RemotingExceptionpublic void closeStandaloneConnection(Connection conn)
conn - public Connection getConnection(String addr, int connectTimeout) throws RemotingException, InterruptedException
Notice:
RpcConfigs.CONNECT_TIMEOUT_KEY to specify connection timeout, time unit is milliseconds, e.g [127.0.0.1:12200?_CONNECTTIMEOUT=3000]
RpcConfigs.CONNECTION_NUM_KEY to specify connection number for each ip and port, e.g [127.0.0.1:12200?_CONNECTIONNUM=30]
RpcConfigs.CONNECTION_WARMUP_KEY to specify whether need warmup all connections for the first time you call this method, e.g [127.0.0.1:12200?_CONNECTIONWARMUP=false]
ConnectionPool
closeConnection(String addr) to close it.
addr - connectTimeout - this is prior to url args RpcConfigs.CONNECT_TIMEOUT_KEYRemotingExceptionInterruptedExceptionpublic Connection getConnection(Url url, int connectTimeout) throws RemotingException, InterruptedException
Url.Notice:
ConnectionPool
closeConnection(Url url) to close it.
url - connectTimeout - this is prior to url args RpcConfigs.CONNECT_TIMEOUT_KEYRemotingExceptionInterruptedExceptionpublic Map<String,List<Connection>> getAllManagedConnections()
public boolean checkConnection(String addr)
addr - RemotingExceptionpublic void closeConnection(String addr)
addr - public void enableConnHeartbeat(String addr)
Notice: this method takes no effect on a stand alone connection.
addr - public void enableConnHeartbeat(Url url)
Url not connected, then do nothing.
Notice: this method takes no effect on a stand alone connection.
url - public void disableConnHeartbeat(String addr)
Notice: this method takes no effect on a stand alone connection.
addr - public void disableConnHeartbeat(Url url)
Url not connected, then do nothing.
Notice: this method takes no effect on a stand alone connection.
url - public void enableReconnectSwitch()
Notice: This api should be called before init()
public void disableReconnectSwith()
Notice: This api should be called before init()
public boolean isReconnectSwitchOn()
public void enableConnectionMonitorSwitch()
public void disableConnectionMonitorSwitch()
Notice: This api should be called before init()
public boolean isConnectionMonitorSwitchOn()
protected DefaultConnectionManager getConnectionManager()
public RemotingAddressParser getAddressParser()
public void setAddressParser(RemotingAddressParser addressParser)
addressParser - value to be assigned to property addressParserpublic void setMonitorStrategy(ConnectionMonitorStrategy monitorStrategy)
monitorStrategy - value to be assigned to property monitorStrategyCopyright © 2021. All rights reserved.