From 53eb0d53c7c98826ed70e7379c4d63d9709456e7 Mon Sep 17 00:00:00 2001 From: Mohammed Aghil Puthiyottil <57040494+MohammedAghil@users.noreply.github.com> Date: Tue, 5 May 2026 23:56:08 +0000 Subject: [PATCH] Route getNotificationConfigs through SdkClient for remote metadata SDK compatibility (#1224) Replace MultiGetRequest with SearchDataObjectRequest using idsQuery to ensure bulk config fetches go through SdkClient, consistent with all other operations. - Added tenantId to search request for multi-tenancy support - Updated gradle wrapper to 9.4.1 (required by OpenSearch gradle plugin) Signed-off-by: Mohammed Aghil Puthiyottil <57040494+MohammedAghil@users.noreply.github.com> --- .../gradle/wrapper/gradle-wrapper.properties | 4 +- .../index/NotificationConfigIndex.kt | 39 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/notifications/gradle/wrapper/gradle-wrapper.properties b/notifications/gradle/wrapper/gradle-wrapper.properties index b11741a1ada..ffc9416beb1 100644 --- a/notifications/gradle/wrapper/gradle-wrapper.properties +++ b/notifications/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=16f2b95838c1ddcf7242b1c39e7bbbb43c842f1f1a1a0dc4959b6d4d68abcac3 -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip +distributionSha256Sum=708d2c6ecc97ca9a11838ef64a6c2301151b8dd10387e22dc1a12c30557cab5b +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 8a4db936e61..6b7cf96715f 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 @@ -13,8 +13,6 @@ import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest import org.opensearch.action.bulk.BulkResponse import org.opensearch.action.delete.DeleteResponse import org.opensearch.action.get.GetResponse -import org.opensearch.action.get.MultiGetRequest -import org.opensearch.action.get.MultiGetResponse import org.opensearch.action.index.IndexResponse import org.opensearch.action.search.SearchResponse import org.opensearch.action.support.clustermanager.AcknowledgedResponse @@ -212,12 +210,39 @@ internal object NotificationConfigIndex : ConfigOperations { */ override suspend fun getNotificationConfigs(ids: Set): List { createIndex() - val getRequest = MultiGetRequest() - ids.forEach { getRequest.add(INDEX_NAME, it) } - val response: MultiGetResponse = client.suspendUntilTimeout(PluginSettings.operationTimeoutMs) { - multiGet(getRequest, it) + val sourceBuilder = SearchSourceBuilder() + .timeout(TimeValue(PluginSettings.operationTimeoutMs, TimeUnit.MILLISECONDS)) + .query(QueryBuilders.idsQuery().addIds(*ids.toTypedArray())) + .size(ids.size) + val searchRequest = SearchDataObjectRequest.builder() + .indices(INDEX_NAME) + .tenantId(currentTenantId()) + .searchSourceBuilder(sourceBuilder) + .build() + val response: SearchResponse = sdkClient.suspendUntilTimeout(PluginSettings.operationTimeoutMs) { + sdkClient.searchDataObjectAsync(searchRequest).whenComplete(it) + } + return response.hits.hits.mapNotNull { hit -> + try { + val parser = XContentType.JSON.xContent().createParser( + NamedXContentRegistry.EMPTY, + LoggingDeprecationHandler.INSTANCE, + hit.sourceAsString + ) + parser.nextToken() + val doc = NotificationConfigDoc.parse(parser) + val info = DocInfo( + id = hit.id, + version = hit.version, + seqNo = hit.seqNo, + primaryTerm = hit.primaryTerm + ) + NotificationConfigDocInfo(info, doc) + } catch (e: Exception) { + log.warn("$LOG_PREFIX:getNotificationConfigs - failed to parse ${hit.id}: ${e.message}") + null + } } - return response.responses.mapNotNull { parseNotificationConfigDoc(it.id, it.response) } } /**