From be1df945937015b9d83d7a5ac9c049df4caa52b4 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Wed, 30 Aug 2023 17:02:26 +0800 Subject: [PATCH] onboard system and hidden index (#742) Signed-off-by: Hailong Cui --- .../opensearch/notifications/NotificationPlugin.kt | 13 ++++++++++++- .../notifications/index/NotificationConfigIndex.kt | 2 +- .../resources/notifications-config-settings.yml | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt index 2ac0ebae..e15aa7d8 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt @@ -22,6 +22,7 @@ import org.opensearch.core.common.io.stream.NamedWriteableRegistry import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.env.Environment import org.opensearch.env.NodeEnvironment +import org.opensearch.indices.SystemIndexDescriptor import org.opensearch.notifications.action.CreateNotificationConfigAction import org.opensearch.notifications.action.DeleteNotificationConfigAction import org.opensearch.notifications.action.GetChannelListAction @@ -44,6 +45,7 @@ import org.opensearch.notifications.spi.NotificationCore import org.opensearch.notifications.spi.NotificationCoreExtension import org.opensearch.plugins.ActionPlugin import org.opensearch.plugins.Plugin +import org.opensearch.plugins.SystemIndexPlugin import org.opensearch.repositories.RepositoriesService import org.opensearch.rest.RestController import org.opensearch.rest.RestHandler @@ -56,7 +58,7 @@ import java.util.function.Supplier * Entry point of the OpenSearch Notifications plugin * This class initializes the rest handlers. */ -class NotificationPlugin : ActionPlugin, Plugin(), NotificationCoreExtension { +class NotificationPlugin : ActionPlugin, Plugin(), NotificationCoreExtension, SystemIndexPlugin { lateinit var clusterService: ClusterService // initialized in createComponents() @@ -80,6 +82,15 @@ class NotificationPlugin : ActionPlugin, Plugin(), NotificationCoreExtension { return PluginSettings.getAllSettings() } + override fun getSystemIndexDescriptors(settings: Settings?): Collection { + return listOf( + SystemIndexDescriptor( + NotificationConfigIndex.INDEX_NAME, + "System index for storing notification channels related configurations." + ) + ) + } + /** * {@inheritDoc} */ diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt index c166a014..bc63de0e 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt @@ -67,7 +67,7 @@ internal object NotificationConfigIndex : ConfigOperations { const val SCHEMA_VERSION = "schema_version" private val log by logger(NotificationConfigIndex::class.java) - private const val INDEX_NAME = ".opensearch-notifications-config" + const val INDEX_NAME = ".opensearch-notifications-config" private const val MAPPING_FILE_NAME = "notifications-config-mapping.yml" private const val SETTINGS_FILE_NAME = "notifications-config-settings.yml" diff --git a/notifications/notifications/src/main/resources/notifications-config-settings.yml b/notifications/notifications/src/main/resources/notifications-config-settings.yml index 569523b1..1a2fa70a 100644 --- a/notifications/notifications/src/main/resources/notifications-config-settings.yml +++ b/notifications/notifications/src/main/resources/notifications-config-settings.yml @@ -8,3 +8,4 @@ index: number_of_shards: "1" # The data size is not expected to be big so keeping it 1 shard auto_expand_replicas: "0-2" + hidden: true \ No newline at end of file