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


##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotClusterAdminClient.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+/**
+ * Client for cluster-level administration operations.
+ */
+public class PinotClusterAdminClient {
+  private final PinotAdminTransport _transport;
+  private final String _controllerAddress;
+  private final Map<String, String> _headers;
+
+  public PinotClusterAdminClient(PinotAdminTransport transport, String 
controllerAddress,
+      Map<String, String> headers) {
+    _transport = transport;
+    _controllerAddress = controllerAddress;
+    _headers = headers;
+  }
+
+  public String updateClusterConfig(String configJson)
+      throws PinotAdminException {
+    JsonNode response = _transport.executePost(_controllerAddress, 
"/cluster/configs", configJson, null, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Gets all cluster configurations.
+   */
+  public String getClusterConfigs()
+      throws PinotAdminException {
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/cluster/configs", null, _headers);
+    return response.toString();
+  }
+
+  public String deleteClusterConfig(String configName)
+      throws PinotAdminException {
+    JsonNode response = _transport.executeDelete(_controllerAddress, 
"/cluster/configs/" + configName, null,
+        _headers);
+    return response.toString();
+  }
+
+  /**
+   * Runs a periodic task cluster-wide.
+   */
+  public String runPeriodicTask(String taskName)
+      throws PinotAdminException {
+    Map<String, String> queryParams = Map.of("taskname", taskName);
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/periodictask/run", queryParams, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Runs a periodic task for a specific table and type.
+   */
+  public String runPeriodicTask(String taskName, @Nullable String tableName, 
@Nullable String tableType)
+      throws PinotAdminException {
+    Map<String, String> queryParams = new java.util.HashMap<>();
+    queryParams.put("taskname", taskName);
+    if (tableName != null) {
+      queryParams.put("tableName", tableName);
+    }
+    if (tableType != null) {
+      queryParams.put("type", tableType);
+    }
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/periodictask/run", queryParams, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Gets table rebalance job status by job id.
+   */
+  public String getRebalanceStatus(String jobId)

Review Comment:
   Done - PinotRebalanceAdminClient already exists as a separate class with 
rebalance methods.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotClusterAdminClient.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+/**
+ * Client for cluster-level administration operations.
+ */
+public class PinotClusterAdminClient {
+  private final PinotAdminTransport _transport;
+  private final String _controllerAddress;
+  private final Map<String, String> _headers;
+
+  public PinotClusterAdminClient(PinotAdminTransport transport, String 
controllerAddress,
+      Map<String, String> headers) {
+    _transport = transport;
+    _controllerAddress = controllerAddress;
+    _headers = headers;
+  }
+
+  public String updateClusterConfig(String configJson)
+      throws PinotAdminException {
+    JsonNode response = _transport.executePost(_controllerAddress, 
"/cluster/configs", configJson, null, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Gets all cluster configurations.
+   */
+  public String getClusterConfigs()
+      throws PinotAdminException {
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/cluster/configs", null, _headers);
+    return response.toString();
+  }
+
+  public String deleteClusterConfig(String configName)
+      throws PinotAdminException {
+    JsonNode response = _transport.executeDelete(_controllerAddress, 
"/cluster/configs/" + configName, null,
+        _headers);
+    return response.toString();
+  }
+
+  /**
+   * Runs a periodic task cluster-wide.
+   */
+  public String runPeriodicTask(String taskName)
+      throws PinotAdminException {
+    Map<String, String> queryParams = Map.of("taskname", taskName);
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/periodictask/run", queryParams, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Runs a periodic task for a specific table and type.
+   */
+  public String runPeriodicTask(String taskName, @Nullable String tableName, 
@Nullable String tableType)
+      throws PinotAdminException {
+    Map<String, String> queryParams = new java.util.HashMap<>();
+    queryParams.put("taskname", taskName);
+    if (tableName != null) {
+      queryParams.put("tableName", tableName);
+    }
+    if (tableType != null) {
+      queryParams.put("type", tableType);
+    }
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/periodictask/run", queryParams, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Gets table rebalance job status by job id.
+   */
+  public String getRebalanceStatus(String jobId)
+      throws PinotAdminException {
+    JsonNode response = _transport.executeGet(_controllerAddress, 
"/rebalanceStatus/" + jobId, null, _headers);
+    return response.toString();
+  }
+
+  /**
+   * Cancels a query by client id.
+   */
+  public String cancelQueryByClientId(String clientQueryId)

Review Comment:
   Done - PinotQueryAdminClient already exists as a separate class.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotClusterAdminClient.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+/**
+ * Client for cluster-level administration operations.
+ */
+public class PinotClusterAdminClient {
+  private final PinotAdminTransport _transport;
+  private final String _controllerAddress;
+  private final Map<String, String> _headers;
+
+  public PinotClusterAdminClient(PinotAdminTransport transport, String 
controllerAddress,
+      Map<String, String> headers) {
+    _transport = transport;
+    _controllerAddress = controllerAddress;
+    _headers = headers;
+  }
+

Review Comment:
   Done - `updateClusterConfig(String configName, String configValue)` already 
added.



##########
pinot-connectors/pinot-flink-connector/src/test/java/org/apache/pinot/connector/flink/sink/PinotSinkIntegrationTest.java:
##########
@@ -133,17 +130,20 @@ public void testPinotSinkWrite()
   }
 
   private void verifySegments(int numSegments, int numTotalDocs)
-      throws IOException {
-    JsonNode segments = JsonUtils.stringToJsonNode(sendGetRequest(
-            _controllerRequestURLBuilder.forSegmentListAPI(OFFLINE_TABLE_NAME, 
TableType.OFFLINE.toString()))).get(0)
-        .get("OFFLINE");
+      throws Exception {
+    List<String> segments = getOrCreateAdminClient().getSegmentClient()

Review Comment:
   Done - segment client already extracted to local variable.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotLogicalTableAdminClient.java:
##########
@@ -0,0 +1,114 @@
+/**
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+/**
+ * Client for logical table administration operations.
+ */
+public class PinotLogicalTableAdminClient {
+  private final PinotAdminTransport _transport;
+  private final String _controllerAddress;
+  private final java.util.Map<String, String> _headers;
+
+  public PinotLogicalTableAdminClient(PinotAdminTransport transport, String 
controllerAddress,
+      java.util.Map<String, String> headers) {

Review Comment:
   Done - replaced all fully-qualified class names with proper imports across 
all admin client files.



##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotTableAdminClient.java:
##########
@@ -369,4 +974,18 @@ public CompletableFuture<String> createTableAsync(String 
tableConfig, String val
     return _transport.executePostAsync(_controllerAddress, "/tables", 
tableConfig, queryParams, _headers)
         .thenApply(JsonNode::toString);
   }
+
+  private Map<String, String> mergeHeaders(@Nullable Map<String, String> 
headers) {

Review Comment:
   Done - all admin client classes now extend AbstractPinotAdminClient which 
provides shared fields and mergeHeaders.



-- 
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