Class QueryLifecycle

    • Constructor Detail

      • QueryLifecycle

        public QueryLifecycle​(org.apache.druid.query.QueryToolChestWarehouse warehouse,
                              org.apache.druid.query.QuerySegmentWalker texasRanger,
                              org.apache.druid.query.GenericQueryMetricsFactory queryMetricsFactory,
                              org.apache.druid.java.util.emitter.service.ServiceEmitter emitter,
                              RequestLogger requestLogger,
                              AuthorizerMapper authorizerMapper,
                              org.apache.druid.query.DefaultQueryConfig defaultQueryConfig,
                              AuthConfig authConfig,
                              long startMs,
                              long startNs)
    • Method Detail

      • runSimple

        public <T> QueryResponse<T> runSimple​(org.apache.druid.query.Query<T> query,
                                              AuthenticationResult authenticationResult,
                                              Access authorizationResult)
        For callers who have already authorized their query, and where simplicity is desired over flexibility. This method does it all in one call. Logs and metrics are emitted when the Sequence is either fully iterated or throws an exception.
        Parameters:
        query - the query
        authenticationResult - authentication result indicating identity of the requester
        authorizationResult - authorization result of requester
        Returns:
        results
      • initialize

        public void initialize​(org.apache.druid.query.Query<?> baseQuery)
        Initializes this object to execute a specific query. Does not actually execute the query.
        Parameters:
        baseQuery - the query
      • authorize

        public Access authorize​(javax.servlet.http.HttpServletRequest req)
        Authorize the query. Will return an Access object denoting whether the query is authorized or not.
        Parameters:
        req - HTTP request object of the request. If provided, the auth-related fields in the HTTP request will be automatically set.
        Returns:
        authorization result
      • authorize

        public Access authorize​(AuthenticationResult authenticationResult)
        Authorize the query using the authentication result. Will return an Access object denoting whether the query is authorized or not. This method is to be used by the grpc-query-extension.
        Parameters:
        authenticationResult - authentication result indicating identity of the requester
        Returns:
        authorization result of requester
      • execute

        public <T> QueryResponse<T> execute()
        Execute the query. Can only be called if the query has been authorized. Note that query logs and metrics will not be emitted automatically when the Sequence is fully iterated. It is the caller's responsibility to call emitLogsAndMetrics(Throwable, String, long) to emit logs and metrics.
        Returns:
        result sequence and response context
      • emitLogsAndMetrics

        public void emitLogsAndMetrics​(@Nullable
                                       Throwable e,
                                       @Nullable
                                       String remoteAddress,
                                       long bytesWritten)
        Emit logs and metrics for this query.
        Parameters:
        e - exception that occurred while processing this query
        remoteAddress - remote address, for logging; or null if unknown
        bytesWritten - number of bytes written; will become a query/bytes metric if >= 0
      • getQuery

        @Nullable
        public org.apache.druid.query.Query<?> getQuery()
      • getQueryId

        public String getQueryId()
      • threadName

        public String threadName​(String currThreadName)
      • getToolChest

        public org.apache.druid.query.QueryToolChest getToolChest()