Class SamplingService

java.lang.Object
org.elasticsearch.ingest.SamplingService
All Implemented Interfaces:
ClusterStateListener

public class SamplingService extends Object implements ClusterStateListener
  • Field Details

    • RANDOM_SAMPLING_FEATURE_FLAG

      public static final boolean RANDOM_SAMPLING_FEATURE_FLAG
  • Constructor Details

  • Method Details

    • maybeSample

      public void maybeSample(ProjectMetadata projectMetadata, IndexRequest indexRequest)
      Potentially samples the given indexRequest, depending on the existing sampling configuration.
      Parameters:
      projectMetadata - Used to get the sampling configuration
      indexRequest - The raw request to potentially sample
    • maybeSample

      public void maybeSample(ProjectMetadata projectMetadata, String indexName, IndexRequest indexRequest, IngestDocument ingestDocument)
      Potentially samples the given indexRequest, depending on the existing sampling configuration.
      Parameters:
      projectMetadata - Used to get the sampling configuration
      indexRequest - The raw request to potentially sample
      ingestDocument - The IngestDocument used for evaluating any conditionals that are part of the sample configuration
    • getLocalSample

      public List<SamplingService.RawDocument> getLocalSample(ProjectId projectId, String index)
      Gets the sample for the given projectId and index on this node only. The sample is not persistent.
      Parameters:
      projectId - The project that this sample is for
      index - The index that the sample is for
      Returns:
      The raw documents in the sample on this node, or an empty list if there are none
    • getLocalSampleStats

      public SamplingService.SampleStats getLocalSampleStats(ProjectId projectId, String index)
      Gets the sample stats for the given projectId and index on this node only. The stats are not persistent. They are reset when the node restarts for example.
      Parameters:
      projectId - The project that this sample is for
      index - The index that the sample is for
      Returns:
      Current stats on this node for this sample
    • atLeastOneSampleConfigured

      public boolean atLeastOneSampleConfigured()
    • clusterChanged

      public void clusterChanged(ClusterChangedEvent event)
      Description copied from interface: ClusterStateListener
      Called when cluster state changes.

      Cluster states are applied one-by-one which means they can be a performance bottleneck. Implementations of this method should therefore be fast, so please consider forking work into the background rather than doing everything inline.

      Specified by:
      clusterChanged in interface ClusterStateListener