Package com.linkedin.venice.router.api
Class VeniceDispatcher
java.lang.Object
com.linkedin.venice.router.api.VeniceDispatcher
- All Implemented Interfaces:
PartitionDispatchHandler<Instance,
,VenicePath, RouterKey, BasicHttpRequest, io.netty.handler.codec.http.FullHttpResponse, io.netty.handler.codec.http.HttpResponseStatus> PartitionDispatchHandler4<Instance,
VenicePath, RouterKey>
public final class VeniceDispatcher
extends Object
implements PartitionDispatchHandler4<Instance,VenicePath,RouterKey>
-
Constructor Summary
ConstructorDescriptionVeniceDispatcher
(VeniceRouterConfig config, ReadOnlyStoreRepository storeRepository, RouterStats<AggRouterHttpRequestStats> perStoreStatsByType, io.tehuti.metrics.MetricsRepository metricsRepository, StorageNodeClient storageNodeClient, RouteHttpRequestStats routeHttpRequestStats, AggHostHealthStats aggHostHealthStats, RouterStats<AggRouterHttpRequestStats> routerStats) -
Method Summary
Modifier and TypeMethodDescriptionprotected VeniceFullHttpResponse
buildPlainTextResponse
(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf content) protected VeniceFullHttpResponse
buildResponse
(VenicePath path, PortableHttpResponse serverResponse) void
dispatch
(Scatter<Instance, VenicePath, RouterKey> scatter, ScatterGatherRequest<Instance, RouterKey> part, VenicePath path, BasicHttpRequest request, AsyncPromise<Instance> hostSelected, AsyncPromise<List<io.netty.handler.codec.http.FullHttpResponse>> responseFuture, AsyncPromise<io.netty.handler.codec.http.HttpResponseStatus> retryFuture, AsyncFuture<Void> timeoutFuture, Executor executor) Performs the work.For TEST ONLYFor TEST ONLYprotected CompletableFuture<PortableHttpResponse>
sendRequest
(Instance storageNode, VenicePath path, AsyncPromise<io.netty.handler.codec.http.HttpResponseStatus> retryFuture) void
stop()
-
Constructor Details
-
VeniceDispatcher
public VeniceDispatcher(VeniceRouterConfig config, ReadOnlyStoreRepository storeRepository, RouterStats<AggRouterHttpRequestStats> perStoreStatsByType, io.tehuti.metrics.MetricsRepository metricsRepository, StorageNodeClient storageNodeClient, RouteHttpRequestStats routeHttpRequestStats, AggHostHealthStats aggHostHealthStats, RouterStats<AggRouterHttpRequestStats> routerStats)
-
-
Method Details
-
dispatch
public void dispatch(@Nonnull Scatter<Instance, VenicePath, throws RouterExceptionRouterKey> scatter, @Nonnull ScatterGatherRequest<Instance, RouterKey> part, @Nonnull VenicePath path, @Nonnull BasicHttpRequest request, @Nonnull AsyncPromise<Instance> hostSelected, @Nonnull AsyncPromise<List<io.netty.handler.codec.http.FullHttpResponse>> responseFuture, @Nonnull AsyncPromise<io.netty.handler.codec.http.HttpResponseStatus> retryFuture, @Nonnull AsyncFuture<Void> timeoutFuture, @Nonnull Executor executor) Description copied from interface:PartitionDispatchHandler
Performs the work.- Specified by:
dispatch
in interfacePartitionDispatchHandler<Instance,
VenicePath, RouterKey, BasicHttpRequest, io.netty.handler.codec.http.FullHttpResponse, io.netty.handler.codec.http.HttpResponseStatus> - Parameters:
scatter
- The scatter-gather request.part
- The part of the scatter-gather request to be executed.path
- The derived path of this part of the request.request
- The original HttpRequest object.hostSelected
- To be completed with the actual host selected.responseFuture
- To be completed with HttpResponse parts.retryFuture
- To be completed with the HttpResponseStatus.timeoutFuture
- Listen for timeout.executor
- For executing work on context executor. A single thread is available for each request. For efficiency, the AsyncPromises should be completed on the context executor thread.- Throws:
RouterException
-
sendRequest
protected CompletableFuture<PortableHttpResponse> sendRequest(Instance storageNode, VenicePath path, AsyncPromise<io.netty.handler.codec.http.HttpResponseStatus> retryFuture) throws RouterException - Throws:
RouterException
-
buildResponse
protected VeniceFullHttpResponse buildResponse(VenicePath path, PortableHttpResponse serverResponse) throws IOException - Throws:
IOException
-
getRouteHttpRequestStats
For TEST ONLY -
getPendingRequestThrottler
For TEST ONLY -
buildPlainTextResponse
protected VeniceFullHttpResponse buildPlainTextResponse(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf content) -
stop
public void stop()
-