Skip to content

Commit

Permalink
Register system index descriptors through SystemIndexPlugin.getSystem…
Browse files Browse the repository at this point in the history
…IndexDescriptors (opensearch-project#2586) (opensearch-project#2668)

* Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors

Signed-off-by: Craig Perkins <[email protected]>

* Address code review feedback

Signed-off-by: Craig Perkins <[email protected]>

* Remove unused imports

Signed-off-by: Craig Perkins <[email protected]>

* Remove unused comments

Signed-off-by: Craig Perkins <[email protected]>

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit 6c8720e)

Co-authored-by: Craig Perkins <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and cwperks authored Jul 18, 2024
1 parent c8545e5 commit 91f1c5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class CommonValue {
public static final String ML_MEMORY_META_INDEX = ".plugins-ml-memory-meta";
public static final Integer ML_MEMORY_META_INDEX_SCHEMA_VERSION = 1;
public static final String ML_MEMORY_MESSAGE_INDEX = ".plugins-ml-memory-message";
public static final String ML_STOP_WORDS_INDEX = ".plugins-ml-stop-words";
public static final Set<String> stopWordsIndices = ImmutableSet.of(".plugins-ml-stop-words");
public static final Integer ML_MEMORY_MESSAGE_INDEX_SCHEMA_VERSION = 1;
public static final String USER_FIELD_MAPPING = " \""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@

package org.opensearch.ml.plugin;

import static org.opensearch.ml.common.CommonValue.ML_AGENT_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_CONFIG_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_CONNECTOR_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_CONTROLLER_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_MEMORY_MESSAGE_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_MEMORY_META_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_MODEL_GROUP_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_STOP_WORDS_INDEX;
import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX;

import java.nio.file.Path;
Expand Down Expand Up @@ -38,6 +43,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.env.Environment;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.indices.SystemIndexDescriptor;
import org.opensearch.ml.action.agents.DeleteAgentTransportAction;
import org.opensearch.ml.action.agents.GetAgentTransportAction;
import org.opensearch.ml.action.agents.TransportRegisterAgentAction;
Expand Down Expand Up @@ -284,6 +290,7 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.SearchPipelinePlugin;
import org.opensearch.plugins.SearchPlugin;
import org.opensearch.plugins.SystemIndexPlugin;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.rest.RestController;
import org.opensearch.rest.RestHandler;
Expand All @@ -310,7 +317,8 @@ public class MachineLearningPlugin extends Plugin
SearchPlugin,
SearchPipelinePlugin,
ExtensiblePlugin,
IngestPlugin {
IngestPlugin,
SystemIndexPlugin {
public static final String ML_THREAD_POOL_PREFIX = "thread_pool.ml_commons.";
public static final String GENERAL_THREAD_POOL = "opensearch_ml_general";
public static final String EXECUTE_THREAD_POOL = "opensearch_ml_execute";
Expand Down Expand Up @@ -1017,4 +1025,20 @@ public Map<String, org.opensearch.ingest.Processor.Factory> getProcessors(org.op
);
return Collections.unmodifiableMap(processors);
}

@Override
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
List<SystemIndexDescriptor> systemIndexDescriptors = new ArrayList<>();
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_AGENT_INDEX, "ML Commons Agent Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_CONFIG_INDEX, "ML Commons Configuration Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_CONNECTOR_INDEX, "ML Commons Connector Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_CONTROLLER_INDEX, "ML Commons Controller Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_MODEL_GROUP_INDEX, "ML Commons Model Group Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_MODEL_INDEX, "ML Commons Model Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_TASK_INDEX, "ML Commons Task Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_MEMORY_META_INDEX, "ML Commons Memory Meta Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_MEMORY_MESSAGE_INDEX, "ML Commons Memory Message Index"));
systemIndexDescriptors.add(new SystemIndexDescriptor(ML_STOP_WORDS_INDEX, "ML Commons Stop Words Index"));
return systemIndexDescriptors;
}
}

0 comments on commit 91f1c5b

Please sign in to comment.