Skip to content

Commit cf1016f

Browse files
authored
Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors (#750)
* Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors Signed-off-by: Craig Perkins <[email protected]> * Add CHANGELOG entry Signed-off-by: Craig Perkins <[email protected]> * Remove extra characters Signed-off-by: Craig Perkins <[email protected]> * Address code review comments Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]>
1 parent 118f534 commit cf1016f

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1717
## [Unreleased 2.x](https://github.com/opensearch-project/flow-framework/compare/2.14...2.x)
1818
### Features
1919
### Enhancements
20+
- Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors ([#750](https://github.com/opensearch-project/flow-framework/pull/750))
21+
2022
### Bug Fixes
2123

2224
### Infrastructure

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ testClusters.integTest {
394394

395395
}
396396

397-
// Install Flow Framwork Plugin on integTest cluster nodes
397+
// Install Flow Framework Plugin on integTest cluster nodes
398398
plugin(project.tasks.bundlePlugin.archiveFile)
399399

400400
// Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1

src/main/java/org/opensearch/flowframework/FlowFrameworkPlugin.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
import org.opensearch.flowframework.util.EncryptorUtils;
5858
import org.opensearch.flowframework.workflow.WorkflowProcessSorter;
5959
import org.opensearch.flowframework.workflow.WorkflowStepFactory;
60+
import org.opensearch.indices.SystemIndexDescriptor;
6061
import org.opensearch.ml.client.MachineLearningNodeClient;
6162
import org.opensearch.plugins.ActionPlugin;
6263
import org.opensearch.plugins.Plugin;
64+
import org.opensearch.plugins.SystemIndexPlugin;
6365
import org.opensearch.repositories.RepositoriesService;
6466
import org.opensearch.rest.RestController;
6567
import org.opensearch.rest.RestHandler;
@@ -73,9 +75,12 @@
7375
import java.util.List;
7476
import java.util.function.Supplier;
7577

78+
import static org.opensearch.flowframework.common.CommonValue.CONFIG_INDEX;
7679
import static org.opensearch.flowframework.common.CommonValue.DEPROVISION_WORKFLOW_THREAD_POOL;
7780
import static org.opensearch.flowframework.common.CommonValue.FLOW_FRAMEWORK_THREAD_POOL_PREFIX;
81+
import static org.opensearch.flowframework.common.CommonValue.GLOBAL_CONTEXT_INDEX;
7882
import static org.opensearch.flowframework.common.CommonValue.PROVISION_WORKFLOW_THREAD_POOL;
83+
import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_STATE_INDEX;
7984
import static org.opensearch.flowframework.common.CommonValue.WORKFLOW_THREAD_POOL;
8085
import static org.opensearch.flowframework.common.FlowFrameworkSettings.FLOW_FRAMEWORK_ENABLED;
8186
import static org.opensearch.flowframework.common.FlowFrameworkSettings.MAX_WORKFLOWS;
@@ -86,7 +91,7 @@
8691
/**
8792
* An OpenSearch plugin that enables builders to innovate AI apps on OpenSearch.
8893
*/
89-
public class FlowFrameworkPlugin extends Plugin implements ActionPlugin {
94+
public class FlowFrameworkPlugin extends Plugin implements ActionPlugin, SystemIndexPlugin {
9095

9196
private FlowFrameworkSettings flowFrameworkSettings;
9297

@@ -207,4 +212,13 @@ public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
207212
);
208213
}
209214

215+
@Override
216+
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
217+
return List.of(
218+
new SystemIndexDescriptor(CONFIG_INDEX, "Flow Framework Config index"),
219+
new SystemIndexDescriptor(GLOBAL_CONTEXT_INDEX, "Flow Framework Global Context index"),
220+
new SystemIndexDescriptor(WORKFLOW_STATE_INDEX, "Flow Framework Workflow State index")
221+
);
222+
}
223+
210224
}

src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
import org.opensearch.common.settings.Setting;
1717
import org.opensearch.common.settings.Settings;
1818
import org.opensearch.env.Environment;
19+
import org.opensearch.indices.SystemIndexDescriptor;
1920
import org.opensearch.test.OpenSearchTestCase;
2021
import org.opensearch.threadpool.TestThreadPool;
2122
import org.opensearch.threadpool.ThreadPool;
2223

2324
import java.io.IOException;
25+
import java.util.Collection;
2426
import java.util.Set;
2527
import java.util.concurrent.TimeUnit;
2628
import java.util.stream.Collectors;
@@ -86,6 +88,9 @@ public void testPlugin() throws IOException {
8688
assertEquals(9, ffp.getActions().size());
8789
assertEquals(3, ffp.getExecutorBuilders(settings).size());
8890
assertEquals(5, ffp.getSettings().size());
91+
92+
Collection<SystemIndexDescriptor> systemIndexDescriptors = ffp.getSystemIndexDescriptors(Settings.EMPTY);
93+
assertEquals(3, systemIndexDescriptors.size());
8994
}
9095
}
9196
}

0 commit comments

Comments
 (0)