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 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:
  • Field Details

  • Constructor Details

    • 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 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 of DruidService to 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:
      getName in class DruidService
    • getTier

      public String getTier()
    • getMaxSize

      public long getMaxSize()
    • getServerType

      public ServerType getServerType()
    • getPriority

      public int getPriority()
    • isDiscoverable

      public boolean isDiscoverable()
      Overrides:
      isDiscoverable in class DruidService
      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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object