hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Weiwei Yang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-12389) Ozone: oz commandline list calls should return valid JSON format output
Date Mon, 04 Sep 2017 04:26:00 GMT

    [ https://issues.apache.org/jira/browse/HDFS-12389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16152110#comment-16152110
] 

Weiwei Yang commented on HDFS-12389:
------------------------------------

Following code to parse output

{code}
with open('keys.json') as data_file:
  data = json.load(data_file)

for key in data:
  for attribute, value in key.iteritems():
    print attribute, value
{code}

it fails with error

{noformat}
Traceback (most recent call last):
  File "testkeys.py", line 4, in <module>
    data = json.load(data_file)
  File "/usr/lib64/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 369, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 9 column 1 - line 17 column 1 (char 186 - 372)
{noformat}

> Ozone: oz commandline list calls should return valid JSON format output
> -----------------------------------------------------------------------
>
>                 Key: HDFS-12389
>                 URL: https://issues.apache.org/jira/browse/HDFS-12389
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: ozone
>    Affects Versions: HDFS-7240
>            Reporter: Weiwei Yang
>            Assignee: Weiwei Yang
>
> At present the outputs of {{listVolume}}, {{listBucket}} and {{listKey}} are hard to
parse, for example following call
> {code}
> ./bin/hdfs oz -listVolume http://localhost:9864 -user wwei
> {code}
> lists all volumes in my cluster and it returns
> {noformat}
> {
>     "version" : 0,
>     "md5hash" : null,
>     "createdOn" : "Mon, 04 Sep 2017 03:25:22 GMT",
>     "modifiedOn" : "Mon, 04 Sep 2017 03:25:22 GMT",
>     "size" : 10240,
>     "keyName" : "key-0-22381",
>     "dataFileName" : null
>   }
>  {  
>     "version" : 0,
>     "md5hash" : null,
>     "createdOn" : "Mon, 04 Sep 2017 03:25:22 GMT",
>     "modifiedOn" : "Mon, 04 Sep 2017 03:25:22 GMT",
>     "size" : 10240,
>     "keyName" : "key-0-22381",
>     "dataFileName" : null
>   }
>   ...
> {noformat}
> this is not a valid JSON format output hence it is hard to parse in clients' script for
further interactions. Propose to reformat them to valid JSON data.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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


Mime
View raw message