Skip to content

Commit caaeb50

Browse files
committed
make targetShards return OpenSearchMajorVersion.V_2_X for serverless mode
1 parent c1987f9 commit caaeb50

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

mr/src/main/java/org/opensearch/hadoop/rest/RestClient.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ public String postDocument(Resource resource, BytesArray document) throws IOExce
297297
return id.toString();
298298
}
299299

300-
public void refresh(Resource resource) {
301-
// Skip refresh operation for serverless mode as _refresh endpoint is not supported
302-
if (settings.getServerlessMode()) {
303-
if (LOG.isDebugEnabled()) {
304-
LOG.debug("Serverless mode - skipping refresh operation (not supported in serverless)");
300+
public void refresh(Resource resource) {
301+
// Skip refresh operation for serverless mode as _refresh endpoint is not supported
302+
if (settings.getServerlessMode()) {
303+
if (LOG.isDebugEnabled()) {
304+
LOG.debug("Serverless mode - skipping refresh operation (not supported in serverless)");
305+
}
306+
return;
305307
}
306-
return;
308+
execute(POST, resource.refresh());
307309
}
308-
execute(POST, resource.refresh());
309-
}
310310

311311
public List<List<Map<String, Object>>> targetShards(String index, String routing) {
312312
List<List<Map<String, Object>>> shardsJson = null;
@@ -730,7 +730,7 @@ public ClusterInfo mainInfo() {
730730
if (this.settings.getServerlessMode()) {
731731
// Use a dummy UUID instead of null to avoid NPE in validation
732732
ClusterName clusterName = new ClusterName("serverless-collection", "serverless-uuid");
733-
return new ClusterInfo(clusterName, OpenSearchMajorVersion.LATEST);
733+
return new ClusterInfo(clusterName, OpenSearchMajorVersion.V_2_X);
734734
}
735735

736736
// Check for cached serverless cluster info

mr/src/main/java/org/opensearch/hadoop/rest/RestRepository.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ protected Map<ShardInfo, NodeInfo> doGetWriteTargetPrimaryShards(boolean clientN
302302

303303
return shards;
304304
} else {
305-
// Original implementation for non-serverless mode
306305
List<List<Map<String, Object>>> info = client.targetShards(resources.getResourceWrite().index(), SettingsUtils.getFixedRouting(settings));
307306
Map<ShardInfo, NodeInfo> shards = new LinkedHashMap<ShardInfo, NodeInfo>();
308307
List<NodeInfo> nodes = client.getHttpNodes(clientNodesOnly);

0 commit comments

Comments
 (0)