Skip to content

Commit

Permalink
Fix debug issues
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <widdis@gmail.com>
  • Loading branch information
dbwiddis committed Jan 29, 2023
1 parent c1787b5 commit 8addf5a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
9 changes: 0 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -755,18 +755,9 @@ dependencies {
// compileOnly "org.opensearch:opensearch-job-scheduler-spi:${job_scheduler_version}"
// Removed Common Utils dependency from AD
// implementation "org.opensearch:common-utils:${common_utils_version}"
<<<<<<< Upstream, based on 1ba8bc66a5e1deda321dfda1d63639ed02e2b670
<<<<<<< HEAD
implementation "org.opensearch.sdk:opensearch-sdk-java:1.0.0-SNAPSHOT"
implementation "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
=======
implementation "org.opensearch:opensearch-sdk-java:1.0.0-SNAPSHOT"
>>>>>>> 6f76601 (Add High Level Rest Client to extension)
=======
implementation "org.opensearch.sdk:opensearch-sdk-java:1.0.0-SNAPSHOT"
>>>>>>> 1ca3b79 Fix compile errors
implementation "org.opensearch.client:opensearch-java:${opensearch_version}"
implementation "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
implementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}"
implementation group: 'com.google.guava', name: 'guava', version:'31.0.1-jre'
implementation group: 'com.google.guava', name: 'failureaccess', version:'1.0.1'
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/opensearch/ad/AnomalyDetectorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ public Collection<Object> createComponents(
Interpolator interpolator = new LinearUniformInterpolator(singleFeatureLinearUniformInterpolator);
// SearchFeatureDao is Injected for IndexAnomalyDetectorTrasnportAction constructor
SearchFeatureDao searchFeatureDao = new SearchFeatureDao(
null, // Client client,
null, // client,
xContentRegistry,
interpolator,
clientUtil,
settings,
null, // ClusterService clusterService,
null, // clusterService,
AnomalyDetectorSettings.NUM_SAMPLES_PER_TREE
);

Expand Down Expand Up @@ -874,8 +874,6 @@ public List<NamedXContentRegistry.Entry> getNamedXContent() {
new ActionHandler<>(DeleteAnomalyDetectorAction.INSTANCE, DeleteAnomalyDetectorTransportAction.class),
new ActionHandler<>(GetAnomalyDetectorAction.INSTANCE, GetAnomalyDetectorTransportAction.class),
new ActionHandler<>(IndexAnomalyDetectorAction.INSTANCE, IndexAnomalyDetectorTransportAction.class)
*/
/* @anomaly-detection.create-detector
new ActionHandler<>(AnomalyDetectorJobAction.INSTANCE, AnomalyDetectorJobTransportAction.class),
new ActionHandler<>(ADResultBulkAction.INSTANCE, ADResultBulkTransportAction.class),
new ActionHandler<>(EntityResultAction.INSTANCE, EntityResultTransportAction.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public SearchFeatureDao(
settingsUpdateConsumers.put(PAGE_SIZE, it -> this.pageSize = (int) it);
clusterService.addSettingsUpdateConsumer(settingsUpdateConsumers);
} catch (Exception e) {
// TODO Handle this
// FIXME Handle this here or in SDKClusterService after bug fix
// https://github.com/opensearch-project/opensearch-sdk-java/issues/366
}
this.minimumDocCountForPreview = minimumDocCount;
this.previewTimeoutInMilliseconds = previewTimeoutInMilliseconds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public AnomalyDetectionIndices(
int maxUpdateRunningTimes
) {
this.client = restClient;
this.adminClient = restClient;
this.adminClient = client.admin();
this.clusterService = sdkClusterService;
this.threadPool = threadPool;
// this.clusterService.addLocalNodeMasterListener(this);
Expand Down Expand Up @@ -203,7 +203,8 @@ public AnomalyDetectionIndices(
try {
this.clusterService.addSettingsUpdateConsumer(settingToConsumerMap);
} catch (Exception e) {
// TODO Handle this
// FIXME Handle this here or in SDKClusterService after bug fix
// https://github.com/opensearch-project/opensearch-sdk-java/issues/366
}

this.settings = Settings.builder().put("index.hidden", true).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public AbstractAnomalyDetectorAction(ExtensionsRunner extensionsRunner) {
try {
clusterService.addSettingsUpdateConsumer(settingToConsumerMap);
} catch (Exception e) {
// FIXME handle this
// FIXME Handle this here or in SDKClusterService after bug fix
// https://github.com/opensearch-project/opensearch-sdk-java/issues/366
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ private ExtensionRestResponse indexAnomalyDetectorResponse(ExtensionRestRequest
RestStatus restStatus = RestStatus.CREATED;
if (request.method() == RestRequest.Method.PUT) {
restStatus = RestStatus.OK;
} else {
logger.info("Detector ID: {}", response.getId());
}
ExtensionRestResponse extensionRestResponse = new ExtensionRestResponse(
request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.opensearch.ad.rest.handler;

import static org.opensearch.ad.constant.CommonErrorMessages.FAIL_TO_FIND_DETECTOR_MSG;
import static org.opensearch.ad.model.ADTaskType.HISTORICAL_DETECTOR_TASK_TYPES;
import static org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX;
import static org.opensearch.ad.util.ParseUtils.listEqualsWithoutConsideringOrder;
import static org.opensearch.ad.util.ParseUtils.parseAggregators;
Expand Down Expand Up @@ -385,6 +384,8 @@ protected void validateTimeField(boolean indexingDryRun) {
// FIXME Need to implement this; does shard level actions on the cluster
// https://github.com/opensearch-project/opensearch-sdk-java/issues/361
// client.execute(GetFieldMappingsAction.INSTANCE, getMappingsRequest, mappingsListener);
// For now just skip and go to the next step:
prepareAnomalyDetectorIndexing(indexingDryRun);
}

/**
Expand All @@ -403,6 +404,8 @@ protected void prepareAnomalyDetectorIndexing(boolean indexingDryRun) {
// () -> updateAnomalyDetector(detectorId, indexingDryRun),
// xContentRegistry
// );
// FIXME Substitute call for the above, remove when JS work enables above code
updateAnomalyDetector(detectorId, indexingDryRun);
} else {
createAnomalyDetector(indexingDryRun);
}
Expand Down Expand Up @@ -445,14 +448,17 @@ private void onGetAnomalyDetectorResponse(GetResponse response, boolean indexing
return;
}

adTaskManager.getAndExecuteOnLatestDetectorLevelTask(detectorId, HISTORICAL_DETECTOR_TASK_TYPES, (adTask) -> {
if (adTask.isPresent() && !adTask.get().isDone()) {
// can't update detector if there is AD task running
listener.onFailure(new OpenSearchStatusException("Detector is running", RestStatus.INTERNAL_SERVER_ERROR));
} else {
validateExistingDetector(existingDetector, indexingDryRun);
}
}, transportService, true, listener);
// FIXME: Need to implement ADTaskManager extension point
// https://github.com/opensearch-project/opensearch-sdk-java/issues/371

// adTaskManager.getAndExecuteOnLatestDetectorLevelTask(detectorId, HISTORICAL_DETECTOR_TASK_TYPES, (adTask) -> {
// if (adTask.isPresent() && !adTask.get().isDone()) {
// // can't update detector if there is AD task running
// listener.onFailure(new OpenSearchStatusException("Detector is running", RestStatus.INTERNAL_SERVER_ERROR));
// } else {
validateExistingDetector(existingDetector, indexingDryRun);
// }
// }, transportService, true, listener);
} catch (IOException e) {
String message = "Failed to parse anomaly detector " + detectorId;
logger.error(message, e);
Expand Down Expand Up @@ -668,6 +674,8 @@ protected void validateCategoricalField(String detectorId, boolean indexingDryRu
// FIXME Need to implement this; does shard level actions on the cluster
// https://github.com/opensearch-project/opensearch-sdk-java/issues/361
// client.execute(GetFieldMappingsAction.INSTANCE, getMappingsRequest, mappingsListener);
// For now just skip and go to the next step:
searchAdInputIndices(detectorId, indexingDryRun);
}

protected void searchAdInputIndices(String detectorId, boolean indexingDryRun) {
Expand Down

0 comments on commit 8addf5a

Please sign in to comment.