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 protected
ScatterGatherRequestHandlerImpl(SCATTER_GATHER_HELPER scatterGatherHelper, TimeoutProcessor timeoutProcessor)
protected
ScatterGatherRequestHandlerImpl(SCATTER_GATHER_HELPER scatterGatherHelper, RouterTimeoutProcessor timeoutProcessor)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
appendError(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 void
appendErrorsForOfflinePartitions(BHS request, Scatter<H,P,K> scatter, java.util.List<AsyncFuture<java.util.List<HR>>> responseFutures)
protected abstract HRS
badRequest()
protected abstract HR
buildErrorResponse(BHS request, HRS status, java.lang.String contentMessage, java.lang.Throwable ex)
protected HR
buildExceptionResponse(BHS request, java.lang.Throwable cause)
protected abstract HR
buildResponse(BHS request, Metrics metrics, java.util.List<HR> gatheredResponses)
protected void
dispatch(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.Executor
executor(CHC ctx)
protected abstract HRS
gatewayTimeout()
protected abstract java.lang.String
getReasonPhrase(HRS status)
protected abstract int
getResponseCode(HR response)
protected abstract Headers
getResponseHeaders(HR response)
protected abstract int
getResponseReadable(HR response)
SCATTER_GATHER_HELPER
getScatterGatherHelper()
protected AsyncFuture<HR>
handler(CHC ctx, BHS request)
protected abstract boolean
hasErrorInStorageNodeResponse(HR response)
protected void
incrementTotalRetries(ScatterGatherStats.Delta stats)
protected void
incrementTotalRetriesError(ScatterGatherStats.Delta stats)
protected void
incrementTotalRetriesWinner(ScatterGatherStats.Delta stats)
protected abstract HRS
internalServerError()
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(java.lang.Throwable cause)
protected abstract HRS
multiStatus()
protected BHS
prepareRequest(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 boolean
releaseRequest(BHS value)
protected boolean
releaseResponse(HR value)
protected BHS
retainRequest(BHS value)
protected abstract HRS
serviceUnavailable()
protected abstract void
setKeepAlive(HR response, boolean keepAlive)
static void
setMetric(Metrics metric, MetricNames metricName, java.util.function.Supplier<TimeValue> supplier)
protected abstract HRS
statusOf(int code)
protected abstract java.lang.Runnable
timeout(CHC ctx, java.lang.Runnable task)
protected java.lang.Runnable
timeout(CHC ctx, java.lang.String msg, AsyncPromise<java.lang.Void> timeoutFuture)
protected <T> java.lang.Runnable
timeout(CHC ctx, java.lang.String msg, AsyncPromise<T> timeoutFuture, T value)
protected static java.lang.Throwable
unwrapCompletion(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:
getScatterGatherHelper
in 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()
-
serviceUnavailable
protected abstract HRS serviceUnavailable()
-
internalServerError
protected abstract HRS internalServerError()
-
isSuccessStatus
protected abstract boolean isSuccessStatus(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)
-
incrementTotalRetriesError
protected void incrementTotalRetriesError(ScatterGatherStats.Delta stats)
-
incrementTotalRetriesWinner
protected void incrementTotalRetriesWinner(ScatterGatherStats.Delta stats)
-
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:
isTooLongFrameException
in 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)
-
-