public class ResponseManager extends Object
| Constructor and Description |
|---|
ResponseManager(StreamManagerLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
void |
deliverException(IOException cause)
Delivers exception to all the callers waiting for a response
Should be called when the callers of waitForResponse are not expected to get a real response
eg, when the connection is dropped
This is a way to fail fast and cleanup
|
void |
deliverResponse(String requestId,
Object response)
Deliver a response object.
|
void |
registerForResponse(String requestId)
Register a pending response for a client request.
|
<T> T |
waitForResponse(String requestId,
long timeoutInSeconds,
Class<T> responseTypeClass)
Wait for the arrival of a response.
|
public ResponseManager(StreamManagerLogger logger)
public void registerForResponse(String requestId) throws StreamManagerException
requestId - request idStreamManagerExceptionpublic <T> T waitForResponse(String requestId, long timeoutInSeconds, Class<T> responseTypeClass) throws InterruptedException, IOException, StreamManagerException
T - Response class type, should not be an IOExceptionrequestId - Request idtimeoutInSeconds - Timeout in secondsresponseTypeClass - Response classInterruptedException - InterruptedExceptionIOException - when an IOException is deliveredStreamManagerException - For other exceptionspublic void deliverResponse(String requestId, Object response)
requestId - Request idresponse - Response objectpublic void deliverException(IOException cause)
cause - exception to deliver