Package org.ovirt.vdsm.jsonrpc.client
Class JsonRpcClient
- java.lang.Object
-
- org.ovirt.vdsm.jsonrpc.client.JsonRpcClient
-
public class JsonRpcClient extends java.lang.Object
ReactorClient
wrapper which provides ability to send single or batched requests. Each send operation is represented byCall
future which is updated when response arrives.
-
-
Field Summary
Fields Modifier and Type Field Description private ReactorClient
client
private java.util.concurrent.ScheduledExecutorService
executorService
private org.slf4j.Logger
log
private ClientPolicy
policy
private ResponseTracker
tracker
-
Constructor Summary
Constructors Constructor Description JsonRpcClient(ReactorClient client, ResponseTracker tracker)
WrapsReactorClient
to hide response update details.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.Future<JsonRpcResponse>
call(JsonRpcRequest req)
Sends single request and returnsFuture
representation ofJsonRpcResponse
.java.util.concurrent.Future<JsonRpcResponse>
call(JsonRpcRequest req, BrokerCommandCallback callback)
void
close()
ReactorClient
getClient()
ClientPolicy
getClientRetryPolicy()
int
getConnectionId()
java.lang.String
getHostname()
ClientPolicy
getRetryPolicy()
boolean
isClosed()
void
processResponse(JsonRpcResponse response)
void
removeCall(java.util.concurrent.Future<JsonRpcResponse> call)
private void
retryCall(JsonRpcRequest request, JsonRpcCall call)
void
setClientRetryPolicy(ClientPolicy policy)
void
setExecutorService(java.util.concurrent.ScheduledExecutorService executorService)
void
setRetryPolicy(ClientPolicy policy)
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
-
client
private final ReactorClient client
-
tracker
private ResponseTracker tracker
-
policy
private ClientPolicy policy
-
executorService
private java.util.concurrent.ScheduledExecutorService executorService
-
-
Constructor Detail
-
JsonRpcClient
public JsonRpcClient(ReactorClient client, ResponseTracker tracker)
WrapsReactorClient
to hide response update details.- Parameters:
client
- - used to communicate.tracker
- - used for response tracking.
-
-
Method Detail
-
setClientRetryPolicy
public void setClientRetryPolicy(ClientPolicy policy)
-
setRetryPolicy
public void setRetryPolicy(ClientPolicy policy)
-
getClientRetryPolicy
public ClientPolicy getClientRetryPolicy()
-
getRetryPolicy
public ClientPolicy getRetryPolicy()
-
getHostname
public java.lang.String getHostname()
-
getConnectionId
public int getConnectionId()
-
setExecutorService
public void setExecutorService(java.util.concurrent.ScheduledExecutorService executorService)
-
call
public java.util.concurrent.Future<JsonRpcResponse> call(JsonRpcRequest req) throws ClientConnectionException
Sends single request and returnsFuture
representation ofJsonRpcResponse
.- Parameters:
req
- - Request which is about to be sent.- Returns:
- Future representation of the response or
null
if sending failed. - Throws:
ClientConnectionException
- is thrown when connection issues occur.RequestAlreadySentException
- when the same requests is attempted to be send twice.
-
call
public java.util.concurrent.Future<JsonRpcResponse> call(JsonRpcRequest req, BrokerCommandCallback callback) throws ClientConnectionException
- Throws:
ClientConnectionException
-
removeCall
public void removeCall(java.util.concurrent.Future<JsonRpcResponse> call)
-
retryCall
private void retryCall(JsonRpcRequest request, JsonRpcCall call)
-
getClient
public ReactorClient getClient() throws ClientConnectionException
- Throws:
ClientConnectionException
-
processResponse
public void processResponse(JsonRpcResponse response)
-
close
public void close()
-
isClosed
public boolean isClosed()
-
-