Class ServerHolder
- java.lang.Object
-
- org.apache.druid.server.coordinator.ServerHolder
-
- All Implemented Interfaces:
Comparable<ServerHolder>
public class ServerHolder extends Object implements Comparable<ServerHolder>
Encapsulates the state of a DruidServer during a single coordinator run.ServerHolders are naturally ordered by available size, servers with more available size first.
-
-
Constructor Summary
Constructors Constructor Description ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon)ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon, boolean isDecommissioning)ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon, boolean isDecommissioning, int maxSegmentsInLoadQueue, int maxLifetimeInQueue)Creates a new ServerHolder valid for a single coordinator run.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancelOperation(SegmentAction action, org.apache.druid.timeline.DataSegment segment)booleancanLoadSegment(org.apache.druid.timeline.DataSegment segment)Checks if the server can load the given segment.intcompareTo(ServerHolder serverHolder)booleanequals(Object o)SegmentActiongetActionOnSegment(org.apache.druid.timeline.DataSegment segment)longgetAvailableSize()List<org.apache.druid.timeline.DataSegment>getLoadingSegments()Segments that are currently in the queue for being loaded on this server.longgetMaxSize()intgetNumLoadingReplicas()intgetNumMovingSegments()intgetNumQueuedSegments()LoadQueuePeongetPeon()doublegetPercentUsed()SegmentCountsPerIntervalgetProjectedSegments()Segments that are expected to be loaded on this server once all the operations in progress have completed.Map<org.apache.druid.timeline.DataSegment,SegmentAction>getQueuedSegments()Segments queued for load, drop or move on this server.Collection<org.apache.druid.timeline.DataSegment>getServedSegments()Segments that are currently loaded on this server.ImmutableDruidServergetServer()longgetSizeUsed()Total projected disk usage of this server in bytes.inthashCode()booleanisDecommissioning()booleanisDroppingSegment(org.apache.druid.timeline.DataSegment segment)booleanisLoadingSegment(org.apache.druid.timeline.DataSegment segment)booleanisLoadQueueFull()booleanisProjectedSegment(org.apache.druid.timeline.DataSegment segment)booleanisRealtimeServer()booleanisServingSegment(org.apache.druid.timeline.DataSegment segment)Returns true if this server has the segment loaded and is not dropping it.booleanstartOperation(SegmentAction action, org.apache.druid.timeline.DataSegment segment)StringtoString()
-
-
-
Constructor Detail
-
ServerHolder
public ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon)
-
ServerHolder
public ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon, boolean isDecommissioning)
-
ServerHolder
public ServerHolder(ImmutableDruidServer server, LoadQueuePeon peon, boolean isDecommissioning, int maxSegmentsInLoadQueue, int maxLifetimeInQueue)
Creates a new ServerHolder valid for a single coordinator run.- Parameters:
server- Underlying Druid serverpeon- Load queue peon for this serverisDecommissioning- Whether the server is decommissioningmaxSegmentsInLoadQueue- Max number of segments that can be present in the load queue at any point. If this is 0, the load queue can have an unlimited number of segments.maxLifetimeInQueue- Number of coordinator runs after a which a segment in load/drop queue is considered to be stuck.
-
-
Method Detail
-
getServer
public ImmutableDruidServer getServer()
-
getPeon
public LoadQueuePeon getPeon()
-
getMaxSize
public long getMaxSize()
-
getSizeUsed
public long getSizeUsed()
Total projected disk usage of this server in bytes.The total size:
- INCLUDES segments loaded on this server
- INCLUDES segments loading on this server (actions: LOAD/REPLICATE)
- INCLUDES segments moving to this server (action: MOVE_TO)
- INCLUDES segments moving from this server (action: MOVE_FROM). This is because these segments have only been marked for drop. We include the size of these segments to avoid over-assigning the server in case the corresponding MOVE_TO operation gets delayed or fails.
- EXCLUDES segments dropping from this server (action: DROP). Excluding these segments cannot result in over-assignment because drops are always processed before loads.
-
getPercentUsed
public double getPercentUsed()
-
isDecommissioning
public boolean isDecommissioning()
-
isLoadQueueFull
public boolean isLoadQueueFull()
-
getAvailableSize
public long getAvailableSize()
-
canLoadSegment
public boolean canLoadSegment(org.apache.druid.timeline.DataSegment segment)
Checks if the server can load the given segment.A load is possible only if the server meets all of the following criteria:
- is not being decommissioned
- is not already serving the segment
- is not performing any other action on the segment
- has not already exceeded the load queue limit in this run
- has available disk space
-
getActionOnSegment
public SegmentAction getActionOnSegment(org.apache.druid.timeline.DataSegment segment)
-
getQueuedSegments
public Map<org.apache.druid.timeline.DataSegment,SegmentAction> getQueuedSegments()
Segments queued for load, drop or move on this server.- Contains segments present in the queue when the current coordinator run started.
- Contains segments added to the queue during the current run.
- Maps replicating segments to LOAD rather than REPLICATE for simplicity.
- Does not contain segments whose actions were cancelled.
-
getProjectedSegments
public SegmentCountsPerInterval getProjectedSegments()
Segments that are expected to be loaded on this server once all the operations in progress have completed.
-
isProjectedSegment
public boolean isProjectedSegment(org.apache.druid.timeline.DataSegment segment)
-
getLoadingSegments
public List<org.apache.druid.timeline.DataSegment> getLoadingSegments()
Segments that are currently in the queue for being loaded on this server. This does not include segments that are being moved to this server.
-
getServedSegments
public Collection<org.apache.druid.timeline.DataSegment> getServedSegments()
Segments that are currently loaded on this server.
-
isServingSegment
public boolean isServingSegment(org.apache.druid.timeline.DataSegment segment)
Returns true if this server has the segment loaded and is not dropping it.
-
isLoadingSegment
public boolean isLoadingSegment(org.apache.druid.timeline.DataSegment segment)
-
isDroppingSegment
public boolean isDroppingSegment(org.apache.druid.timeline.DataSegment segment)
-
getNumMovingSegments
public int getNumMovingSegments()
-
getNumLoadingReplicas
public int getNumLoadingReplicas()
-
getNumQueuedSegments
public int getNumQueuedSegments()
-
startOperation
public boolean startOperation(SegmentAction action, org.apache.druid.timeline.DataSegment segment)
-
cancelOperation
public boolean cancelOperation(SegmentAction action, org.apache.druid.timeline.DataSegment segment)
-
isRealtimeServer
public boolean isRealtimeServer()
-
compareTo
public int compareTo(ServerHolder serverHolder)
- Specified by:
compareToin interfaceComparable<ServerHolder>
-
-