Package org.apache.druid.discovery
Class DataNodeService
java.lang.Object
org.apache.druid.discovery.DruidService
org.apache.druid.discovery.DataNodeService
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 of
DruidService. 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 the JsonProperty annotation for serialization,
but uses DruidServiceSerializer.
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 of DiscoveryDruidNode.
To handle the bug of the duplicate "type" key, DiscoveryDruidNode first deserializes
the JSON to StringObjectPairList,
handles the duplicate "type" keys in the StringObjectPairList,
and then finally converts it to a DruidService. See DiscoveryDruidNode.toMap(List).- See Also:
-
DruidServiceSerializerDiscoveryDruidNode.toMap(List)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataNodeService(String tier, long maxSize, ServerType serverType, int priority) DataNodeService(String tier, long maxSize, ServerType serverType, int priority, boolean isDiscoverable) -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic 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.longgetName()intgetTier()inthashCode()booleantoString()
-
Field Details
-
DISCOVERY_SERVICE_KEY
- See Also:
-
SERVER_TYPE_PROP_KEY
- See Also:
-
-
Constructor Details
-
DataNodeService
-
DataNodeService
public DataNodeService(String tier, long maxSize, ServerType serverType, int priority, boolean isDiscoverable)
-
-
Method Details
-
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
- Specified by:
getNamein classDruidService
-
getTier
-
getMaxSize
public long getMaxSize() -
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.
-
equals
-
hashCode
public int hashCode() -
toString
-