Package org.apache.druid.query.context
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:
{@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 }); } }
Make sure all extension keys are added with the {@link #registerKey(Key)} or {@link #registerKeys(Key[])} methods.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 Summary
Fields Modifier and Type Field Description static ResponseContext.Key
CPU_CONSUMED_NANOS
The total CPU time for threads related to Sequence processing of the query.static ResponseContext.Key
ETAG
Entity tag.static ResponseContext.Keys
INSTANCE
One and only global list of keys.static ResponseContext.Key
MISSING_SEGMENTS
Lists missing segments.static ResponseContext.Key
NUM_SCANNED_ROWS
The number of rows scanned byScanQueryEngine
.static ResponseContext.Key
QUERY_FAIL_DEADLINE_MILLIS
Query fail time (current time + timeout).static ResponseContext.Key
QUERY_TOTAL_BYTES_GATHERED
Query total bytes gathered.static ResponseContext.Key
REMAINING_RESPONSES_FROM_QUERY_SERVERS
Map of most relevant query ID to remaining number of responses from query nodes.static 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.static ResponseContext.Key
TRUNCATED
Indicates if aResponseContext
was truncated during serialization.static ResponseContext.Key
UNCOVERED_INTERVALS
Lists intervals for which NO segment is present.static ResponseContext.Key
UNCOVERED_INTERVALS_OVERFLOWED
Indicates if the number of uncovered intervals exceeded the limit (true/false).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseContext.Key
find(String name)
Returns a registered key associated with the given name, ornull
if the key is not registered.static ResponseContext.Keys
instance()
Returns the single, global key registry for this server.ResponseContext.Key
keyOf(String name)
Returns a registered key associated with the name {@param name}.void
registerKey(ResponseContext.Key key)
Primary way of registering context keys.void
registerKeys(ResponseContext.Key[] keys)
Register a group of keys.
-
-
-
Field Detail
-
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 inCachingClusteredClient
when it initializes the connection to the query nodes, and is updated whenever they respond (@code DirectDruidClient).RetryQueryRunner
uses this value to check if theMISSING_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:
Query.getMostSpecificId()
-
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 byScanQueryEngine
.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 seeCPUTimeMetricQueryRunner
-
TRUNCATED
public static final ResponseContext.Key TRUNCATED
Indicates if aResponseContext
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 Detail
-
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 {@param 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, ornull
if the key is not registered. This form is for testing and for deserialization when the existence of the key is suspect.
-
-