Class 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 Detail

      • 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 server
        peon - Load queue peon for this server
        isDecommissioning - Whether the server is decommissioning
        maxSegmentsInLoadQueue - 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

      • getMaxSize

        public long getMaxSize()
      • getSizeUsed

        public long getSizeUsed()
        Total projected disk usage of this server in bytes.

        The total size:

        1. INCLUDES segments loaded on this server
        2. INCLUDES segments loading on this server (actions: LOAD/REPLICATE)
        3. INCLUDES segments moving to this server (action: MOVE_TO)
        4. 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.
        5. 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()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object