Search in sources :

Example 1 with EntityProfileRequest

use of org.opensearch.ad.transport.EntityProfileRequest in project anomaly-detection by opensearch-project.

the class EntityProfileRunner method prepareEntityProfile.

private void prepareEntityProfile(ActionListener<EntityProfile> listener, String detectorId, Entity entityValue, Set<EntityProfileName> profilesToCollect, AnomalyDetector detector, String categoryField) {
    EntityProfileRequest request = new EntityProfileRequest(detectorId, entityValue, profilesToCollect);
    client.execute(EntityProfileAction.INSTANCE, request, ActionListener.wrap(r -> getJob(detectorId, entityValue, profilesToCollect, detector, r, listener), listener::onFailure));
}
Also used : EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest) EntityProfileName(org.opensearch.ad.model.EntityProfileName) XContentParser(org.opensearch.common.xcontent.XContentParser) ANOMALY_DETECTOR_JOB_INDEX(org.opensearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) EntityProfileResponse(org.opensearch.ad.transport.EntityProfileResponse) Map(java.util.Map) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) SearchRequest(org.opensearch.action.search.SearchRequest) ActionListener(org.opensearch.action.ActionListener) EntityProfile(org.opensearch.ad.model.EntityProfile) NestedQueryBuilder(org.opensearch.index.query.NestedQueryBuilder) QueryBuilders(org.opensearch.index.query.QueryBuilders) Client(org.opensearch.client.Client) CommonName(org.opensearch.ad.constant.CommonName) NumericSetting(org.opensearch.ad.settings.NumericSetting) Preference(org.opensearch.cluster.routing.Preference) InitProgressProfile(org.opensearch.ad.model.InitProgressProfile) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) ANOMALY_DETECTORS_INDEX(org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX) GetRequest(org.opensearch.action.get.GetRequest) LoggingDeprecationHandler(org.opensearch.common.xcontent.LoggingDeprecationHandler) Set(java.util.Set) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) ScoreMode(org.apache.lucene.search.join.ScoreMode) MultiResponsesDelegateActionListener(org.opensearch.ad.util.MultiResponsesDelegateActionListener) AggregationBuilders(org.opensearch.search.aggregations.AggregationBuilders) List(java.util.List) CommonErrorMessages(org.opensearch.ad.constant.CommonErrorMessages) Logger(org.apache.logging.log4j.Logger) AnomalyResult(org.opensearch.ad.model.AnomalyResult) Entity(org.opensearch.ad.model.Entity) EntityState(org.opensearch.ad.model.EntityState) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) Optional(java.util.Optional) XContentType(org.opensearch.common.xcontent.XContentType) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) EntityProfileAction(org.opensearch.ad.transport.EntityProfileAction) ParseUtils(org.opensearch.ad.util.ParseUtils) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest)

Example 2 with EntityProfileRequest

use of org.opensearch.ad.transport.EntityProfileRequest in project anomaly-detection by opensearch-project.

the class BwcTests method setUpEntityProfileRequest.

private void setUpEntityProfileRequest() {
    profilesToCollect = new HashSet<EntityProfileName>();
    profilesToCollect.add(EntityProfileName.STATE);
    entityProfileRequest1_1 = new EntityProfileRequest(detectorId, entity, profilesToCollect);
    entityProfileRequest1_0 = new EntityProfileRequest1_0(detectorId, categoryValue, profilesToCollect);
}
Also used : EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest) EntityProfileName(org.opensearch.ad.model.EntityProfileName)

Example 3 with EntityProfileRequest

use of org.opensearch.ad.transport.EntityProfileRequest in project anomaly-detection by opensearch-project.

the class BwcTests method testDeserializeEntityProfileRequest1_1.

/**
 * For EntityResultRequest, the input is a 1.1 stream.
 * @throws IOException when serialization/deserialization has issues.
 */
public void testDeserializeEntityProfileRequest1_1() throws IOException {
    setUpEntityProfileRequest();
    entityProfileRequest1_1.writeTo(output1_1);
    StreamInput streamInput = output1_1.bytes().streamInput();
    streamInput.setVersion(V_1_1_0);
    EntityProfileRequest readRequest = new EntityProfileRequest(streamInput);
    assertThat(readRequest.getAdID(), equalTo(detectorId));
    assertThat(readRequest.getEntityValue(), equalTo(entity));
    assertThat(readRequest.getProfilesToCollect(), equalTo(profilesToCollect));
}
Also used : StreamInput(org.opensearch.common.io.stream.StreamInput) EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest)

Example 4 with EntityProfileRequest

use of org.opensearch.ad.transport.EntityProfileRequest in project anomaly-detection by opensearch-project.

the class BwcTests method testDeserializeEntityProfileRequest1_0.

/**
 * For EntityResultRequest, the input is a 1.0 stream.
 * @throws IOException when serialization/deserialization has issues.
 */
public void testDeserializeEntityProfileRequest1_0() throws IOException {
    setUpEntityProfileRequest();
    entityProfileRequest1_0.writeTo(output1_0);
    StreamInput streamInput = output1_0.bytes().streamInput();
    streamInput.setVersion(Version.V_1_0_0);
    EntityProfileRequest readRequest = new EntityProfileRequest(streamInput);
    assertThat(readRequest.getAdID(), equalTo(detectorId));
    assertThat(readRequest.getEntityValue(), equalTo(convertedEntity));
    assertThat(readRequest.getProfilesToCollect(), equalTo(profilesToCollect));
}
Also used : StreamInput(org.opensearch.common.io.stream.StreamInput) EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest)

Aggregations

EntityProfileRequest (org.opensearch.ad.transport.EntityProfileRequest)4 EntityProfileName (org.opensearch.ad.model.EntityProfileName)2 StreamInput (org.opensearch.common.io.stream.StreamInput)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 ScoreMode (org.apache.lucene.search.join.ScoreMode)1 ActionListener (org.opensearch.action.ActionListener)1 GetRequest (org.opensearch.action.get.GetRequest)1 SearchRequest (org.opensearch.action.search.SearchRequest)1 CommonErrorMessages (org.opensearch.ad.constant.CommonErrorMessages)1 CommonName (org.opensearch.ad.constant.CommonName)1 AnomalyDetector (org.opensearch.ad.model.AnomalyDetector)1 ANOMALY_DETECTORS_INDEX (org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX)1 AnomalyDetectorJob (org.opensearch.ad.model.AnomalyDetectorJob)1 ANOMALY_DETECTOR_JOB_INDEX (org.opensearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX)1 AnomalyResult (org.opensearch.ad.model.AnomalyResult)1