Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#80][Part-3] feat: add REST API for decommisson #684

Merged
merged 25 commits into from
Mar 10, 2023

Conversation

xianjingfeng
Copy link
Member

@xianjingfeng xianjingfeng commented Mar 4, 2023

What changes were proposed in this pull request?

Add REST API for decommisson

Why are the changes needed?

Support shuffle server decommission. It is a part of #80

Does this PR introduce any user-facing change?

Env:

  • Server IP: 127.0.0.1
  • HTTP port: 19998
  • RPC port: 19999

Decommission example:

curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/decommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'

Cancel decommission example:

curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/cancelDecommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'

Get server list:

# path: /api/server/nodes[?id={serverId}][?status={serverStatus}]
curl  "http://127.0.0.1:19998/api/server/nodes?status=DECOMMISSIONING"
curl  "http://127.0.0.1:19998/api/server/nodes?status=ACTIVE"

How was this patch tested?

UT

# Conflicts:
#	coordinator/src/main/java/org/apache/uniffle/coordinator/SimpleClusterManager.java
# Conflicts:
#	common/src/main/java/org/apache/uniffle/common/ServerStatus.java
#	common/src/main/java/org/apache/uniffle/common/exception/InvalidRequestException.java
#	common/src/main/java/org/apache/uniffle/common/rpc/StatusCode.java
#	common/src/test/java/org/apache/uniffle/common/ServerStatusTest.java
#	coordinator/src/main/java/org/apache/uniffle/coordinator/CoordinatorGrpcService.java
#	coordinator/src/main/java/org/apache/uniffle/coordinator/CoordinatorServer.java
#	coordinator/src/main/java/org/apache/uniffle/coordinator/ServerNode.java
#	coordinator/src/main/java/org/apache/uniffle/coordinator/SimpleClusterManager.java
#	coordinator/src/test/java/org/apache/uniffle/coordinator/ServerNodeTest.java
#	integration-test/common/src/test/java/org/apache/uniffle/test/ShuffleServerInternalGrpcTest.java
#	internal-client/src/main/java/org/apache/uniffle/client/api/ShuffleServerInternalClient.java
#	internal-client/src/main/java/org/apache/uniffle/client/impl/grpc/ShuffleServerInternalGrpcClient.java
#	internal-client/src/main/java/org/apache/uniffle/client/request/RssDecommissionRequest.java
#	internal-client/src/main/java/org/apache/uniffle/client/response/RssDecommissionResponse.java
#	proto/src/main/proto/Rss.proto
#	server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
#	server/src/main/java/org/apache/uniffle/server/ShuffleServerConf.java
#	server/src/main/java/org/apache/uniffle/server/ShuffleServerInternalGrpcService.java
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2023

Codecov Report

Merging #684 (fddc053) into master (313ddd6) will increase coverage by 2.19%.
The diff coverage is 18.88%.

@@             Coverage Diff              @@
##             master     #684      +/-   ##
============================================
+ Coverage     60.79%   62.99%   +2.19%     
- Complexity     1839     1858      +19     
============================================
  Files           221      214       -7     
  Lines         12655    10774    -1881     
  Branches       1069     1065       -4     
