Skip to content

Commit

Permalink
Rename AD to time series analytics & Resolve Compiler Errors
Browse files Browse the repository at this point in the history
This commit focuses on renaming the AnomalyDetectorPlugin to TimeSeriesAnalyticsPlugin as well as addressing compiler errors due to package import changes. The primary transformations are:

* Renamed AnomalyDetectorPlugin to TimeSeriesAnalyticsPlugin.
* Updated all references from AnomalyDetectorPlugin to TimeSeriesAnalyticsPlugin.
* Amended plugin information in build.gradle and src/main/resources/es-plugin.properties.
* Switched job type in TimeSeriesAnalyticsPlugin from opendistro_anomaly_detector to opensearch_time_series_analytics.

These changes led to the modification of our plugin binary from opensearch-anomaly-detection-3.0.0.0-SNAPSHOT.jar to opensearch-time-series-analytics-3.0.0.0-SNAPSHOT.jar.

Moreover, following changes from OpenSearch Pull Request #8157, compiler errors were encountered, which were resolved by updating the import packages

* org.opensearch.common.io.stream.NamedWriteableRegistry => org.opensearch.core.common.io.stream.NamedWriteableRegistry
* org.opensearch.common.xcontent.XContentParserUtils => * org.opensearch.core.xcontent.XContentParserUtils
* org.opensearch.common.bytes.BytesArray => org.opensearch.core.common.bytes.BytesArray * org.opensearch.common.io.stream.StreamInput => * org.opensearch.core.common.io.stream.StreamInput ** org.opensearch.common.io.stream.StreamOutput => org.opensearch.core.common.io.stream.StreamOutput
* org.opensearch.common.io.stream.Writeable => org.opensearch.core.common.io.stream.Writeable
* org.opensearch.common.io.stream.NotSerializableExceptionWrapper => org.opensearch.core.common.io.stream.NotSerializableExceptionWrapper
* org.opensearch.rest.RestStatus => org.opensearch.core.rest.RestStatus
* org.opensearch.common.ParsingException => org.opensearch.core.common.ParsingException
* org.opensearch.common.bytes.BytesReference => org.opensearch.core.common.bytes.BytesReference
* org.opensearch.common.io.stream.InputStreamStreamInput => org.opensearch.core.common.io.stream.InputStreamStreamInput
* org.opensearch.common.io.stream.OutputStreamStreamOutput => org.opensearch.core.common.io.stream.OutputStreamStreamOutput
* org.opensearch.index.shard.ShardId => org.opensearch.core.index.shard.ShardId* org.opensearch.index.Index => org.opensearch.core.index.Index
* org.opensearch.core.index.IndexNotFoundException => org.opensearch.index.IndexNotFoundException

Validation steps were executed to ensure these changes did not break functionality:
* gradle build was successful. A local build was required due to outdated OpenSearch and job scheduler nightly builds.
* Backward compatibility tests were performed on a two-node 2.9 cluster running some detectors. These detectors continued to produce results on a 3.0 cluster with these updates.
* I can start new detectors on the 3.0 node.
* After shutting down a 2.9 node, the job transfer to the 3.0 node was successful and the job continued to perform as expected.

Signed-off-by: Kaituo Li <kaituo@amazon.com>
  • Loading branch information
kaituo committed Jul 13, 2023
1 parent bc16499 commit b5d3487
Show file tree
Hide file tree
Showing 814 changed files with 111,985 additions and 613 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ ext {
}

opensearchplugin {
name 'opensearch-anomaly-detection'
description 'OpenSearch anomaly detector plugin'
classname 'org.opensearch.ad.AnomalyDetectorPlugin'
name 'opensearch-time-series-analytics'
description 'OpenSearch time series analytics plugin'
classname 'org.opensearch.timeseries.TimeSeriesAnalyticsPlugin'
extendedPlugins = ['lang-painless', 'opensearch-job-scheduler']
}

Expand Down Expand Up @@ -655,7 +655,7 @@ task release(type: Copy, group: 'build') {

List<String> jacocoExclusions = [
// code for configuration, settings, etc is excluded from coverage
'org.opensearch.ad.AnomalyDetectorPlugin',
'org.opensearch.timeseries.TimeSeriesAnalyticsPlugin',

// rest layer is tested in integration testing mostly, difficult to mock all of it
'org.opensearch.ad.rest.*',
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/opensearch/ad/AbstractProfileRunner.java-e
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.ad;

import java.util.Locale;

import org.opensearch.ad.model.InitProgressProfile;

public abstract class AbstractProfileRunner {
protected long requiredSamples;

public AbstractProfileRunner(long requiredSamples) {
this.requiredSamples = requiredSamples;
}

protected InitProgressProfile computeInitProgressProfile(long totalUpdates, long intervalMins) {
float percent = Math.min((100.0f * totalUpdates) / requiredSamples, 100.0f);
int neededPoints = (int) (requiredSamples - totalUpdates);
return new InitProgressProfile(
// rounding: 93.456 => 93%, 93.556 => 94%
// Without Locale.ROOT, sometimes conversions use localized decimal digits
// rather than the usual ASCII digits. See https://tinyurl.com/y5sdr5tp
String.format(Locale.ROOT, "%.0f%%", percent),
intervalMins * neededPoints,
neededPoints
);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/opensearch/ad/AnomalyDetectorJobRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import static org.opensearch.action.DocWriteResponse.Result.CREATED;
import static org.opensearch.action.DocWriteResponse.Result.UPDATED;
import static org.opensearch.ad.AnomalyDetectorPlugin.AD_THREAD_POOL_NAME;
import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.opensearch.timeseries.TimeSeriesAnalyticsPlugin.AD_THREAD_POOL_NAME;
import static org.opensearch.timeseries.util.RestHandlerUtils.XCONTENT_WITH_TYPE;

import java.io.IOException;
Expand Down
Loading

0 comments on commit b5d3487

Please sign in to comment.