Package org.apache.druid.client
Class DruidServer
- java.lang.Object
-
- org.apache.druid.client.DruidServer
-
- All Implemented Interfaces:
Comparable<DruidServer>
public class DruidServer extends Object implements Comparable<DruidServer>
A mutable collection of metadata of segments (DataSegmentobjects), stored on a particular Druid server (typically historical). This class should not be subclassed, it isn't declared final only to make it possible to mock the class with EasyMock in tests.- See Also:
- an immutable counterpart of this class
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_NUM_REPLICANTSstatic intDEFAULT_PRIORITYstatic StringDEFAULT_TIER
-
Constructor Summary
Constructors Constructor Description DruidServer(String name, String hostAndPort, String hostAndTlsPort, long maxSize, ServerType type, String tier, int priority)DruidServer(DruidNode node, DruidServerConfig config, ServerType type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DruidServeraddDataSegment(org.apache.druid.timeline.DataSegment segment)DruidServeraddDataSegments(DruidServer server)intcompareTo(DruidServer o)DruidServercopyWithoutSegments()booleanequals(Object o)longgetCurrSize()DruidDataSourcegetDataSource(String dataSource)Collection<DruidDataSource>getDataSources()StringgetHost()StringgetHostAndPort()StringgetHostAndTlsPort()longgetMaxSize()DruidServerMetadatagetMetadata()StringgetName()intgetPriority()StringgetScheme()org.apache.druid.timeline.DataSegmentgetSegment(org.apache.druid.timeline.SegmentId segmentId)StringgetTier()intgetTotalSegments()Returns the current number of segments, stored in this DruidServer object.ServerTypegetType()inthashCode()booleanisSegmentBroadcastTarget()booleanisSegmentReplicationOrBroadcastTarget()booleanisSegmentReplicationTarget()Iterable<org.apache.druid.timeline.DataSegment>iterateAllSegments()Returns an iterable to go over all segments in all data sources, stored on this DruidServer.org.apache.druid.timeline.DataSegmentremoveDataSegment(org.apache.druid.timeline.SegmentId segmentId)ImmutableDruidServertoImmutableDruidServer()StringtoString()
-
-
-
Field Detail
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
DEFAULT_NUM_REPLICANTS
public static final int DEFAULT_NUM_REPLICANTS
- See Also:
- Constant Field Values
-
DEFAULT_TIER
public static final String DEFAULT_TIER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DruidServer
public DruidServer(DruidNode node, DruidServerConfig config, ServerType type)
-
DruidServer
public DruidServer(String name, String hostAndPort, String hostAndTlsPort, long maxSize, ServerType type, String tier, int priority)
-
-
Method Detail
-
getName
public String getName()
-
getMetadata
public DruidServerMetadata getMetadata()
-
getHost
public String getHost()
-
getHostAndPort
public String getHostAndPort()
-
getHostAndTlsPort
public String getHostAndTlsPort()
-
getCurrSize
public long getCurrSize()
-
getMaxSize
public long getMaxSize()
-
getType
public ServerType getType()
-
getTier
public String getTier()
-
isSegmentReplicationTarget
public boolean isSegmentReplicationTarget()
-
isSegmentBroadcastTarget
public boolean isSegmentBroadcastTarget()
-
isSegmentReplicationOrBroadcastTarget
public boolean isSegmentReplicationOrBroadcastTarget()
-
getPriority
public int getPriority()
-
getScheme
public String getScheme()
-
iterateAllSegments
public Iterable<org.apache.druid.timeline.DataSegment> iterateAllSegments()
Returns an iterable to go over all segments in all data sources, stored on this DruidServer. The order in which segments are iterated is unspecified. Since this DruidServer can be mutated concurrently, the set of segments observed during an iteration may _not_ be a momentary snapshot of the segments on the server, in other words, it may be that there was no moment when the DruidServer stored exactly the returned set of segments. Note: the iteration may not be as trivially cheap as, for example, iteration over an ArrayList. Try (to some reasonable extent) to organize the code so that it iterates the returned iterable only once rather than several times.
-
getTotalSegments
public int getTotalSegments()
Returns the current number of segments, stored in this DruidServer object. This number if weakly consistent with the number of segments ifiterateAllSegments()is iterated about the same time, because segments might be added or removed in parallel.
-
getSegment
public org.apache.druid.timeline.DataSegment getSegment(org.apache.druid.timeline.SegmentId segmentId)
-
addDataSegment
public DruidServer addDataSegment(org.apache.druid.timeline.DataSegment segment)
-
addDataSegments
public DruidServer addDataSegments(DruidServer server)
-
removeDataSegment
@Nullable public org.apache.druid.timeline.DataSegment removeDataSegment(org.apache.druid.timeline.SegmentId segmentId)
-
getDataSource
public DruidDataSource getDataSource(String dataSource)
-
getDataSources
public Collection<DruidDataSource> getDataSources()
-
compareTo
public int compareTo(DruidServer o)
- Specified by:
compareToin interfaceComparable<DruidServer>
-
toImmutableDruidServer
public ImmutableDruidServer toImmutableDruidServer()
-
copyWithoutSegments
public DruidServer copyWithoutSegments()
-
-