- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterStateListener,LifecycleComponent,SchedulerEngine.Listener,Releasable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Method Summary
Modifier and TypeMethodDescriptionbooleanatLeastOneSampleConfigured(ProjectMetadata projectMetadata) voidCalled when cluster state changes.static SamplingServicecreate(ScriptService scriptService, ClusterService clusterService, Settings settings) voiddeleteSampleConfiguration(ProjectId projectId, String index, TimeValue masterNodeTimeout, TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener) protected voiddoClose()Close this component.protected voiddoStart()Start this component.protected voiddoStop()Stop this component.getLocalSample(ProjectId projectId, String index) Gets the sample for the given projectId and index on this node only.getLocalSampleStats(ProjectId projectId, String index) Gets the sample stats for the given projectId and index on this node only.getSamplingConfiguration(ProjectMetadata projectMetadata, String indexName) Retrieves the sampling configuration for the specified index from the given project metadata.voidmaybeSample(ProjectMetadata projectMetadata, IndexRequest indexRequest) Potentially samples the given indexRequest, depending on the existing sampling configuration.voidmaybeSample(ProjectMetadata projectMetadata, IndexRequest indexRequest, IngestDocument ingestDocument) Potentially samples the given indexRequest, depending on the existing sampling configuration.static voidthrowIndexNotFoundExceptionIfNotDataStreamOrIndex(IndexNameExpressionResolver indexNameExpressionResolver, ProjectResolver projectResolver, ClusterState state, IndicesRequest request) voidtriggered(SchedulerEngine.Event event) voidupdateSampleConfiguration(ProjectId projectId, String index, SamplingConfiguration samplingConfiguration, TimeValue masterNodeTimeout, TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener) Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
RANDOM_SAMPLING_FEATURE_FLAG
public static final boolean RANDOM_SAMPLING_FEATURE_FLAG -
TTL_POLL_INTERVAL_SETTING
-
-
Method Details
-
create
public static SamplingService create(ScriptService scriptService, ClusterService clusterService, Settings settings) -
maybeSample
Potentially samples the given indexRequest, depending on the existing sampling configuration.- Parameters:
projectMetadata- Used to get the sampling configurationindexRequest- The raw request to potentially sample
-
maybeSample
public void maybeSample(ProjectMetadata projectMetadata, IndexRequest indexRequest, IngestDocument ingestDocument) Potentially samples the given indexRequest, depending on the existing sampling configuration. The request will be sampled against the sampling configurations of all indices it has been rerouted to (if it has been rerouted).- Parameters:
projectMetadata- Used to get the sampling configurationindexRequest- The raw request to potentially sampleingestDocument- The IngestDocument used for evaluating any conditionals that are part of the sample configuration
-
getSamplingConfiguration
public SamplingConfiguration getSamplingConfiguration(ProjectMetadata projectMetadata, String indexName) Retrieves the sampling configuration for the specified index from the given project metadata.- Parameters:
projectMetadata- The project metadata containing sampling information.indexName- The name of the index or data stream for which to retrieve the sampling configuration.- Returns:
- The
SamplingConfigurationfor the specified index, ornullif none exists.
-
getLocalSample
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 forindex- 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
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 forindex- The index that the sample is for- Returns:
- Current stats on this node for this sample
-
throwIndexNotFoundExceptionIfNotDataStreamOrIndex
public static void throwIndexNotFoundExceptionIfNotDataStreamOrIndex(IndexNameExpressionResolver indexNameExpressionResolver, ProjectResolver projectResolver, ClusterState state, IndicesRequest request) -
atLeastOneSampleConfigured
-
updateSampleConfiguration
public void updateSampleConfiguration(ProjectId projectId, String index, SamplingConfiguration samplingConfiguration, TimeValue masterNodeTimeout, TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener) -
deleteSampleConfiguration
public void deleteSampleConfiguration(ProjectId projectId, String index, TimeValue masterNodeTimeout, TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener) -
clusterChanged
Description copied from interface:ClusterStateListenerCalled 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:
clusterChangedin interfaceClusterStateListener
-
triggered
- Specified by:
triggeredin interfaceSchedulerEngine.Listener
-
doStart
protected void doStart()Description copied from class:AbstractLifecycleComponentStart this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.
This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.- Specified by:
doStartin classAbstractLifecycleComponent
-
doStop
protected void doStop()Description copied from class:AbstractLifecycleComponentStop this component. Typically that means doing the reverse of whateverAbstractLifecycleComponent.doStart()does.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, after callingAbstractLifecycleComponent.doStart(), although it will not be called at all if this component did not successfully start.- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
Description copied from class:AbstractLifecycleComponentClose this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.- Specified by:
doClosein classAbstractLifecycleComponent- Throws:
IOException
-