Class EsqlExecutionInfo
java.lang.Object
org.elasticsearch.xpack.esql.action.EsqlExecutionInfo
- All Implemented Interfaces:
Writeable,ChunkedToXContent,ChunkedToXContentObject
Holds execution metadata about ES|QL queries for cross-cluster searches in order to display
this information in ES|QL JSON responses.
Patterned after the SearchResponse.Clusters and SearchResponse.Cluster classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the search metadata about a particular cluster involved in a cross-cluster search.static enumNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldstatic final TransportVersionstatic final TransportVersionstatic final TransportVersionstatic final ParseFieldstatic final ParseFieldstatic final Stringstatic final Stringstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldFields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionEsqlExecutionInfo(Predicate<String> skipOnPlanTimeFailurePredicate, EsqlExecutionInfo.IncludeExecutionMetadata includeExecutionMetadata) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStopHook(BooleanSupplier hook) Registers a hook thatrunStopHooks()fires when the user requests async STOP for this query.voidclusterInfoInitializing(boolean clusterInfoInitializing) booleanvoidgetCluster(String clusterAlias) inthashCode()booleanIs there any metadata to report in the response? This is true on cross-cluster search with includeCCSMetadata=true or when there are partial failures.booleanvoidinitCluster(String clusterAlias, String localCusterName, String indexExpression) This creates an initial Cluster object with indexExpression and skipUnavailable.booleanbooleanbooleanbooleanbooleanvoidvoidCall when ES|QL execution is complete in order to set the overall took time for an ES|QL query.voidMarks the overall result as partial directly, independent of the per-cluster status path used for shard/node failures.voidRemoves a previously-registered stop hook.booleanFires all registered stop hooks and returnstrueif at least one hook reported that it cut a live unit of work.booleanshouldSkipOnFailure(String clusterAlias) voidstartSubPlans(boolean isSubqueryJoin) swapCluster(String clusterAlias, BiFunction<String, EsqlExecutionInfo.Cluster, EsqlExecutionInfo.Cluster> remappingFunction) Utility to swap a Cluster object.toString()Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params) voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunked, toXContentChunkedV8Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragment
-
Field Details
-
LOCAL_CLUSTER_NAME_REPRESENTATION
- See Also:
-
ORIGIN_CLUSTER_NAME_REPRESENTATION
- See Also:
-
TOTAL_FIELD
-
SUCCESSFUL_FIELD
-
SKIPPED_FIELD
-
RUNNING_FIELD
-
PARTIAL_FIELD
-
FAILED_FIELD
-
DETAILS_FIELD
-
TOOK
-
IS_PARTIAL_FIELD
-
EXECUTION_METADATA_VERSION
-
EXECUTION_CLUSTER_NAME_VERSION
-
EXECUTION_PROFILE_FORMAT_VERSION
-
clusterInfo
-
-
Constructor Details
-
EsqlExecutionInfo
public EsqlExecutionInfo(Predicate<String> skipOnPlanTimeFailurePredicate, EsqlExecutionInfo.IncludeExecutionMetadata includeExecutionMetadata) - Parameters:
skipOnPlanTimeFailurePredicate- Decides whether we should skip the cluster that fails during planning phase.includeExecutionMetadata- (user defined setting) whether to include the execution/CCS metadata in the HTTP response
-
EsqlExecutionInfo
- Throws:
IOException
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
includeCCSMetadata
public boolean includeCCSMetadata() -
includeExecutionMetadata
-
markEndQuery
public void markEndQuery()Call when ES|QL execution is complete in order to set the overall took time for an ES|QL query. -
overallTook
-
clusterAliases
-
queryProfile
-
shouldSkipOnFailure
- Parameters:
clusterAlias- to check if we should skip this cluster on failure- Returns:
- whether it's OK to skip the cluster on failure.
- Throws:
NoSuchRemoteClusterException- if clusterAlias is unknown to this node's RemoteClusterService
-
isCrossClusterSearch
public boolean isCrossClusterSearch() -
hasMetadataToReport
public boolean hasMetadataToReport()Is there any metadata to report in the response? This is true on cross-cluster search with includeCCSMetadata=true or when there are partial failures. -
getCluster
-
getClusters
-
initCluster
This creates an initial Cluster object with indexExpression and skipUnavailable. -
swapCluster
public EsqlExecutionInfo.Cluster swapCluster(String clusterAlias, BiFunction<String, EsqlExecutionInfo.Cluster, EsqlExecutionInfo.Cluster> remappingFunction) Utility to swap a Cluster object. Guidelines for the remapping function:- The remapping function should return a new Cluster object to swap it for the existing one.
- If in the remapping function you decide to abort the swap you must return the original Cluster object to keep the map unchanged.
- Do not return
null. If the remapping function returnsnull, the mapping is removed (or remains absent if initially absent). - If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged. Throwing exception therefore is OK, but it is generally discouraged.
- The remapping function may be called multiple times in a CAS fashion underneath, make sure that is safe to do so.
- Parameters:
clusterAlias- key with which the specified value is associatedremappingFunction- function to swap the oldCluster to a newCluster- Returns:
- the new Cluster object
-
toXContentChunked
- Specified by:
toXContentChunkedin interfaceChunkedToXContent
-
getClusterStates
- Parameters:
status- the status you want to access- Returns:
- a stream of clusters with that status
-
getRunningClusterAliases
-
toString
-
equals
-
hashCode
public int hashCode() -
isPartial
public boolean isPartial() -
markPartial
public void markPartial()Marks the overall result as partial directly, independent of the per-cluster status path used for shard/node failures. This is required for pure external-source queries (e.g.EXTERNAL "file://..."), which carry noclusterInfoentry to driveswapCluster(java.lang.String, java.util.function.BiFunction<java.lang.String, org.elasticsearch.xpack.esql.action.EsqlExecutionInfo.Cluster, org.elasticsearch.xpack.esql.action.EsqlExecutionInfo.Cluster>)— so a lenient external read that drops data (e.g. amax_record_sizetruncation under a non-stricterror_mode) has no cluster to flip. Sticky like the cluster-driven path: once partial, always partial. -
markAsStopped
public void markAsStopped() -
isStopped
public boolean isStopped() -
addStopHook
Registers a hook thatrunStopHooks()fires when the user requests async STOP for this query. The hook should returntrueonly on the transition from running to finishing — seestopHooksfor the rationale. -
removeStopHook
Removes a previously-registered stop hook. Callers register per-phase hooks (e.g. one per driver in aComputeService.runComputeinvocation) and must invoke this on phase completion so the async task's stop-hook list doesn't retain references to closed drivers/contexts for the whole task lifetime — coordinator reductions and subplans invokerunComputemultiple times under the same task, and cleared hooks would otherwise no-op but keep the driver-graph reachable. Uses reference equality viaList.remove(Object), so callers must pass the exact sameBooleanSupplierinstance previously registered. -
runStopHooks
public boolean runStopHooks()Fires all registered stop hooks and returnstrueif at least one hook reported that it cut a live unit of work. Callers can use this to decide whether STOP truncated the query (and therefore the response should be flaggedis_partial=true) or whether STOP merely raced with natural completion (in which case the response is honestly complete).No wrapping try/catch here: today's hooks are
Driver::runStopHookswhich delegates toDriverContext.runStopHooks(), and that already isolates per-hook failures so one misbehaving operator can't sink the STOP response. Any exception escaping this loop is a bug in a caller (added a hook that doesn't respect the contract) and should surface loudly. -
clusterInfoInitializing
public void clusterInfoInitializing(boolean clusterInfoInitializing) -
isMainPlan
public boolean isMainPlan() -
startSubPlans
public void startSubPlans(boolean isSubqueryJoin) -
isSubqueryJoinSubPlan
public boolean isSubqueryJoinSubPlan() -
finishSubPlans
public void finishSubPlans()
-