Package org.apache.druid.discovery
Class DataNodeService
- java.lang.Object
-
- org.apache.druid.discovery.DruidService
-
- org.apache.druid.discovery.DataNodeService
-
public class DataNodeService extends DruidService
Metadata announced by any node that serves segments. Note for JSON serialization and deserialization. This class has a bug that it has the "type" property which is the duplicate name with the subtype key ofDruidService. It seems to happen to work if the "type" subtype key appears first in the serialized JSON since Jackson uses the first "type" property as the subtype key. To always enforce this property order, this class does not use theJsonPropertyannotation for serialization, but usesDruidServiceSerializer. Since this is a hacky-way to not break compatibility, a new "serverType" field is added to replace the deprecated "type" field. Once we completely remove the "type" field from this class, we can remove DruidServiceSerializer as well. The set of properties to serialize is hard-coded in DruidServiceSerializer. If you want to add a new field in this class before we remove the "type" field, you must add a proper handling of that new field in DruidServiceSerializer as well. For deserialization, DruidServices are deserialized as a part ofDiscoveryDruidNode. To handle the bug of the duplicate "type" key, DiscoveryDruidNode first deserializes the JSON toStringObjectPairList, handles the duplicate "type" keys in the StringObjectPairList, and then finally converts it to a DruidService. SeeDiscoveryDruidNode.toMap(List).
-
-
Field Summary
Fields Modifier and Type Field Description static StringDISCOVERY_SERVICE_KEYstatic StringSERVER_TYPE_PROP_KEY
-
Constructor Summary
Constructors Constructor Description DataNodeService(String tier, long maxSize, ServerType serverType, int priority)DataNodeService(String tier, long maxSize, ServerType serverType, int priority, boolean isDiscoverable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static DataNodeServicefromJson(String tier, long maxSize, ServerType type, ServerType serverType, int priority)This JSON creator requires for the "type" subtype key ofDruidServiceto appear before the "type" property of this class in the serialized JSON.longgetMaxSize()StringgetName()intgetPriority()ServerTypegetServerType()StringgetTier()inthashCode()booleanisDiscoverable()StringtoString()
-
-
-
Field Detail
-
DISCOVERY_SERVICE_KEY
public static final String DISCOVERY_SERVICE_KEY
- See Also:
- Constant Field Values
-
SERVER_TYPE_PROP_KEY
public static final String SERVER_TYPE_PROP_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DataNodeService
public DataNodeService(String tier, long maxSize, ServerType serverType, int priority)
-
DataNodeService
public DataNodeService(String tier, long maxSize, ServerType serverType, int priority, boolean isDiscoverable)
-
-
Method Detail
-
fromJson
public static DataNodeService fromJson(String tier, long maxSize, @Deprecated @Nullable ServerType type, @Nullable ServerType serverType, int priority)
This JSON creator requires for the "type" subtype key ofDruidServiceto appear before the "type" property of this class in the serialized JSON. Deserialization can fail otherwise. See the Javadoc of this class for more details.
-
getName
public String getName()
- Specified by:
getNamein classDruidService
-
getTier
public String getTier()
-
getMaxSize
public long getMaxSize()
-
getServerType
public ServerType getServerType()
-
getPriority
public int getPriority()
-
isDiscoverable
public boolean isDiscoverable()
- Overrides:
isDiscoverablein classDruidService- Returns:
- Whether the service should be discoverable. The default implementation returns true. Some implementations may choose to override this so that the service is not discoverable if it has not been configured. This will not throw a fatal exception, but instead will just skip binding and log a message. This could be useful for optional configuration for the service.
-
-