Class EsqlExecutionInfo

java.lang.Object
org.elasticsearch.xpack.esql.action.EsqlExecutionInfo
All Implemented Interfaces:
Writeable, ChunkedToXContent, ChunkedToXContentObject

public class EsqlExecutionInfo extends Object implements ChunkedToXContentObject, Writeable
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.
  • Field Details

    • LOCAL_CLUSTER_NAME_REPRESENTATION

      public static final String LOCAL_CLUSTER_NAME_REPRESENTATION
      See Also:
    • TOTAL_FIELD

      public static final org.elasticsearch.xcontent.ParseField TOTAL_FIELD
    • SUCCESSFUL_FIELD

      public static final org.elasticsearch.xcontent.ParseField SUCCESSFUL_FIELD
    • SKIPPED_FIELD

      public static final org.elasticsearch.xcontent.ParseField SKIPPED_FIELD
    • RUNNING_FIELD

      public static final org.elasticsearch.xcontent.ParseField RUNNING_FIELD
    • PARTIAL_FIELD

      public static final org.elasticsearch.xcontent.ParseField PARTIAL_FIELD
    • FAILED_FIELD

      public static final org.elasticsearch.xcontent.ParseField FAILED_FIELD
    • DETAILS_FIELD

      public static final org.elasticsearch.xcontent.ParseField DETAILS_FIELD
    • TOOK

      public static final org.elasticsearch.xcontent.ParseField TOOK
    • IS_PARTIAL_FIELD

      public static final org.elasticsearch.xcontent.ParseField IS_PARTIAL_FIELD
    • clusterInfo

      public final ConcurrentMap<String,EsqlExecutionInfo.Cluster> clusterInfo
  • Constructor Details

    • EsqlExecutionInfo

      public EsqlExecutionInfo(boolean includeCCSMetadata)
    • EsqlExecutionInfo

      public EsqlExecutionInfo(Predicate<String> skipOnPlanTimeFailurePredicate, boolean includeCCSMetadata)
      Parameters:
      skipOnPlanTimeFailurePredicate - Decides whether we should skip the cluster that fails during planning phase.
      includeCCSMetadata - (user defined setting) whether to include the CCS metadata in the HTTP response
    • EsqlExecutionInfo

      public EsqlExecutionInfo(StreamInput in) throws IOException
      Throws:
      IOException
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • includeCCSMetadata

      public boolean includeCCSMetadata()
    • markEndPlanning

      public void markEndPlanning()
      Call when ES|QL "planning" phase is complete and query execution (in ComputeService) is about to start. Note this is currently only built for a single phase planning/execution model. When INLINESTATS moves towards GA we may need to revisit this model. Currently, it should never be called more than once.
    • planningTookTime

      public org.elasticsearch.core.TimeValue planningTookTime()
    • 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

      public org.elasticsearch.core.TimeValue overallTook()
    • tookSoFar

      public org.elasticsearch.core.TimeValue tookSoFar()
      How much time the query took since starting.
    • overallTimeSpan

      public TimeSpan overallTimeSpan()
    • planningTimeSpan

      public TimeSpan planningTimeSpan()
    • clusterAliases

      public Set<String> clusterAliases()
    • shouldSkipOnFailure

      public boolean shouldSkipOnFailure(String clusterAlias)
      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

      public EsqlExecutionInfo.Cluster getCluster(String clusterAlias)
    • getClusters

      public Map<String,EsqlExecutionInfo.Cluster> getClusters()
    • swapCluster

      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 returns null, 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 associated
      remappingFunction - function to swap the oldCluster to a newCluster
      Returns:
      the new Cluster object
    • toXContentChunked

      public Iterator<? extends org.elasticsearch.xcontent.ToXContent> toXContentChunked(org.elasticsearch.xcontent.ToXContent.Params params)
      Specified by:
      toXContentChunked in interface ChunkedToXContent
    • getClusterStates

      Parameters:
      status - the status you want to access
      Returns:
      a stream of clusters with that status
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isPartial

      public boolean isPartial()
    • markAsStopped

      public void markAsStopped()
    • isStopped

      public boolean isStopped()