Search in sources :

Example 21 with GetResponse

use of com.github.ambry.protocol.GetResponse in project ambry by linkedin.

the class GetBlobResultInternal method handleResponse.

/**
 * Hands over the response to the associated GetOperation that issued the request.
 * @param responseInfo the {@link ResponseInfo} containing the response.
 */
void handleResponse(ResponseInfo responseInfo) {
    long startTime = time.milliseconds();
    GetResponse getResponse = extractGetResponseAndNotifyResponseHandler(responseInfo);
    RouterRequestInfo routerRequestInfo = (RouterRequestInfo) responseInfo.getRequestInfo();
    GetRequest getRequest = (GetRequest) routerRequestInfo.getRequest();
    GetOperation getOperation = correlationIdToGetOperation.remove(getRequest.getCorrelationId());
    if (getOperations.contains(getOperation)) {
        try {
            getOperation.handleResponse(responseInfo, getResponse);
            if (getOperation.isOperationComplete()) {
                remove(getOperation);
            }
        } catch (Exception e) {
            removeAndAbort(getOperation, new RouterException("Get handleResponse encountered unexpected error", e, RouterErrorCode.UnexpectedInternalError));
        }
        routerMetrics.getManagerHandleResponseTimeMs.update(time.milliseconds() - startTime);
    } else {
        routerMetrics.ignoredResponseCount.inc();
    }
}
Also used : GetRequest(com.github.ambry.protocol.GetRequest) GetResponse(com.github.ambry.protocol.GetResponse)

Aggregations

GetResponse (com.github.ambry.protocol.GetResponse)21 DataInputStream (java.io.DataInputStream)18 ArrayList (java.util.ArrayList)16 GetRequest (com.github.ambry.protocol.GetRequest)12 PartitionRequestInfo (com.github.ambry.protocol.PartitionRequestInfo)12 BlobId (com.github.ambry.commons.BlobId)9 ByteBufferInputStream (com.github.ambry.utils.ByteBufferInputStream)9 BlobProperties (com.github.ambry.messageformat.BlobProperties)8 InputStream (java.io.InputStream)8 ByteBuffer (java.nio.ByteBuffer)7 BlobData (com.github.ambry.messageformat.BlobData)6 MessageFormatException (com.github.ambry.messageformat.MessageFormatException)6 ResponseInfo (com.github.ambry.network.ResponseInfo)6 IOException (java.io.IOException)6 RequestInfo (com.github.ambry.network.RequestInfo)5 CrcInputStream (com.github.ambry.utils.CrcInputStream)5 FileInputStream (java.io.FileInputStream)5 BlobIdFactory (com.github.ambry.commons.BlobIdFactory)4 ServerErrorCode (com.github.ambry.commons.ServerErrorCode)4 BlobAll (com.github.ambry.messageformat.BlobAll)4