Skip to content

Commit

Permalink
add comments and address compiler errors
Browse files Browse the repository at this point in the history
Signed-off-by: Kaituo Li <[email protected]>
  • Loading branch information
kaituo committed Aug 1, 2023
1 parent 264c06b commit c844bd1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.opensearch.client.Client;
import org.opensearch.cluster.LocalNodeClusterManagerListener;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.component.LifecycleListener;
import org.opensearch.common.lifecycle.LifecycleListener;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/opensearch/forecast/model/ForecastTaskType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@

import com.google.common.collect.ImmutableList;

/**
* The ForecastTaskType enum defines different task types for forecasting, categorized into real-time and historical settings.
* In real-time forecasting, we monitor states at the forecaster level, resulting in two distinct task types: one for
* single-stream forecasting and another for high cardinality (HC). In the historical setting, state tracking is more nuanced,
* encompassing both entity and forecaster levels. This leads to three specific task types: a forecaster-level task dedicated
* to single-stream forecasting, and two tasks for HC, one at the forecaster level and another at the entity level.
*
* Real-time forecasting:
* - FORECAST_REALTIME_SINGLE_STREAM: Represents a task type for single-stream forecasting. Ideal for scenarios where a single
* time series is processed in real-time.
* - FORECAST_REALTIME_HC_FORECASTER: Represents a task type for high cardinality (HC) forecasting. Used when dealing with a
* large number of distinct entities in real-time.
*
* Historical forecasting:
* - FORECAST_HISTORICAL_SINGLE_STREAM: Represents a forecaster-level task for single-stream historical forecasting.
* Suitable for analyzing a single time series in a sequential manner.
* - FORECAST_HISTORICAL_HC_FORECASTER: A forecaster-level task to track overall state, initialization progress, errors, etc.,
* for HC forecasting. Central to managing multiple historical time series with high cardinality.
* - FORECAST_HISTORICAL_HC_ENTITY: An entity-level task to track the state, initialization progress, errors, etc., of a
* specific entity within HC historical forecasting. Allows for fine-grained information recording at the entity level.
*
*/
public enum ForecastTaskType implements TaskType {
FORECAST_REALTIME_SINGLE_STREAM,
FORECAST_REALTIME_HC_FORECASTER,
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/opensearch/ad/MemoryTrackerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.core.common.unit.ByteSizeValue;
import org.opensearch.monitor.jvm.JvmInfo;
import org.opensearch.monitor.jvm.JvmInfo.Mem;
import org.opensearch.monitor.jvm.JvmService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.core.common.unit.ByteSizeValue;
import org.opensearch.monitor.jvm.JvmInfo;
import org.opensearch.monitor.jvm.JvmInfo.Mem;
import org.opensearch.monitor.jvm.JvmService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.opensearch.ad.settings.AnomalyDetectorSettings;
import org.opensearch.client.Client;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.component.LifecycleListener;
import org.opensearch.common.lifecycle.LifecycleListener;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.opensearch.action.ActionResponse;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.test.OpenSearchIntegTestCase;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void writeTo(StreamOutput streamOutput) throws IOException {
@Test
public void toXContentTest() throws IOException {
StopDetectorResponse stopDetectorResponse = new StopDetectorResponse(true);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
stopDetectorResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/opensearch/timeseries/TestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,19 @@ public static ADTask randomAdTask(
return task;
}

/**
* Generates a random Entity based on the provided configuration.
*
* If the configuration has multiple categories, a new Entity is created with attributes
* populated with random alphanumeric strings of length 5.
*
* If the configuration is marked as high cardinality and does not have multiple categories,
* a new Entity is created with a single attribute using the first category field and a random
* alphanumeric string of length 5.
*
* @param config The configuration object containing information about a time series analysis.
* @return A randomly generated Entity based on the configuration, or null if the config is null.
*/
public static Entity randomEntity(Config config) {
Entity entity = null;
if (config != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
import org.opensearch.common.util.BitMixer;
import org.opensearch.common.util.MockBigArrays;
import org.opensearch.common.util.MockPageCacheRecycler;
import org.opensearch.core.indices.breaker.NoneCircuitBreakerService;
import org.opensearch.index.mapper.DateFieldMapper;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.indices.breaker.NoneCircuitBreakerService;
import org.opensearch.search.DocValueFormat;
import org.opensearch.search.SearchHit;
import org.opensearch.search.SearchHits;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/test/org/opensearch/ad/util/FakeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.common.util.PageCacheRecycler;
import org.opensearch.core.common.io.stream.NamedWriteableRegistry;
import org.opensearch.indices.breaker.NoneCircuitBreakerService;
import org.opensearch.core.indices.breaker.NoneCircuitBreakerService;
import org.opensearch.tasks.TaskManager;
import org.opensearch.tasks.TaskResourceTrackingService;
import org.opensearch.test.OpenSearchTestCase;
Expand Down

0 comments on commit c844bd1

Please sign in to comment.