Class NodeRole


  • public class NodeRole
    extends Object
    Defines the 'role' of a Druid service, utilized to strongly type announcement and service discovery. Originally, this was an enum to add type safety for discovery and announcement purposes, but was expanded into a class to allow for extensibility while retaining the type safety of using defined types instead of raw strings. As such, this class tries to mimic the interface provided by the previous enum. Built in node roles define a name that is distinct from jsonName, and is the previous value which would occur when the enum was used in a 'toString' context. Custom node roles allow extension to participate in announcement and discovery, but are limited to only using jsonName for both toString and JSON serde. The historical context of why the enum was different from ServerType (also called "node type" in various places) is because while they are essentially the same abstraction, merging them could only increase the complexity and drop the code safety, because they name the same types differently ("peon" - "indexer-executor" and "middleManager" - "realtime") and both expose them via JSON APIs. These abstractions can all potentially be merged when Druid updates to Jackson 2.9 that supports JsonAliases, see https://github.com/apache/druid/issues/7152.