xiangfu0 commented on code in PR #17167:
URL: https://github.com/apache/pinot/pull/17167#discussion_r3039278866


##########
pinot-connectors/pinot-flink-connector/src/main/java/org/apache/pinot/connector/flink/FlinkQuickStart.java:
##########
@@ -79,12 +76,11 @@ public static void main(String[] args)
     execEnv.setParallelism(2);
     DataStream<Row> srcDs = 
execEnv.fromCollection(data).returns(TEST_TYPE_INFO).keyBy(r -> r.getField(0));
 
-    HttpClient httpClient = HttpClient.getInstance();
-    ControllerRequestClient client = new ControllerRequestClient(
-        ControllerRequestURLBuilder.baseUrl(DEFAULT_CONTROLLER_URL), 
httpClient);
-    Schema schema = PinotConnectionUtils.getSchema(client, "starbucksStores");
-    TableConfig tableConfig = PinotConnectionUtils.getTableConfig(client, 
"starbucksStores", "OFFLINE");
-    srcDs.addSink(new PinotSinkFunction<>(new 
FlinkRowGenericRowConverter(TEST_TYPE_INFO), tableConfig, schema));
-    execEnv.execute();
+    try (PinotAdminClient client = new PinotAdminClient("localhost:9000")) {
+      Schema schema = 
client.getSchemaClient().getSchemaObject("starbucksStores");
+      TableConfig tableConfig = 
client.getTableClient().getTableConfigObject("starbucksStores", "OFFLINE");
+      srcDs.addSink(new PinotSinkFunction<>(new 
FlinkRowGenericRowConverter(TEST_TYPE_INFO), tableConfig, schema));
+      execEnv.execute();

Review Comment:
   Fixed - FlinkQuickStart now uses DEFAULT_CONTROLLER_ADDRESS constant.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotFileIngestClient.java:
##########
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.client.admin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.FileBody;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+
+
+/**
+ * Explicit client for Pinot controller endpoints that accept file or raw-body 
uploads.
+ */
+public class PinotFileIngestClient extends AbstractPinotAdminClient {
+  public PinotFileIngestClient(PinotAdminTransport transport, String 
controllerAddress, Map<String, String> headers) {
+    super(transport, controllerAddress, headers);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromFile.
+   */
+  public String buildIngestFromFileUrl(String tableNameWithType, Map<String, 
String> batchConfigMap) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromFile?tableNameWithType=" + tableNameWithType 
+ "&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8);
+  }

Review Comment:
   Fixed - batchConfigMapStr is now serialized using Jackson 
ObjectMapper.writeValueAsString() for proper JSON encoding.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotFileIngestClient.java:
##########
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.client.admin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.FileBody;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+
+
+/**
+ * Explicit client for Pinot controller endpoints that accept file or raw-body 
uploads.
+ */
+public class PinotFileIngestClient extends AbstractPinotAdminClient {
+  public PinotFileIngestClient(PinotAdminTransport transport, String 
controllerAddress, Map<String, String> headers) {
+    super(transport, controllerAddress, headers);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromFile.
+   */
+  public String buildIngestFromFileUrl(String tableNameWithType, Map<String, 
String> batchConfigMap) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromFile?tableNameWithType=" + tableNameWithType 
+ "&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromURI.
+   */
+  public String buildIngestFromUriUrl(String tableNameWithType, Map<String, 
String> batchConfigMap, String sourceUri) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromURI?tableNameWithType=" + tableNameWithType + 
"&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8) + 
"&sourceURIStr="
+        + URLEncoder.encode(sourceUri, StandardCharsets.UTF_8);
+  }
+
+  /**
+   * Posts a multipart file upload to the ingestFromFile endpoint.
+   */
+  public int ingestFromFile(String tableNameWithType, Map<String, String> 
batchConfigMap, File inputFile)
+      throws PinotAdminException {
+    return postFile(buildIngestFromFileUrl(tableNameWithType, batchConfigMap), 
inputFile);
+  }
+
+  /**
+   * Posts a multipart file upload to the ingestFromURI endpoint.
+   */
+  public int ingestFromUri(String tableNameWithType, Map<String, String> 
batchConfigMap, String sourceUri,
+      File inputFile)
+      throws PinotAdminException {
+    return postFile(buildIngestFromUriUrl(tableNameWithType, batchConfigMap, 
sourceUri), inputFile);
+  }
+
+  /**
+   * Posts a multipart file to an explicit URL.
+   */
+  public int postFile(String url, File inputFile)
+      throws PinotAdminException {
+    HttpEntity reqEntity =
+        MultipartEntityBuilder.create().addPart("file", new 
FileBody(inputFile.getAbsoluteFile())).build();
+    return execute(url, reqEntity);
+  }
+
+  /**
+   * Posts a plain string body to an explicit URL.
+   */
+  public int postString(String url, String body)
+      throws PinotAdminException {
+    return execute(url, new StringEntity(body));
+  }
+
+  private int execute(String url, HttpEntity entity)
+      throws PinotAdminException {
+    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+      HttpPost httpPost = new HttpPost(url);
+      for (Map.Entry<String, String> header : _headers.entrySet()) {
+        httpPost.setHeader(header.getKey(), header.getValue());
+      }
+      httpPost.setEntity(entity);
+      try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
+        return response.getCode();
+      }

Review Comment:
   Fixed - PinotFileIngestClient.execute() now applies the SSLContext from the 
transport when building the HTTP client.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotFileIngestClient.java:
##########
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.client.admin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.FileBody;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+
+
+/**
+ * Explicit client for Pinot controller endpoints that accept file or raw-body 
uploads.
+ */
+public class PinotFileIngestClient extends AbstractPinotAdminClient {
+  public PinotFileIngestClient(PinotAdminTransport transport, String 
controllerAddress, Map<String, String> headers) {
+    super(transport, controllerAddress, headers);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromFile.
+   */
+  public String buildIngestFromFileUrl(String tableNameWithType, Map<String, 
String> batchConfigMap) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(java.util.stream.Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromFile?tableNameWithType=" + tableNameWithType 
+ "&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromURI.
+   */
+  public String buildIngestFromUriUrl(String tableNameWithType, Map<String, 
String> batchConfigMap, String sourceUri) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(java.util.stream.Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromURI?tableNameWithType=" + tableNameWithType + 
"&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8) + 
"&sourceURIStr="
+        + URLEncoder.encode(sourceUri, StandardCharsets.UTF_8);
+  }

Review Comment:
   Fixed - switched from manual string concatenation to Jackson ObjectMapper 
for proper JSON serialization.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotFileIngestClient.java:
##########
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.client.admin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.entity.mime.FileBody;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+
+
+/**
+ * Explicit client for Pinot controller endpoints that accept file or raw-body 
uploads.
+ */
+public class PinotFileIngestClient extends AbstractPinotAdminClient {
+  public PinotFileIngestClient(PinotAdminTransport transport, String 
controllerAddress, Map<String, String> headers) {
+    super(transport, controllerAddress, headers);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromFile.
+   */
+  public String buildIngestFromFileUrl(String tableNameWithType, Map<String, 
String> batchConfigMap) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(java.util.stream.Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromFile?tableNameWithType=" + tableNameWithType 
+ "&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8);
+  }
+
+  /**
+   * Builds the ingestion URL for ingestFromURI.
+   */
+  public String buildIngestFromUriUrl(String tableNameWithType, Map<String, 
String> batchConfigMap, String sourceUri) {
+    String batchConfigMapStr =
+        batchConfigMap.entrySet().stream().map(e -> "\"" + e.getKey() + 
"\":\"" + e.getValue() + "\"")
+            .collect(java.util.stream.Collectors.joining(",", "{", "}"));
+    String baseUrl = _transport.getScheme() + "://" + _controllerAddress;
+    return baseUrl + "/ingestFromURI?tableNameWithType=" + tableNameWithType + 
"&batchConfigMapStr="
+        + URLEncoder.encode(batchConfigMapStr, StandardCharsets.UTF_8) + 
"&sourceURIStr="
+        + URLEncoder.encode(sourceUri, StandardCharsets.UTF_8);
+  }
+
+  /**
+   * Posts a multipart file upload to the ingestFromFile endpoint.
+   */
+  public int ingestFromFile(String tableNameWithType, Map<String, String> 
batchConfigMap, File inputFile)
+      throws PinotAdminException {
+    return postFile(buildIngestFromFileUrl(tableNameWithType, batchConfigMap), 
inputFile);
+  }
+
+  /**
+   * Posts a multipart file upload to the ingestFromURI endpoint.
+   */
+  public int ingestFromUri(String tableNameWithType, Map<String, String> 
batchConfigMap, String sourceUri,
+      File inputFile)
+      throws PinotAdminException {
+    return postFile(buildIngestFromUriUrl(tableNameWithType, batchConfigMap, 
sourceUri), inputFile);
+  }
+
+  /**
+   * Posts a multipart file to an explicit URL.
+   */
+  public int postFile(String url, File inputFile)
+      throws PinotAdminException {
+    HttpEntity reqEntity =
+        MultipartEntityBuilder.create().addPart("file", new 
FileBody(inputFile.getAbsoluteFile())).build();
+    return execute(url, reqEntity);
+  }
+
+  /**
+   * Posts a plain string body to an explicit URL.
+   */
+  public int postString(String url, String body)
+      throws PinotAdminException {
+    return execute(url, new StringEntity(body));
+  }
+
+  private int execute(String url, HttpEntity entity)
+      throws PinotAdminException {
+    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+      HttpPost httpPost = new HttpPost(url);
+      for (Map.Entry<String, String> header : _headers.entrySet()) {
+        httpPost.setHeader(header.getKey(), header.getValue());
+      }
+      httpPost.setEntity(entity);
+      try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
+        return response.getCode();
+      }
+    } catch (IOException e) {
+      throw new PinotAdminException("Failed to execute file ingest request to 
" + url, e);
+    }

Review Comment:
   Fixed - buildHttpClient() now applies SSLContext from transport when 
available.



##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/LaunchBackfillIngestionJobCommand.java:
##########
@@ -102,7 +102,7 @@ public boolean execute()
       Properties transportProperties = getTransportProperties(spec);
       PinotAdminClient adminClient = new PinotAdminClient(controllerAddress, 
transportProperties, authHeader);
 
-      _pinotSegmentApiClient = adminClient.getSegmentApiClient();
+      _pinotSegmentAdminClient = adminClient.getSegmentClient();
       // 1. Fetch existing segments that need to be backfilled (to be replaced)

Review Comment:
   Fixed - PinotAdminClient is now stored as a field and closed in a finally 
block.



##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/OperateClusterConfigCommand.java:
##########
@@ -144,36 +87,34 @@ public String run()
     if (StringUtils.isEmpty(_config) && !_operation.equalsIgnoreCase("GET")) {
       throw new UnsupportedOperationException("Empty config: " + _config);
     }
-    String clusterConfigUrl =
-        _controllerProtocol + "://" + _controllerHost + ":" + _controllerPort 
+ "/cluster/configs";
-    List<Header> headers = AuthProviderUtils.makeAuthHeaders(
-        AuthProviderUtils.makeAuthProvider(_authProvider, _authTokenUrl, 
_authToken, _user,
-        _password));
-    switch (_operation.toUpperCase()) {
-      case "ADD":
-      case "UPDATE":
-        String[] splits = _config.split("=");
-        if (splits.length != 2) {
-          throw new UnsupportedOperationException(
-              "Bad config: " + _config + ". Please follow the pattern of 
[Config Key]=[Config Value]");
-        }
-        String request = 
JsonUtils.objectToString(Collections.singletonMap(splits[0], splits[1]));
-        return sendRequest("POST", clusterConfigUrl, request, headers);
-      case "GET":
-        String response = sendRequest("GET", clusterConfigUrl, null, headers);
-        JsonNode jsonNode = JsonUtils.stringToJsonNode(response);
-        Iterator<String> fieldNamesIterator = jsonNode.fieldNames();
-        String results = "";
-        while (fieldNamesIterator.hasNext()) {
-          String key = fieldNamesIterator.next();
-          String value = jsonNode.get(key).textValue();
-          results += String.format("%s=%s\n", key, value);
-        }
-        return results;
-      case "DELETE":
-        return sendRequest("DELETE", String.format("%s/%s", clusterConfigUrl, 
_config), null, headers);
-      default:
-        throw new UnsupportedOperationException("Unsupported operation: " + 
_operation);
+    String normalizedOperation = _operation.toUpperCase(Locale.ROOT);
+    try (PinotAdminClient adminClient = getPinotAdminClient()) {
+      switch (normalizedOperation) {
+        case "ADD":
+        case "UPDATE":
+          String[] splits = _config.split("=");
+          if (splits.length != 2) {
+            throw new UnsupportedOperationException(
+                "Bad config: " + _config + ". Please follow the pattern of 
[Config Key]=[Config Value]");
+          }
+          String request = 
JsonUtils.objectToString(java.util.Collections.singletonMap(splits[0], 
splits[1]));
+          return adminClient.getClusterClient().updateClusterConfig(request);
+        case "GET":
+          String response = adminClient.getClusterClient().getClusterConfigs();
+          JsonNode jsonNode = JsonUtils.stringToJsonNode(response);
+          StringBuilder results = new StringBuilder();
+          jsonNode.fieldNames().forEachRemaining(key -> {
+            String value = jsonNode.get(key).textValue();
+            results.append(String.format("%s=%s%n", key, value));
+          });
+          return results.toString();
+        case "DELETE":
+          return adminClient.getClusterClient().deleteClusterConfig(_config);
+        default:
+          throw new UnsupportedOperationException("Unsupported operation: " + 
_operation);
+      }
+    } catch (PinotAdminException e) {
+      throw new RuntimeException("Failed to operate on cluster config", e);

Review Comment:
   Acknowledged - will let PinotAdminException propagate instead of wrapping in 
RuntimeException in a follow-up.



##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/OperateClusterConfigCommand.java:
##########
@@ -144,36 +87,34 @@ public String run()
     if (StringUtils.isEmpty(_config) && !_operation.equalsIgnoreCase("GET")) {
       throw new UnsupportedOperationException("Empty config: " + _config);
     }
-    String clusterConfigUrl =
-        _controllerProtocol + "://" + _controllerHost + ":" + _controllerPort 
+ "/cluster/configs";
-    List<Header> headers = AuthProviderUtils.makeAuthHeaders(
-        AuthProviderUtils.makeAuthProvider(_authProvider, _authTokenUrl, 
_authToken, _user,
-        _password));
-    switch (_operation.toUpperCase()) {
-      case "ADD":
-      case "UPDATE":
-        String[] splits = _config.split("=");
-        if (splits.length != 2) {
-          throw new UnsupportedOperationException(
-              "Bad config: " + _config + ". Please follow the pattern of 
[Config Key]=[Config Value]");
-        }
-        String request = 
JsonUtils.objectToString(Collections.singletonMap(splits[0], splits[1]));
-        return sendRequest("POST", clusterConfigUrl, request, headers);
-      case "GET":
-        String response = sendRequest("GET", clusterConfigUrl, null, headers);
-        JsonNode jsonNode = JsonUtils.stringToJsonNode(response);
-        Iterator<String> fieldNamesIterator = jsonNode.fieldNames();
-        String results = "";
-        while (fieldNamesIterator.hasNext()) {
-          String key = fieldNamesIterator.next();
-          String value = jsonNode.get(key).textValue();
-          results += String.format("%s=%s\n", key, value);
-        }
-        return results;
-      case "DELETE":
-        return sendRequest("DELETE", String.format("%s/%s", clusterConfigUrl, 
_config), null, headers);
-      default:
-        throw new UnsupportedOperationException("Unsupported operation: " + 
_operation);
+    String normalizedOperation = _operation.toUpperCase(Locale.ROOT);
+    try (PinotAdminClient adminClient = getPinotAdminClient()) {
+      switch (normalizedOperation) {
+        case "ADD":
+        case "UPDATE":
+          String[] splits = _config.split("=");
+          if (splits.length != 2) {
+            throw new UnsupportedOperationException(
+                "Bad config: " + _config + ". Please follow the pattern of 
[Config Key]=[Config Value]");
+          }
+          String request = 
JsonUtils.objectToString(java.util.Collections.singletonMap(splits[0], 
splits[1]));
+          return adminClient.getClusterClient().updateClusterConfig(request);

Review Comment:
   Fixed in this PR - the FQCN issue in PinotClusterAdminClient has been 
addressed. The OperateClusterConfigCommand uses the admin client's 
updateClusterConfig(key, value) which handles serialization internally.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to