You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-issues@hadoop.apache.org by "Szilard Nemeth (Jira)" <ji...@apache.org> on 2021/12/16 21:55:00 UTC

[jira] [Updated] (YARN-11052) Improve code quality in TestRMWebServicesNodeLabels

     [ https://issues.apache.org/jira/browse/YARN-11052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Szilard Nemeth updated YARN-11052:
----------------------------------
    Description: 
Possible code improvements I've identified in this class:

1. In TestRMWebServicesNodeLabels#testNodeLabels: Missing HTTP response status code checks for successful operations
2. Some methods are throwing too many types of Exceptions, e.g. "throws JSONException, Exception" can be simplified to "throws Exception"
3. Repeated code fragments can be replaced. E.g.: 
{code}
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
    response.getType().toString());
{code}

4. Some variable names are confusing, e.g. "NodeLabelsInfo nlsifo"
5. There are many node label related endpoint calls, all copy-pasted, for example: 
{code}
response =
    r.path("ws").path("v1").path("cluster")
        .path("add-node-labels").queryParam("user.name", userName)
        .accept(MediaType.APPLICATION_JSON)
        .entity(toJson(nodeLabelsInfo, NodeLabelsInfo.class),
            MediaType.APPLICATION_JSON)
        .post(ClientResponse.class);
{code}
This is just an example, there are many many endpoint calls duplicated like this, they could be extracted to methods.

6. Duplicated validation code of all REST endpoints can be simplified
7. There are weird, repeated log strings that could be removed, like: 
{code}
LOG.info("posted node nodelabel")
{code}

8. Constants could be added for labels, node ids, etc.

> Improve code quality in TestRMWebServicesNodeLabels
> ---------------------------------------------------
>
>                 Key: YARN-11052
>                 URL: https://issues.apache.org/jira/browse/YARN-11052
>             Project: Hadoop YARN
>          Issue Type: Improvement
>          Components: test
>            Reporter: Szilard Nemeth
>            Assignee: Szilard Nemeth
>            Priority: Minor
>
> Possible code improvements I've identified in this class:
> 1. In TestRMWebServicesNodeLabels#testNodeLabels: Missing HTTP response status code checks for successful operations
> 2. Some methods are throwing too many types of Exceptions, e.g. "throws JSONException, Exception" can be simplified to "throws Exception"
> 3. Repeated code fragments can be replaced. E.g.: 
> {code}
> assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
>     response.getType().toString());
> {code}
> 4. Some variable names are confusing, e.g. "NodeLabelsInfo nlsifo"
> 5. There are many node label related endpoint calls, all copy-pasted, for example: 
> {code}
> response =
>     r.path("ws").path("v1").path("cluster")
>         .path("add-node-labels").queryParam("user.name", userName)
>         .accept(MediaType.APPLICATION_JSON)
>         .entity(toJson(nodeLabelsInfo, NodeLabelsInfo.class),
>             MediaType.APPLICATION_JSON)
>         .post(ClientResponse.class);
> {code}
> This is just an example, there are many many endpoint calls duplicated like this, they could be extracted to methods.
> 6. Duplicated validation code of all REST endpoints can be simplified
> 7. There are weird, repeated log strings that could be removed, like: 
> {code}
> LOG.info("posted node nodelabel")
> {code}
> 8. Constants could be added for labels, node ids, etc.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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