============================================
- Hits           7694     6787     -907     
+ Misses         4553     3639     -914     
+ Partials        408      348      -60     
Impacted Files Coverage Δ
...a/org/apache/uniffle/coordinator/web/Response.java 0.00% <0.00%> (ø)
...dinator/web/request/CancelDecommissionRequest.java 0.00% <0.00%> (ø)
...e/coordinator/web/request/DecommissionRequest.java 0.00% <0.00%> (ø)
...e/uniffle/coordinator/web/servlet/BaseServlet.java 10.00% <10.00%> (ø)
.../uniffle/coordinator/web/servlet/NodesServlet.java 20.00% <20.00%> (ø)
...dinator/web/servlet/CancelDecommissionServlet.java 27.27% <27.27%> (ø)
...e/coordinator/web/servlet/DecommissionServlet.java 27.27% <27.27%> (ø)
.../apache/uniffle/coordinator/CoordinatorServer.java 59.37% <100.00%> (+1.99%) ⬆️
...ategy/storage/AppBalanceSelectStorageStrategy.java 70.00% <0.00%> (-2.00%) ⬇️
...org/apache/uniffle/server/LocalStorageChecker.java 68.14% <0.00%> (-0.73%) ⬇️
... and 19 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xianjingfeng xianjingfeng changed the title [#80][Part-2] feat: add REST API for decommisson [#80][Part-3] feat: add REST API for decommisson Mar 4, 2023
@zuston
Copy link
Member

zuston commented Mar 4, 2023

From the example listed in description, I have questions

  1. Do we support decommission multiple server in one request?
  2. Can we list all decommissioning and decommissioned servers?

@xianjingfeng
Copy link
Member Author

From the example listed in description, I have questions

  1. Do we support decommission multiple server in one request?
  2. Can we list all decommissioning and decommissioned servers?

Updated. Now supported.

Copy link
Contributor

@advancedxy advancedxy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM generally except one meta question.

@@ -179,6 +183,19 @@ private void initialization() throws Exception {
server = coordinatorFactory.getServer();
}

private void registerRESTAPI() throws Exception {
LOG.info("Register REST API");
jettyServer.addServlet(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is troublesome to get parameters from path in the current framework. Should we introduce other REST frameworks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we introduce other REST frameworks?

If it's too much trouble, I'm OK with current route path. If it's simple, I prefer the above REST path, which is more idiomatic. It's up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be more and more rest apis in the future. It is still troublesome to add an api under the current framework. So I think we can consider it later. How about introduce Jersey? @advancedxy @jerqi @zuston @kaijchen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with Jersey. Is it lightweight enough? Is it used widely?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with Jersey. Is it lightweight enough? Is it used widely?

Yes. Hadoop and Spark use Jersey either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if Jersey is lightweight. I hope the restful framework could be modern and lightweight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be more and more rest apis in the future. It is still troublesome to add an api under the current framework. So I think we can consider it later. How about introduce Jersey? @advancedxy @jerqi @zuston @kaijchen

I'm ok with current status. Let's make the new REST server framework a followup PR. Jersey itself seems a bit complex, but the path annotation https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e2081 is quite elegant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can refer to Apache Livy, it use scalatra. We can use similar Java framework.
https://www.51cto.com/article/311366.html

@jerqi
Copy link
Contributor

jerqi commented Mar 8, 2023

@smallzhongfeng Could you help me review this pr?

@xianjingfeng
Copy link
Member Author

Env: Server IP: 127.0.0.1 HTTP port: 19998 RPC port: 19999
Decommission example: curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/decommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
Cancel decommission example: curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/cancelDecommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
Get server list: /api/server/nodes[?id={serverId}][?status={serverStatus}] curl "http://127.0.0.1:19998/api/server/nodes?status=DECOMMISSIONING" curl "http://127.0.0.1:19998/api/server/nodes?status=ACTIVE"

Thanks @xianjingfeng for the work. I suggest adding some docs for this, in this PR or part-4.

Done

docs/coordinator_guide.md Show resolved Hide resolved
docs/coordinator_guide.md Outdated Show resolved Hide resolved
@smallzhongfeng
Copy link
Contributor

The GA failure cause by CoordinatorMetricsTest, could you rebase the latest code and trigger test again ?

Copy link
Contributor

@smallzhongfeng smallzhongfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@kaijchen kaijchen merged commit 4b5bf10 into apache:master Mar 10, 2023
@kaijchen
Copy link
Contributor

Thanks @xianjingfeng for the work, and thanks everyone reviewing.

@xianjingfeng xianjingfeng deleted the issue_80_part3 branch March 10, 2023 09:13
advancedxy pushed a commit to advancedxy/incubator-uniffle that referenced this pull request Mar 21, 2023
### What changes were proposed in this pull request?

Add REST API for decommisson

### Why are the changes needed?

Support shuffle server decommission. It is a part of apache#80

### Does this PR introduce _any_ user-facing change?

Env:

* Server IP: 127.0.0.1
* HTTP port: 19998
* RPC port: 19999

Decommission example:

```shell
curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/decommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
```

Cancel decommission example:

```shell
curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/cancelDecommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
```

Get server list:

```shell
# path: /api/server/nodes[?id={serverId}][?status={serverStatus}]
curl  "http://127.0.0.1:19998/api/server/nodes?status=DECOMMISSIONING"
curl  "http://127.0.0.1:19998/api/server/nodes?status=ACTIVE"
```

### How was this patch tested?

UT
xianjingfeng added a commit to xianjingfeng/incubator-uniffle that referenced this pull request Apr 5, 2023
### What changes were proposed in this pull request?

Add REST API for decommisson

### Why are the changes needed?

Support shuffle server decommission. It is a part of apache#80

### Does this PR introduce _any_ user-facing change?

Env:

* Server IP: 127.0.0.1
* HTTP port: 19998
* RPC port: 19999

Decommission example:

```shell
curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/decommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
```

Cancel decommission example:

```shell
curl -XPOST -H "Content-type:application/json" "http://127.0.0.1:19998/api/server/cancelDecommission" -d '{"serverIds:": ["127.0.0.1:19999"]}'
```

Get server list:

```shell
# path: /api/server/nodes[?id={serverId}][?status={serverStatus}]
curl  "http://127.0.0.1:19998/api/server/nodes?status=DECOMMISSIONING"
curl  "http://127.0.0.1:19998/api/server/nodes?status=ACTIVE"
```

### How was this patch tested?

UT
jerqi referenced this pull request in beryllw/incubator-uniffle May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants