Package org.ovirt.vdsm.jsonrpc.client
Class JsonRpcClient
java.lang.Object
org.ovirt.vdsm.jsonrpc.client.JsonRpcClient
ReactorClient wrapper which provides ability to send single or batched requests.
Each send operation is represented by Call future which is updated when response arrives.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReactorClientprivate ScheduledExecutorServiceprivate final org.slf4j.Loggerprivate ClientPolicyprivate ResponseTracker -
Constructor Summary
ConstructorsConstructorDescriptionJsonRpcClient(ReactorClient client, ResponseTracker tracker) WrapsReactorClientto hide response update details. -
Method Summary
Modifier and TypeMethodDescriptioncall(JsonRpcRequest req) Sends single request and returnsFuturerepresentation ofJsonRpcResponse.call(JsonRpcRequest req, BrokerCommandCallback callback) voidclose()intbooleanisClosed()voidprocessResponse(JsonRpcResponse response) voidremoveCall(Future<JsonRpcResponse> call) private voidretryCall(JsonRpcRequest request, JsonRpcCall call) voidsetClientRetryPolicy(ClientPolicy policy) voidsetExecutorService(ScheduledExecutorService executorService) voidsetRetryPolicy(ClientPolicy policy)
-
Field Details
-
log
private final org.slf4j.Logger log -
client
-
tracker
-
policy
-
executorService
-
-
Constructor Details
-
JsonRpcClient
WrapsReactorClientto hide response update details.- Parameters:
client- - used to communicate.tracker- - used for response tracking.
-
-
Method Details
-
setClientRetryPolicy
-
setRetryPolicy
-
getClientRetryPolicy
-
getRetryPolicy
-
getHostname
-
getConnectionId
public int getConnectionId() -
setExecutorService
-
call
Sends single request and returnsFuturerepresentation ofJsonRpcResponse.- Parameters:
req- - Request which is about to be sent.- Returns:
- Future representation of the response or
nullif sending failed. - Throws:
ClientConnectionException- is thrown when connection issues occur.RequestAlreadySentException- when the same requests is attempted to be send twice.
-
call
public Future<JsonRpcResponse> call(JsonRpcRequest req, BrokerCommandCallback callback) throws ClientConnectionException - Throws:
ClientConnectionException
-
removeCall
-
retryCall
-
getClient
- Throws:
ClientConnectionException
-
processResponse
-
close
public void close() -
isClosed
public boolean isClosed()
-