Package com.linkedin.alpini.router
Class ScatterGatherRequestHandlerImpl<H,P extends ResourcePath<K>,K,R,CHC,BHS extends BasicRequest,HR,HRS extends io.netty.handler.codec.http.HttpResponseStatus,SCATTER_GATHER_HELPER extends ScatterGatherHelper<H,P,K,R,BHS,HR,HRS>>
java.lang.Object
com.linkedin.alpini.router.ScatterGatherRequestHandler<H,P,K,R>
com.linkedin.alpini.router.ScatterGatherRequestHandlerImpl<H,P,K,R,CHC,BHS,HR,HRS,SCATTER_GATHER_HELPER>
- Direct Known Subclasses:
ScatterGatherRequestHandler4
public abstract class ScatterGatherRequestHandlerImpl<H,P extends ResourcePath<K>,K,R,CHC,BHS extends BasicRequest,HR,HRS extends io.netty.handler.codec.http.HttpResponseStatus,SCATTER_GATHER_HELPER extends ScatterGatherHelper<H,P,K,R,BHS,HR,HRS>>
extends ScatterGatherRequestHandler<H,P,K,R>
-
Field Summary
Fields inherited from class com.linkedin.alpini.router.ScatterGatherRequestHandler
_timeoutProcessor, LOG, NOP
-
Constructor Summary
ModifierConstructorDescriptionprotected
ScatterGatherRequestHandlerImpl
(SCATTER_GATHER_HELPER scatterGatherHelper, TimeoutProcessor timeoutProcessor) protected
ScatterGatherRequestHandlerImpl
(SCATTER_GATHER_HELPER scatterGatherHelper, RouterTimeoutProcessor timeoutProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected CompletionStage<?>
appendErrorForEveryKey
(BHS request, List<HR> responses, HRS status, String contentMessage, Throwable ex, ResourcePathParser<P, K> pathParser, ScatterGatherRequest<H, K> part, P basePath) protected void
appendErrorsForOfflinePartitions
(BHS request, Scatter<H, P, K> scatter, List<AsyncFuture<List<HR>>> responseFutures) protected abstract HRS
protected abstract HR
buildErrorResponse
(BHS request, HRS status, String contentMessage, Throwable ex) protected HR
buildExceptionResponse
(BHS request, Throwable cause) protected abstract HR
buildResponse
(BHS request, Metrics metrics, List<HR> gatheredResponses) protected final void
dispatch
(Scatter<H, P, K> scatter, ScatterGatherRequest<H, K> part, P path, BHS request, AsyncPromise<H> hostSelected, AsyncPromise<List<HR>> responseFuture, AsyncPromise<HRS> retryFuture, AsyncFuture<Void> timeoutFuture, Executor contextExecutor) protected abstract Executor
protected abstract HRS
protected abstract String
getReasonPhrase
(HRS status) protected abstract int
getResponseCode
(HR response) protected abstract Headers
getResponseHeaders
(HR response) protected abstract int
getResponseReadable
(HR response) final SCATTER_GATHER_HELPER
protected AsyncFuture<HR>
protected abstract boolean
hasErrorInStorageNodeResponse
(HR response) protected void
protected void
protected void
protected abstract HRS
protected boolean
isLastAttempt
(HRS status) protected abstract boolean
isRequestRetriable
(P path, R role, HRS status) protected abstract boolean
isSuccessStatus
(HRS status) protected abstract boolean
isTooLongFrameException
(Throwable cause) protected abstract HRS
protected BHS
prepareRequest
(BHS value) protected AsyncFutureListener<HRS>
prepareRetry
(AsyncFuture<H> hostFuture, P path, BHS requestRef, R role, AsyncPromise<List<HR>> responseFuture, AsyncFuture<Void> timeoutFuture, Executor contextExecutor, HostHealthMonitor<H> hostHealthMonitor, ScatterGatherStats.Delta stats, Metrics m) protected boolean
releaseRequest
(BHS value) protected boolean
releaseResponse
(HR value) protected BHS
retainRequest
(BHS value) protected abstract HRS
protected abstract void
setKeepAlive
(HR response, boolean keepAlive) static void
setMetric
(Metrics metric, MetricNames metricName, Supplier<TimeValue> supplier) protected abstract HRS
statusOf
(int code) protected abstract Runnable
protected Runnable
timeout
(CHC ctx, String msg, AsyncPromise<Void> timeoutFuture) protected <T> Runnable
timeout
(CHC ctx, String msg, AsyncPromise<T> timeoutFuture, T value) protected static Throwable
Methods inherited from class com.linkedin.alpini.router.ScatterGatherRequestHandler
make, make
-
Constructor Details
-
ScatterGatherRequestHandlerImpl
protected ScatterGatherRequestHandlerImpl(@Nonnull SCATTER_GATHER_HELPER scatterGatherHelper, @Nonnull TimeoutProcessor timeoutProcessor) -
ScatterGatherRequestHandlerImpl
protected ScatterGatherRequestHandlerImpl(@Nonnull SCATTER_GATHER_HELPER scatterGatherHelper, @Nonnull RouterTimeoutProcessor timeoutProcessor)
-
-
Method Details
-
getScatterGatherHelper
- Specified by:
getScatterGatherHelper
in classScatterGatherRequestHandler<H,
P extends ResourcePath<K>, K, R>
-
setMetric
public static void setMetric(Metrics metric, @Nonnull MetricNames metricName, @Nonnull Supplier<TimeValue> supplier) -
timeout
-
timeout
-
timeout
-
executor
-
handler
- Throws:
Exception
-
unwrapCompletion
-
statusOf
-
multiStatus
-
badRequest
-
gatewayTimeout
-
internalServerError
-
isSuccessStatus
-
isRequestRetriable
-
getReasonPhrase
-
prepareRequest
-
retainRequest
-
releaseRequest
-
releaseResponse
-
isLastAttempt
-
prepareRetry
@Nonnull protected AsyncFutureListener<HRS> prepareRetry(@Nonnull AsyncFuture<H> hostFuture, @Nonnull P path, @Nonnull BHS requestRef, @Nonnull R role, @Nonnull AsyncPromise<List<HR>> responseFuture, @Nonnull AsyncFuture<Void> timeoutFuture, @Nonnull Executor contextExecutor, @Nonnull HostHealthMonitor<H> hostHealthMonitor, @Nonnull ScatterGatherStats.Delta stats, Metrics m) -
incrementTotalRetries
-
incrementTotalRetriesError
-
incrementTotalRetriesWinner
-
getResponseCode
-
getResponseReadable
-
hasErrorInStorageNodeResponse
-
getResponseHeaders
-
setKeepAlive
-
buildResponse
-
appendErrorsForOfflinePartitions
-
appendErrorForEveryKey
protected CompletionStage<?> appendErrorForEveryKey(@Nonnull BHS request, @Nonnull List<HR> responses, @Nonnull HRS status, String contentMessage, Throwable ex, @Nonnull ResourcePathParser<P, K> pathParser, @Nonnull ScatterGatherRequest<H, K> part, @Nonnull P basePath) -
appendError
-
isTooLongFrameException
- Specified by:
isTooLongFrameException
in classScatterGatherRequestHandler<H,
P extends ResourcePath<K>, K, R>
-
buildExceptionResponse
-
buildErrorResponse
-
dispatch
protected final void dispatch(@Nonnull Scatter<H, P, K> scatter, @Nonnull ScatterGatherRequest<H, K> part, @Nonnull P path, @Nonnull BHS request, @Nonnull AsyncPromise<H> hostSelected, @Nonnull AsyncPromise<List<HR>> responseFuture, @Nonnull AsyncPromise<HRS> retryFuture, @Nonnull AsyncFuture<Void> timeoutFuture, @Nonnull Executor contextExecutor)
-