You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "advancedxy (via GitHub)" <gi...@apache.org> on 2023/03/05 13:19:15 UTC

[GitHub] [incubator-uniffle] advancedxy commented on a diff in pull request #684: [#80][Part-3] feat: add REST API for decommisson

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: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org