advancedxy commented on code in PR #684:
URL: https://github.com/apache/incubator-uniffle/pull/684#discussion_r1125665019


##########
coordinator/src/main/java/org/apache/uniffle/coordinator/CoordinatorServer.java:
##########
@@ -179,6 +183,19 @@ private void initialization() throws Exception {
     server = coordinatorFactory.getServer();
   }
 
+  private void registerRESTAPI() throws Exception {
+    LOG.info("Register REST API");
+    jettyServer.addServlet(

Review Comment:
   How do you think to struct REST api as follows:
   ```
   GET /api/v1/servers # list all servers. 
   GET /api/v1/servers/:id # get the specific server with id.
   POST /api/v1/servers/:id/decommission # start decommission of server with id
   POST /api/v1/servers/:id/cancelDecommission #...
   POST /api/v1/servers/decommission # batch decommission. similar to the 
current impl
   POST /api/v1/servers/cancelDecommission # batch cancel decommission.
   ```



##########
common/src/test/java/org/apache/uniffle/common/metrics/TestUtils.java:
##########
@@ -42,4 +43,22 @@ public static String httpGetMetrics(String urlString) throws 
IOException {
     in.close();
     return content.toString();
   }
+
+  public static String httpPost(String urlString, String postData) throws 
IOException {
+    URL url = new URL(urlString);
+    HttpURLConnection con = (HttpURLConnection) url.openConnection();
+    con.setDoOutput(true);
+    con.setRequestMethod("POST");
+    OutputStream outputStream = con.getOutputStream();
+    outputStream.write(postData.getBytes());
+    BufferedReader in = new BufferedReader(
+        new InputStreamReader(con.getInputStream()));
+    String inputLine;
+    StringBuffer content = new StringBuffer();
+    while ((inputLine = in.readLine()) != null) {
+      content.append(inputLine);
+    }
+    in.close();

Review Comment:
   Could you use a try with resource here?



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