Class HelixGroupLeastLoadedStrategy
- java.lang.Object
-
- com.linkedin.venice.router.api.routing.helix.HelixGroupLeastLoadedStrategy
-
- All Implemented Interfaces:
HelixGroupSelectionStrategy
public class HelixGroupLeastLoadedStrategy extends java.lang.Object implements HelixGroupSelectionStrategy
This strategy is tried to distribute more load to Helix Groups with more capacity. Since the qps to a specific Router is not that high, so it is acceptable to use synchronized method here. TODO: if we notice a performance issue with the synchronized implementation, we could tune it better to use Atomic data structures by sacrificing the accuracy. This class is also leveragingTimeoutProcessor
to handle potential group counter leaking issue.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_ALLOWED_GROUP
-
Constructor Summary
Constructors Constructor Description HelixGroupLeastLoadedStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finishRequest(long requestId, int groupId)
Notify the corresponding Helix Group that the request is completed, and the implementation will decide whether any cleanup is required or not.int
getAvgGroupPendingRequest()
Get the average of the pending requests among all the groupsint
getMaxGroupPendingRequest()
Get the maximum of the pending requests among all the groupsint
getMinGroupPendingRequest()
Get the minimum of the pending requests among all the groupsint
selectGroup(long requestId, int groupCount)
Select a Helix Group for the current request.
-
-
-
Field Detail
-
MAX_ALLOWED_GROUP
public static final int MAX_ALLOWED_GROUP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HelixGroupLeastLoadedStrategy
public HelixGroupLeastLoadedStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS)
-
-
Method Detail
-
selectGroup
public int selectGroup(long requestId, int groupCount)
Description copied from interface:HelixGroupSelectionStrategy
Select a Helix Group for the current request.- Specified by:
selectGroup
in interfaceHelixGroupSelectionStrategy
-
finishRequest
public void finishRequest(long requestId, int groupId)
Description copied from interface:HelixGroupSelectionStrategy
Notify the corresponding Helix Group that the request is completed, and the implementation will decide whether any cleanup is required or not.- Specified by:
finishRequest
in interfaceHelixGroupSelectionStrategy
-
getMaxGroupPendingRequest
public int getMaxGroupPendingRequest()
Description copied from interface:HelixGroupSelectionStrategy
Get the maximum of the pending requests among all the groups- Specified by:
getMaxGroupPendingRequest
in interfaceHelixGroupSelectionStrategy
-
getMinGroupPendingRequest
public int getMinGroupPendingRequest()
Description copied from interface:HelixGroupSelectionStrategy
Get the minimum of the pending requests among all the groups- Specified by:
getMinGroupPendingRequest
in interfaceHelixGroupSelectionStrategy
-
getAvgGroupPendingRequest
public int getAvgGroupPendingRequest()
Description copied from interface:HelixGroupSelectionStrategy
Get the average of the pending requests among all the groups- Specified by:
getAvgGroupPendingRequest
in interfaceHelixGroupSelectionStrategy
-
-