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

Yiqun Lin edited comment on HDFS-11712 at 4/28/17 5:07 AM:
-----------------------------------------------------------

Thanks [~anu] for taking a look!
{quote}
Do you think we can use ObjectReader or ObjectWriter in many places instead of 
ObjectMapper ? 
{quote}
Yes, that's also what I want to do in the new patch.
{{ObjectMapper}} is a heavy-weight object, but {{ObjectReader}} and 
{{ObjectWriter}} are light-weight instances and they are fully thread-safe, 
reusable.
In the updated patch, I am mainly doing these three things:

* If the instance {{ObjectMapper}}, {{ObjectReader}} or {{ObjectWriter}} 
confgigured is complete the same, I will put that instance into the Utility 
class {{JsonUtils}}. It's safe to do this since {{ObjectMapper}} or other 
related instances are thread safe as long as we have configured instances 
before use and not changed the configuration later.
* If not, I am creating the instance in there all classes respectively and 
reuse the instance in their own class.
* Upgrade all {{ObjectMapper}} APIs used in ozone, API version changed from 
jackson1 to jackson2.

Attach the new patch. Patch seems a little big but actually the change is 
minor, just a few codes being updated and it will not take a long time to 
review, :).


was (Author: linyiqun):
Thanks [~anu] for taking a look!
{quote}
Do you think we can use ObjectReader or ObjectWriter in many places instead of 
ObjectMapper ? 
{quote}
Yes, that's also what I want to do in the new patch.
{{ObjectMapper}} is a heavy-weight object, but {{ObjectReader}} and 
{{ObjectWriter}} are light-weight instances and they are fully thread-safe, 
reusable.
In the updated patch, I am mainly doing these three things:

* If the instance {{ObjectMapper}}, {{ObjectReader}} or {{ObjectWriter}} 
congigured is complete the same, I will put that instance into the Utility 
class {{JsonUtils}}. It's safe to do this since {{ObjectMapper}} or other 
related instances are thread safe as long as we have configured instances 
before use and not changed the configuration later.
* If not, I am creating the instance in there all classes respectively and 
reuse the instance in their own class.
* Upgrade all {{ObjectMapper}} APIs used in ozone, API version changed from 
jackson1 to jackson2.

Attach the new patch. Patch seems a little big but actually the change is 
minor, just a few codes being updated and it will not take a long time to 
review, :).

> Ozone: Reuse ObjectMapper instance to improve the performance
> -------------------------------------------------------------
>
>                 Key: HDFS-11712
>                 URL: https://issues.apache.org/jira/browse/HDFS-11712
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: ozone
>    Affects Versions: HDFS-7240
>            Reporter: Yiqun Lin
>            Assignee: Yiqun Lin
>         Attachments: HDFS-11712-HDFS-7240.001.patch, 
> HDFS-11712-HDFS-7240.002.patch
>
>
> In the ozone, there are many places using {{ObjectMapper}} to do the 
> object-json transformation. From the page of {{ObjectMapper}} 
> (https://github.com/FasterXML/jackson-docs/wiki/Presentation:-Jackson-Performance),
>  {{ObjectMapper}} is a heavy-weight object, it not a good bevahiour  to 
> create this instance everywhere.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to