Class VenicePath
- java.lang.Object
-
- com.linkedin.venice.router.api.path.VenicePath
-
- All Implemented Interfaces:
ResourcePath<RouterKey>
- Direct Known Subclasses:
VeniceMultiKeyPath
,VeniceSingleGetPath
public abstract class VenicePath extends java.lang.Object implements ResourcePath<RouterKey>
-
-
Field Summary
Fields Modifier and Type Field Description protected RetryManager
retryManager
protected java.lang.String
storeName
protected int
versionNumber
-
Constructor Summary
Constructors Constructor Description VenicePath(java.lang.String storeName, int versionNumber, java.lang.String resourceName, boolean smartLongTailRetryEnabled, int smartLongTailRetryAbortThresholdMs, RetryManager retryManager)
VenicePath(java.lang.String storeName, int versionNumber, java.lang.String resourceName, boolean smartLongTailRetryEnabled, int smartLongTailRetryAbortThresholdMs, Time time, RetryManager retryManager)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canRequestStorageNode(java.lang.String storageNode)
This function is used to check whether Router could send retry request to the specified storage node.org.apache.http.client.methods.HttpUriRequest
composeRouterRequest(java.lang.String storageNodeUri)
abstract org.apache.http.client.methods.HttpUriRequest
composeRouterRequestInternal(java.lang.String storageNodeUri)
abstract byte[]
getBody()
VeniceChunkedResponse
getChunkedResponse()
int
getHelixGroupId()
abstract io.netty.handler.codec.http.HttpMethod
getHttpMethod()
int
getLongTailRetryThresholdMs()
long
getOriginalRequestStartTs()
java.util.Collection<RouterKey>
getPartitionKeys()
long
getRequestId()
int
getRequestSize()
abstract RequestType
getRequestType()
java.lang.String
getResourceName()
VeniceResponseDecompressor
getResponseDecompressor()
java.util.Optional<java.util.Map<java.lang.CharSequence,java.lang.String>>
getResponseHeaders()
int
getSmartLongTailRetryAbortThresholdMs()
java.lang.String
getStoreName()
protected RequestType
getStreamingRequestType()
abstract java.lang.String
getVeniceApiVersionHeader()
int
getVersionNumber()
boolean
isLongTailRetryAllowedForNewRequest()
boolean
isLongTailRetryWithinBudget(int numberOfRoutes)
boolean
isRetryRequest()
boolean
isRetryRequestTooLate()
This function will check whether the retry request already passed the retry delay threshold.boolean
isSmartLongTailRetryEnabled()
boolean
isStreamingRequest()
void
markStorageNodeAsFast(java.lang.String fastStorageNode)
void
recordOriginalRequestStartTimestamp()
void
recordRequest()
void
requestStorageNode(java.lang.String storageNode)
void
setChunkedWriteHandler(io.netty.channel.ChannelHandlerContext ctx, VeniceChunkedWriteHandler chunkedWriteHandler, RouterStats<AggRouterHttpRequestStats> routerStats)
void
setHelixGroupId(int helixGroupId)
void
setLongTailRetryThresholdMs(int longTailRetryThresholdMs)
protected void
setPartitionKeys(java.util.Collection<RouterKey> keys)
void
setResponseDecompressor(VeniceResponseDecompressor decompressor)
void
setResponseHeaders(java.util.Map<java.lang.CharSequence,java.lang.String> responseHeaders)
void
setRetryRequest()
void
setRetryRequest(io.netty.handler.codec.http.HttpResponseStatus hrs)
If the inherited class wants to know whether the current path belongs to a retry request or not, it needs to implement this method properly to maintain the internal state.protected void
setupRetryRelatedInfo(VenicePath originalPath)
void
setupVeniceHeaders(java.util.function.BiConsumer<java.lang.String,java.lang.String> setupHeaderFunc)
abstract VenicePath
substitutePartitionKey(RouterKey s)
abstract VenicePath
substitutePartitionKey(java.util.Collection<RouterKey> s)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.alpini.router.api.ResourcePath
getLocation, getPartitionKey
-
-
-
-
Field Detail
-
storeName
protected final java.lang.String storeName
-
versionNumber
protected final int versionNumber
-
retryManager
protected final RetryManager retryManager
-
-
Constructor Detail
-
VenicePath
public VenicePath(java.lang.String storeName, int versionNumber, java.lang.String resourceName, boolean smartLongTailRetryEnabled, int smartLongTailRetryAbortThresholdMs, RetryManager retryManager)
-
VenicePath
public VenicePath(java.lang.String storeName, int versionNumber, java.lang.String resourceName, boolean smartLongTailRetryEnabled, int smartLongTailRetryAbortThresholdMs, Time time, RetryManager retryManager)
-
-
Method Detail
-
getRequestId
public long getRequestId()
-
getHelixGroupId
public int getHelixGroupId()
-
setHelixGroupId
public void setHelixGroupId(int helixGroupId)
-
isSmartLongTailRetryEnabled
public boolean isSmartLongTailRetryEnabled()
-
getSmartLongTailRetryAbortThresholdMs
public int getSmartLongTailRetryAbortThresholdMs()
-
setPartitionKeys
protected void setPartitionKeys(java.util.Collection<RouterKey> keys)
-
getPartitionKeys
@Nonnull public java.util.Collection<RouterKey> getPartitionKeys()
- Specified by:
getPartitionKeys
in interfaceResourcePath<RouterKey>
-
getRequestSize
public int getRequestSize()
-
getVersionNumber
public int getVersionNumber()
-
getResourceName
@Nonnull public java.lang.String getResourceName()
- Specified by:
getResourceName
in interfaceResourcePath<RouterKey>
-
getStoreName
public java.lang.String getStoreName()
-
setRetryRequest
public void setRetryRequest()
- Specified by:
setRetryRequest
in interfaceResourcePath<RouterKey>
-
setRetryRequest
public void setRetryRequest(io.netty.handler.codec.http.HttpResponseStatus hrs)
Description copied from interface:ResourcePath
If the inherited class wants to know whether the current path belongs to a retry request or not, it needs to implement this method properly to maintain the internal state.- Specified by:
setRetryRequest
in interfaceResourcePath<RouterKey>
-
setupRetryRelatedInfo
protected void setupRetryRelatedInfo(VenicePath originalPath)
-
isRetryRequest
public boolean isRetryRequest()
-
getOriginalRequestStartTs
public long getOriginalRequestStartTs()
-
getLongTailRetryThresholdMs
public int getLongTailRetryThresholdMs()
-
setLongTailRetryThresholdMs
public void setLongTailRetryThresholdMs(int longTailRetryThresholdMs)
-
requestStorageNode
public void requestStorageNode(java.lang.String storageNode)
-
markStorageNodeAsFast
public void markStorageNodeAsFast(java.lang.String fastStorageNode)
-
canRequestStorageNode
public boolean canRequestStorageNode(java.lang.String storageNode)
This function is used to check whether Router could send retry request to the specified storage node. It will return false if the requested storage node has been marked as slow.- Parameters:
storageNode
-- Returns:
-
recordOriginalRequestStartTimestamp
public void recordOriginalRequestStartTimestamp()
-
isRetryRequestTooLate
public boolean isRetryRequestTooLate()
This function will check whether the retry request already passed the retry delay threshold. If yes, return true.- Returns:
-
setupVeniceHeaders
public void setupVeniceHeaders(java.util.function.BiConsumer<java.lang.String,java.lang.String> setupHeaderFunc)
-
composeRouterRequest
public org.apache.http.client.methods.HttpUriRequest composeRouterRequest(java.lang.String storageNodeUri)
-
setChunkedWriteHandler
public void setChunkedWriteHandler(io.netty.channel.ChannelHandlerContext ctx, VeniceChunkedWriteHandler chunkedWriteHandler, RouterStats<AggRouterHttpRequestStats> routerStats)
-
setResponseHeaders
public void setResponseHeaders(java.util.Map<java.lang.CharSequence,java.lang.String> responseHeaders)
-
getResponseHeaders
public java.util.Optional<java.util.Map<java.lang.CharSequence,java.lang.String>> getResponseHeaders()
-
setResponseDecompressor
public void setResponseDecompressor(VeniceResponseDecompressor decompressor)
-
getResponseDecompressor
public VeniceResponseDecompressor getResponseDecompressor()
-
getChunkedResponse
public VeniceChunkedResponse getChunkedResponse()
-
isStreamingRequest
public boolean isStreamingRequest()
-
isLongTailRetryAllowedForNewRequest
public boolean isLongTailRetryAllowedForNewRequest()
-
getRequestType
public abstract RequestType getRequestType()
-
getStreamingRequestType
protected RequestType getStreamingRequestType()
-
substitutePartitionKey
public abstract VenicePath substitutePartitionKey(RouterKey s)
-
substitutePartitionKey
public abstract VenicePath substitutePartitionKey(@Nonnull java.util.Collection<RouterKey> s)
-
composeRouterRequestInternal
public abstract org.apache.http.client.methods.HttpUriRequest composeRouterRequestInternal(java.lang.String storageNodeUri)
-
getHttpMethod
public abstract io.netty.handler.codec.http.HttpMethod getHttpMethod()
-
getBody
public abstract byte[] getBody()
-
getVeniceApiVersionHeader
public abstract java.lang.String getVeniceApiVersionHeader()
-
recordRequest
public void recordRequest()
-
isLongTailRetryWithinBudget
public boolean isLongTailRetryWithinBudget(int numberOfRoutes)
-
-