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
Constructors Modifier Constructor Description protectedScatterGatherRequestHandlerImpl(SCATTER_GATHER_HELPER scatterGatherHelper, TimeoutProcessor timeoutProcessor)protectedScatterGatherRequestHandlerImpl(SCATTER_GATHER_HELPER scatterGatherHelper, RouterTimeoutProcessor timeoutProcessor)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidappendError(BHS request, java.util.List<HR> responses, HRS status, java.lang.String contentMessage, java.lang.Throwable ex)protected java.util.concurrent.CompletionStage<?>appendErrorForEveryKey(BHS request, java.util.List<HR> responses, HRS status, java.lang.String contentMessage, java.lang.Throwable ex, ResourcePathParser<P,K> pathParser, ScatterGatherRequest<H,K> part, P basePath)protected voidappendErrorsForOfflinePartitions(BHS request, Scatter<H,P,K> scatter, java.util.List<AsyncFuture<java.util.List<HR>>> responseFutures)protected abstract HRSbadRequest()protected abstract HRbuildErrorResponse(BHS request, HRS status, java.lang.String contentMessage, java.lang.Throwable ex)protected HRbuildExceptionResponse(BHS request, java.lang.Throwable cause)protected abstract HRbuildResponse(BHS request, Metrics metrics, java.util.List<HR> gatheredResponses)protected voiddispatch(Scatter<H,P,K> scatter, ScatterGatherRequest<H,K> part, P path, BHS request, AsyncPromise<H> hostSelected, AsyncPromise<java.util.List<HR>> responseFuture, AsyncPromise<HRS> retryFuture, AsyncFuture<java.lang.Void> timeoutFuture, java.util.concurrent.Executor contextExecutor)protected abstract java.util.concurrent.Executorexecutor(CHC ctx)protected abstract HRSgatewayTimeout()protected abstract java.lang.StringgetReasonPhrase(HRS status)protected abstract intgetResponseCode(HR response)protected abstract HeadersgetResponseHeaders(HR response)protected abstract intgetResponseReadable(HR response)SCATTER_GATHER_HELPERgetScatterGatherHelper()protected AsyncFuture<HR>handler(CHC ctx, BHS request)protected abstract booleanhasErrorInStorageNodeResponse(HR response)protected voidincrementTotalRetries(ScatterGatherStats.Delta stats, HRS responseStatus)protected voidincrementTotalRetriesError(ScatterGatherStats.Delta stats, HRS responseStatus)protected voidincrementTotalRetriesWinner(ScatterGatherStats.Delta stats, HRS responseStatus)protected abstract HRSinternalServerError()protected booleanisLastAttempt(HRS status)protected abstract booleanisRequestRetriable(P path, R role, HRS status)protected abstract booleanisServiceUnavailable(HRS status)protected abstract booleanisSuccessStatus(HRS status)protected abstract booleanisTooLongFrameException(java.lang.Throwable cause)protected abstract HRSmultiStatus()protected BHSprepareRequest(BHS value)protected AsyncFutureListener<HRS>prepareRetry(AsyncFuture<H> hostFuture, P path, BHS requestRef, R role, AsyncPromise<java.util.List<HR>> responseFuture, AsyncFuture<java.lang.Void> timeoutFuture, java.util.concurrent.Executor contextExecutor, HostHealthMonitor<H> hostHealthMonitor, ScatterGatherStats.Delta stats, Metrics m)protected booleanreleaseRequest(BHS value)protected booleanreleaseResponse(HR value)protected BHSretainRequest(BHS value)protected abstract HRSserviceUnavailable()protected abstract voidsetKeepAlive(HR response, boolean keepAlive)static voidsetMetric(Metrics metric, MetricNames metricName, java.util.function.Supplier<TimeValue> supplier)protected abstract HRSstatusOf(int code)protected abstract java.lang.Runnabletimeout(CHC ctx, java.lang.Runnable task)protected java.lang.Runnabletimeout(CHC ctx, java.lang.String msg, AsyncPromise<java.lang.Void> timeoutFuture)protected <T> java.lang.Runnabletimeout(CHC ctx, java.lang.String msg, AsyncPromise<T> timeoutFuture, T value)protected abstract HRStooManyRequests()protected static java.lang.ThrowableunwrapCompletion(java.lang.Throwable ex)-
Methods inherited from class com.linkedin.alpini.router.ScatterGatherRequestHandler
make, make
-
-
-
-
Constructor Detail
-
ScatterGatherRequestHandlerImpl
protected ScatterGatherRequestHandlerImpl(@Nonnull SCATTER_GATHER_HELPER scatterGatherHelper, @Nonnull TimeoutProcessor timeoutProcessor)
-
ScatterGatherRequestHandlerImpl
protected ScatterGatherRequestHandlerImpl(@Nonnull SCATTER_GATHER_HELPER scatterGatherHelper, @Nonnull RouterTimeoutProcessor timeoutProcessor)
-
-
Method Detail
-
getScatterGatherHelper
@Nonnull public final SCATTER_GATHER_HELPER getScatterGatherHelper()
- Specified by:
getScatterGatherHelperin classScatterGatherRequestHandler<H,P extends ResourcePath<K>,K,R>
-
setMetric
public static void setMetric(Metrics metric, @Nonnull MetricNames metricName, @Nonnull java.util.function.Supplier<TimeValue> supplier)
-
timeout
protected abstract java.lang.Runnable timeout(CHC ctx, java.lang.Runnable task)
-
timeout
protected java.lang.Runnable timeout(CHC ctx, java.lang.String msg, AsyncPromise<java.lang.Void> timeoutFuture)
-
timeout
protected <T> java.lang.Runnable timeout(CHC ctx, java.lang.String msg, AsyncPromise<T> timeoutFuture, T value)
-
executor
protected abstract java.util.concurrent.Executor executor(CHC ctx)
-
handler
@Nonnull protected AsyncFuture<HR> handler(@Nonnull CHC ctx, @Nonnull BHS request) throws java.lang.Exception
- Throws:
java.lang.Exception
-
unwrapCompletion
protected static java.lang.Throwable unwrapCompletion(java.lang.Throwable ex)
-
statusOf
protected abstract HRS statusOf(int code)
-
multiStatus
protected abstract HRS multiStatus()
-
badRequest
protected abstract HRS badRequest()
-
gatewayTimeout
protected abstract HRS gatewayTimeout()
-
tooManyRequests
protected abstract HRS tooManyRequests()
-
serviceUnavailable
protected abstract HRS serviceUnavailable()
-
internalServerError
protected abstract HRS internalServerError()
-
isSuccessStatus
protected abstract boolean isSuccessStatus(HRS status)
-
isServiceUnavailable
protected abstract boolean isServiceUnavailable(HRS status)
-
getReasonPhrase
protected abstract java.lang.String getReasonPhrase(HRS status)
-
releaseRequest
protected boolean releaseRequest(BHS value)
-
releaseResponse
protected boolean releaseResponse(HR value)
-
isLastAttempt
protected boolean isLastAttempt(HRS status)
-
prepareRetry
@Nonnull protected AsyncFutureListener<HRS> prepareRetry(@Nonnull AsyncFuture<H> hostFuture, @Nonnull P path, @Nonnull BHS requestRef, @Nonnull R role, @Nonnull AsyncPromise<java.util.List<HR>> responseFuture, @Nonnull AsyncFuture<java.lang.Void> timeoutFuture, @Nonnull java.util.concurrent.Executor contextExecutor, @Nonnull HostHealthMonitor<H> hostHealthMonitor, @Nonnull ScatterGatherStats.Delta stats, Metrics m)
-
incrementTotalRetries
protected void incrementTotalRetries(ScatterGatherStats.Delta stats, HRS responseStatus)
-
incrementTotalRetriesError
protected void incrementTotalRetriesError(ScatterGatherStats.Delta stats, HRS responseStatus)
-
incrementTotalRetriesWinner
protected void incrementTotalRetriesWinner(ScatterGatherStats.Delta stats, HRS responseStatus)
-
getResponseCode
protected abstract int getResponseCode(HR response)
-
getResponseReadable
protected abstract int getResponseReadable(HR response)
-
hasErrorInStorageNodeResponse
protected abstract boolean hasErrorInStorageNodeResponse(HR response)
-
setKeepAlive
protected abstract void setKeepAlive(HR response, boolean keepAlive)
-
buildResponse
@Nonnull protected abstract HR buildResponse(@Nonnull BHS request, Metrics metrics, @Nonnull java.util.List<HR> gatheredResponses)
-
appendErrorsForOfflinePartitions
protected void appendErrorsForOfflinePartitions(@Nonnull BHS request, @Nonnull Scatter<H,P,K> scatter, @Nonnull java.util.List<AsyncFuture<java.util.List<HR>>> responseFutures)
-
appendErrorForEveryKey
protected java.util.concurrent.CompletionStage<?> appendErrorForEveryKey(@Nonnull BHS request, @Nonnull java.util.List<HR> responses, @Nonnull HRS status, java.lang.String contentMessage, java.lang.Throwable ex, @Nonnull ResourcePathParser<P,K> pathParser, @Nonnull ScatterGatherRequest<H,K> part, @Nonnull P basePath)
-
appendError
protected void appendError(@Nonnull BHS request, @Nonnull java.util.List<HR> responses, @Nonnull HRS status, java.lang.String contentMessage, java.lang.Throwable ex)
-
isTooLongFrameException
protected abstract boolean isTooLongFrameException(java.lang.Throwable cause)
- Specified by:
isTooLongFrameExceptionin classScatterGatherRequestHandler<H,P extends ResourcePath<K>,K,R>
-
buildExceptionResponse
@Nonnull protected HR buildExceptionResponse(@Nonnull BHS request, @Nonnull java.lang.Throwable cause)
-
buildErrorResponse
@Nonnull protected abstract HR buildErrorResponse(@Nonnull BHS request, @Nonnull HRS status, java.lang.String contentMessage, java.lang.Throwable ex)
-
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<java.util.List<HR>> responseFuture, @Nonnull AsyncPromise<HRS> retryFuture, @Nonnull AsyncFuture<java.lang.Void> timeoutFuture, @Nonnull java.util.concurrent.Executor contextExecutor)
-
-