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

shell: command ls and nodes support output in json mode #290

Merged
merged 10 commits into from
Mar 4, 2019

Conversation

acelyc111
Copy link
Member

@acelyc111 acelyc111 commented Feb 25, 2019

Add an extra flag -j for command ls and nodes. Output with -j looks like:

>>> ls -d -j
{
    "general_info": {                     // section name
        "1": {                                       // key "1" is app id
            "app_id": "1",
            "status": "AVAILABLE",
            "app_name": "test",
            "app_type": "pegasus",
            "partition_count": "8",
            "replica_count": "3",
            "is_stateful": "true",
            "create_time": "-",
            "drop_time": "-",
            "drop_expire": "-",
            "envs_count": "0"
        },
        "2": {
            "app_id": "2",
            "status": "AVAILABLE",
            "app_name": "analysis_log",
            "app_type": "pegasus",
            "partition_count": "4",
            "replica_count": "3",
            "is_stateful": "true",
            "create_time": "-",
            "drop_time": "-",
            "drop_expire": "-",
            "envs_count": "0"
        },
        ...
    },
    "summary": {
        "total_app_count": "184",
        "fully_healthy_app_count": "184",
        "unhealthy_app_count": "0",
        "write_unhealthy_app_count": "0",
        "read_unhealthy_app_count": "0"
    }
}
>>> nodes -d -j
{
    "details": {
        "<ip>:<port>": {
            "address": "<ip>:<port>",
            "status": "ALIVE",
            "replica_count": "256",
            "primary_count": "101",
            "secondary_count": "155"
        },
        "<ip>:<port>": {
            "address": "<ip>:<port>",
            "status": "ALIVE",
            "replica_count": "265",
            "primary_count": "99",
            "secondary_count": "166"
        },
        ...
    },
    "summary": {
        "total_node_count": "10",
        "alive_node_count": "10",
        "unalive_node_count": "0"
    }
}

@qinzuoyan
Copy link
Contributor

在空行、分段这些细节上还需要改进,目前的打印结果层次不太清晰,譬如:

>>> nodes

details
address              status  
10.38.161.207:31801  ALIVE   
10.38.161.244:31801  ALIVE   
10.38.162.227:31801  ALIVE   
10.38.162.236:31801  ALIVE   
10.38.166.24:31801   ALIVE   
10.38.166.28:31801   ALIVE   
10.38.166.81:31801   ALIVE   
10.38.166.82:31801   ALIVE   
10.38.166.83:31801   ALIVE   
10.38.166.93:31801   ALIVE   
summary
total_node_count    : 10
alive_node_count    : 10
unalive_node_count  : 0 

>>> 

@acelyc111
Copy link
Member Author

在空行、分段这些细节上还需要改进,目前的打印结果层次不太清晰,譬如:

>>> nodes

details
address              status  
10.38.161.207:31801  ALIVE   
10.38.161.244:31801  ALIVE   
10.38.162.227:31801  ALIVE   
10.38.162.236:31801  ALIVE   
10.38.166.24:31801   ALIVE   
10.38.166.28:31801   ALIVE   
10.38.166.81:31801   ALIVE   
10.38.166.82:31801   ALIVE   
10.38.166.83:31801   ALIVE   
10.38.166.93:31801   ALIVE   
summary
total_node_count    : 10
alive_node_count    : 10
unalive_node_count  : 0 

>>> 

fixed

@qinzuoyan
Copy link
Contributor

为了显示清晰,不同的section之间最好用空行分隔,譬如下面就没有:

>>> nodes
[details]
address              status  
10.239.35.224:34801  ALIVE   
10.239.35.224:34802  ALIVE   
10.239.35.224:34803  ALIVE   
[summary]
total_node_count    : 3
alive_node_count    : 3
unalive_node_count  : 0

@acelyc111
Copy link
Member Author

acelyc111 commented Mar 1, 2019

为了显示清晰,不同的section之间最好用空行分隔,譬如下面就没有:

>>> nodes
[details]
address              status  
10.239.35.224:34801  ALIVE   
10.239.35.224:34802  ALIVE   
10.239.35.224:34803  ALIVE   
[summary]
total_node_count    : 3
alive_node_count    : 3
unalive_node_count  : 0

这得统一改rdsn,这个PR就不特殊处理了

nodes_detail = self._run_shell("nodes -d -j").strip()

primaries_per_node = {}
min_ = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么多加了下划线

Copy link
Member Author

Choose a reason for hiding this comment

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

min是库函数...

@qinzuoyan
Copy link
Contributor

为了显示清晰,不同的section之间最好用空行分隔,譬如下面就没有:

>>> nodes
[details]
address              status  
10.239.35.224:34801  ALIVE   
10.239.35.224:34802  ALIVE   
10.239.35.224:34803  ALIVE   
[summary]
total_node_count    : 3
alive_node_count    : 3
unalive_node_count  : 0

这得统一改rdsn,这个PR就不特殊处理了

现在rdsn也还没有提交,先一起都改好?

@acelyc111
Copy link
Member Author

acelyc111 commented Mar 4, 2019

为了显示清晰,不同的section之间最好用空行分隔,譬如下面就没有:

>>> nodes
[details]
address              status  
10.239.35.224:34801  ALIVE   
10.239.35.224:34802  ALIVE   
10.239.35.224:34803  ALIVE   
[summary]
total_node_count    : 3
alive_node_count    : 3
unalive_node_count  : 0

这得统一改rdsn,这个PR就不特殊处理了

现在rdsn也还没有提交,先一起都改好?

fixed

@qinzuoyan qinzuoyan merged commit 2d35dce into apache:master Mar 4, 2019
@neverchanje neverchanje mentioned this pull request Jun 14, 2019
24 tasks
@neverchanje neverchanje mentioned this pull request Jun 21, 2019
19 tasks
neverchanje pushed a commit to neverchanje/pegasus that referenced this pull request Jul 13, 2019
Former-commit-id: 4a78724131e5aadb4788693d81721a273cf934b7 [formerly 2d35dce]
Former-commit-id: 3cab8745a7f36f33c787650e073694c61a1c67c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants