Class ResponseContext.Keys

java.lang.Object
org.apache.druid.query.context.ResponseContext.Keys
Enclosing class:
ResponseContext

public static class ResponseContext.Keys extends Object
Global registry of response context keys. Also defines the standard keys associated with objects in the context.

If it's necessary to add new keys in the context then they should be listed in a separate class:

invalid input: '{@code
 public class SomeClass
 {
   static final Key EXTENSION_KEY_1 = new StringKey(
      "extension_key_1", Visibility.HEADER_AND_TRAILER, true),
   static final Key EXTENSION_KEY_2 = new CounterKey(
      "extension_key_2", Visibility.None);

   static {
     Keys.instance().registerKeys(new Key[] {
        EXTENSION_KEY_1,
        EXTENSION_KEY_2
     });
   }
 }</pre>
 Make sure all extension keys are added with the {@link #registerKey(Key)} or
 {@link #registerKeys(Key[])} methods.
 <p>
 Create custom keys in one of two ways. As shown above, predefined key types
 exist for common values. Custom values can be created as shown in the code
 for this class.'
  • Field Details

    • UNCOVERED_INTERVALS

      public static final ResponseContext.Key UNCOVERED_INTERVALS
      Lists intervals for which NO segment is present.
    • UNCOVERED_INTERVALS_OVERFLOWED

      public static final ResponseContext.Key UNCOVERED_INTERVALS_OVERFLOWED
      Indicates if the number of uncovered intervals exceeded the limit (true/false).
    • REMAINING_RESPONSES_FROM_QUERY_SERVERS

      public static final ResponseContext.Key REMAINING_RESPONSES_FROM_QUERY_SERVERS
      Map of most relevant query ID to remaining number of responses from query nodes. The value is initialized in CachingClusteredClient when it initializes the connection to the query nodes, and is updated whenever they respond (@code DirectDruidClient). RetryQueryRunner uses this value to check if the MISSING_SEGMENTS is valid.

      Currently, the broker doesn't run subqueries in parallel, the remaining number of responses will be updated one by one per subquery. However, since it can be parallelized to run subqueries simultaneously, we store them in a ConcurrentHashMap.

      See Also:
    • MISSING_SEGMENTS

      public static final ResponseContext.Key MISSING_SEGMENTS
      Lists missing segments.
    • ETAG

      public static final ResponseContext.Key ETAG
      Entity tag. A part of HTTP cache validation mechanism. Is being removed from the context before sending and used as a separate HTTP header.
    • QUERY_TOTAL_BYTES_GATHERED

      public static final ResponseContext.Key QUERY_TOTAL_BYTES_GATHERED
      Query total bytes gathered.
    • QUERY_FAIL_DEADLINE_MILLIS

      public static final ResponseContext.Key QUERY_FAIL_DEADLINE_MILLIS
      Query fail time (current time + timeout).
    • TIMEOUT_AT

      public static final ResponseContext.Key TIMEOUT_AT
      This variable indicates when a running query should be expired, and is effective only when 'timeout' of queryContext has a positive value.
    • NUM_SCANNED_ROWS

      public static final ResponseContext.Key NUM_SCANNED_ROWS
      The number of rows scanned by ScanQueryEngine.

      Named "count" for backwards compatibility with older data servers that still send this, even though it's now marked as internal.

    • CPU_CONSUMED_NANOS

      public static final ResponseContext.Key CPU_CONSUMED_NANOS
      The total CPU time for threads related to Sequence processing of the query. Resulting value on a Broker is a sum of downstream values from historicals / realtime nodes. For additional information see CPUTimeMetricQueryRunner
    • TRUNCATED

      public static final ResponseContext.Key TRUNCATED
      Indicates if a ResponseContext was truncated during serialization.
    • INSTANCE

      public static final ResponseContext.Keys INSTANCE
      One and only global list of keys. This is a semi-constant: it is mutable at start-up time, but then is not thread-safe, and must remain unchanged for the duration of the server run.
  • Method Details

    • instance

      public static ResponseContext.Keys instance()
      Returns the single, global key registry for this server.
    • registerKey

      public void registerKey(ResponseContext.Key key)
      Primary way of registering context keys.
      Throws:
      IllegalArgumentException - if the key has already been registered.
    • registerKeys

      public void registerKeys(ResponseContext.Key[] keys)
      Register a group of keys.
    • keyOf

      public ResponseContext.Key keyOf(String name)
      Returns a registered key associated with the name .
      Throws:
      IllegalStateException - if a corresponding key has not been registered.
    • find

      public ResponseContext.Key find(String name)
      Returns a registered key associated with the given name, or null if the key is not registered. This form is for testing and for deserialization when the existence of the key is suspect.