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

[#837] feat: Display information of all application through Cli. #964

Merged
merged 27 commits into from
Aug 11, 2023

Conversation

slfan1989
Copy link
Collaborator

@slfan1989 slfan1989 commented Jun 24, 2023

What changes were proposed in this pull request?

uniffle client-cli -host localhost -port 9526 --applications --app-list application_1,application_2 --appId-regex application_1 -o JSON

sh-3.2# ./uniffle client-cli -host localhost -port 9526 --applications --app-list application_1,application_2 --appId-regex application_1 -o JSON

2023-08-08 18:10:29,130 INFO uniffle.AbstractCustomCommandLine: connected to coordinator: http://localhost:9526.
2023-08-08 18:10:29,517 INFO cli.UniffleCLI: uniffle-client-cli : get applications
application: [{"applicationId":"application_1","user":"test","lastHeartBeatTime":"2023-08-08 18:10:23"}]

uniffle client-cli -host localhost -port 9526 --applications -o JSON

sh-3.2# ./uniffle client-cli -host localhost -port 9526 --applications -o JSON
2023-08-08 18:15:06,737 INFO uniffle.AbstractCustomCommandLine: connected to coordinator: http://localhost:9526.
2023-08-08 18:15:07,149 INFO cli.UniffleCLI: uniffle-client-cli : get applications
application: [{"applicationId":"application_0","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_10","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_100","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1000","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1001","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1002","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1003","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1004","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"},{"applicationId":"application_1005","user":"test","lastHeartBeatTime":"2023-08-08 18:14:51"}]

sh-3.2# ./uniffle client-cli -host localhost -port 9526 --applications

sh-3.2# ./uniffle client-cli -host localhost -port 9526 --applications
2023-08-08 18:16:32,561 INFO uniffle.AbstractCustomCommandLine: connected to coordinator: http://localhost:9526.
2023-08-08 18:16:33,066 INFO cli.UniffleCLI: uniffle-client-cli : get applications
+-------------------------------------------------------------------+
|                       Uniffle Applications                        |
+------------------+------+---------------------+-------------------+
|  ApplicationId   | User | Last HeartBeatTime  | RemoteStoragePath |
+------------------+------+---------------------+-------------------+
|  application_0   | test | 2023-08-08 18:16:30 |       null        |
|  application_1   | test | 2023-08-08 18:16:30 |       null        |
|  application_10  | test | 2023-08-08 18:16:30 |       null        |
| application_100  | test | 2023-08-08 18:16:30 |       null        |
| application_1000 | test | 2023-08-08 18:16:30 |       null        |
| application_1001 | test | 2023-08-08 18:16:30 |       null        |
| application_1002 | test | 2023-08-08 18:16:30 |       null        |
| application_1003 | test | 2023-08-08 18:16:30 |       null        |
| application_1004 | test | 2023-08-08 18:16:30 |       null        |
| application_1005 | test | 2023-08-08 18:16:30 |       null        |
+------------------+------+---------------------+-------------------+

Why are the changes needed?

fixes #837 [Subtask] Display information of all application through Cli.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Add Junit Test & Test environment verification

@slfan1989 slfan1989 marked this pull request as draft June 24, 2023 04:09
@slfan1989
Copy link
Collaborator Author

The code still needs to be improved and will be submitted again soon.

@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2023

Codecov Report

Attention: Patch coverage is 16.41337% with 275 lines in your changes missing coverage. Please review.

Project coverage is 54.81%. Comparing base (57c35ad) to head (8f90bf0).
Report is 462 commits behind head on master.

Files Patch % Lines
...c/main/java/org/apache/uniffle/cli/UniffleCLI.java 26.53% 71 Missing and 1 partial ⚠️
...main/java/org/apache/uniffle/api/AdminRestApi.java 1.85% 53 Missing ⚠️
...in/java/org/apache/uniffle/common/Application.java 0.00% 47 Missing ⚠️
...apache/uniffle/coordinator/ApplicationManager.java 0.00% 43 Missing ⚠️
...iffle/coordinator/web/resource/ServerResource.java 0.00% 19 Missing ⚠️
...java/org/apache/uniffle/client/RestClientImpl.java 0.00% 14 Missing ⚠️
...org/apache/uniffle/entity/ApplicationResponse.java 0.00% 10 Missing ⚠️
.../org/apache/uniffle/AbstractCustomCommandLine.java 47.05% 9 Missing ⚠️
...le/coordinator/web/request/ApplicationRequest.java 68.18% 7 Missing ⚠️
...n/java/org/apache/uniffle/cli/UniffleAdminCLI.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #964      +/-   ##
============================================
+ Coverage     54.27%   54.81%   +0.53%     
- Complexity     2550     2572      +22     
============================================
  Files           386      371      -15     
  Lines         21828    19924    -1904     
  Branches       1807     1863      +56     
============================================
- Hits          11848    10921     -927     
+ Misses         9278     8369     -909     
+ Partials        702      634      -68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@slfan1989 slfan1989 marked this pull request as ready for review June 25, 2023 23:44
@slfan1989
Copy link
Collaborator Author

slfan1989 commented Jun 25, 2023

@jerqi The function of the code has been completed, and I will add unit tests and screenshots of the test environment as soon as possible.

FormattingCLIUtils.java(apache/hadoop#5577) can help the command line to format the output, so that the content of the command line output has better readability. FormattingCLIUtils.java was contributed by @yl09099 , I think this class should be submitted by him.

@advancedxy
Copy link
Contributor

is it possible to output applications in json format? That way, it would be easier to pipe the result to other command line tools.

@slfan1989
Copy link
Collaborator Author

is it possible to output applications in json format? That way, it would be easier to pipe the result to other command line tools.

Thanks for the suggestion! I will try to use json to output the result.

@advancedxy
Copy link
Contributor

is it possible to output applications in json format? That way, it would be easier to pipe the result to other command line tools.

Thanks for the suggestion! I will try to use json to output the result.

I think current output is fine. It’s nice to have an option to output in json format.

@slfan1989
Copy link
Collaborator Author

I think current output is fine. It’s nice to have an option to output in json format.

Thanks for your suggestions! I will improve this part of the code.

@jerqi jerqi changed the title [#837] [Subtask] Display information of all application through Cli. [#837] (feat) Display information of all application through Cli. Jul 4, 2023
@jerqi jerqi changed the title [#837] (feat) Display information of all application through Cli. [#837] feat: Display information of all application through Cli. Jul 4, 2023
@jerqi jerqi requested a review from smallzhongfeng July 4, 2023 16:33
@slfan1989 slfan1989 self-assigned this Jul 7, 2023
smallzhongfeng
smallzhongfeng previously approved these changes Jul 9, 2023
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.

Thanks @slfan1989 Gernally lgtm except for some minor comment ! Could you resolve these conflicts first?


if (cmd.hasOption(uniffleApplicationCli.getOpt())) {
LOG.info("uniffle-client-cli : get applications");
PrintWriter writer = new PrintWriter(new OutputStreamWriter(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use try-resource? I think we need to close these stream finally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will modify code.

uniffleApplicationCli = new Option(shortPrefix + "apps", longPrefix + "applications",
true, "The command will be used to print a list of applications. \n"
+ "We usually use the command like this: \n"
+ "uniffle -apps|--applications application_167671938823_0001,application_167671938823_0002");
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -45,6 +50,7 @@ public class RestClientImpl implements RestClient {
private static final Logger LOG = LoggerFactory.getLogger(RestClientImpl.class);
private CloseableHttpClient httpclient;
private String baseUrl;
final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this need to be private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for reviewing the code, I will modify code.

jerqi
jerqi previously approved these changes Jul 12, 2023
Copy link
Contributor

@jerqi jerqi left a comment

Choose a reason for hiding this comment

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

@advancedxy
Copy link
Contributor

Seems like there are still some merge conflict, would you mind to resolve it first?

@slfan1989
Copy link
Collaborator Author

@advancedxy @smallzhongfeng @jerqi Can you help to review this PR again? Thank you very much!

cli/pom.xml Outdated
@@ -49,5 +49,9 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do cli depend on coordinator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed this issue. this is because I need to use the application object, this object I put it in common.

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=INFO
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
log4j.appender.RollingAppender=org.apache.log4j.RollingFileAppender
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we remove them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you very much for your help to review the code! I will revert this part of the change. When I was testing locally, I modified this file.

@slfan1989
Copy link
Collaborator Author

@advancedxy @jerqi Can you help to review this PR again? I have made improvements based on suggestions, including adding support for pagination, appId_regex, filtering by heartBeatTime range and output in JSON format.

@jerqi
Copy link
Contributor

jerqi commented Aug 8, 2023

You can run the command to fix style issues

mvn spotless:apply -Pspark3 -Pspark2 -Ptez -Pmr -Phadoop2.8

@advancedxy
Copy link
Contributor

Ah, this pr is getting bigger and bigger. Let's address the existing comments here and get it merged first.

New options and refines could be done in follow up prs.

@smallzhongfeng
Copy link
Contributor

Ah, this pr is getting bigger and bigger. Let's address the existing comments here and get it merged first.

New options and refines could be done in follow up prs.

+1, I think we should merge it at first, other features could be added slowly in the future to reduce the cost of review.

if (!result) {
final String exceptionErrorMsg =
"Timed out waiting for condition. "
+ (org.apache.commons.lang3.StringUtils.isNotEmpty(errorMsg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we import this package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for reviewing the code, I will fix it.

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.

Also cc @advancedxy

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.

LGTM.

It took too long, let's merge it first and do some refines in follow up prs.

@advancedxy advancedxy merged commit 1406e1f into apache:master Aug 11, 2023
32 checks passed
@advancedxy
Copy link
Contributor

Thanks @slfan1989 for your work. Merged.

@slfan1989
Copy link
Collaborator Author

@smallzhongfeng @advancedxy Thank you very much for helping to review the code!

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.

[Subtask] Display information of all application through Cli
5 participants