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

Xiaoyu Yao commented on HDFS-11001:
-----------------------------------

Thanks [~anu] for the responses, below are some follow up questions:

bq. I did, but both getCommand and addCommand are write operations in our 
world. The reason being that getCommand returns the list of all commands at 
this point time, and we replace the commandMap with an empty list. It is 
actually a list with NullCommand with patch v002.

Thanks for clarify that getCommand is actually a write op in our world. Makes 
sense to me.

bq. We actually allocate this list in the constructor and it is fly-weight 
pattern as much as I can see. It does the allocation only once and then uses 
this list to return whenever we need.Since we allocate this list in the 
constructor what we return from getCommand is guaranteed to be not null.
{code}
nullList = new LinkedList<>();
nullList.add(NullCommand.newBuilder().build());
{code}

1. Sorry I was not clear about the fly-weight pattern. I mean the emptyList 
does not 
need to be constructed each time getCommand() return a non-empty list for a 
datanode.

{code}
LinkedList<SCMCommand> emptyList = new LinkedList<>();
{code}

2. You are right on the nullList. However, the allocation once guarantee is 
from the caller. 
It would be better to reuse the class static empty List so that the caller 
won't need to worry about unnecessary object creation, which looks like a be a 
very good case for fly-weight pattern. 

3. If we don't expect any operation at the datanode side for NullCommand, can 
we remove NullCommand to save a RPC roundtrip? This way, 
{{nullList.add(NullCommand.newBuilder().build());}} can also be removed. 

> Ozone:SCM: Add support for registerNode in SCM
> ----------------------------------------------
>
>                 Key: HDFS-11001
>                 URL: https://issues.apache.org/jira/browse/HDFS-11001
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: ozone
>    Affects Versions: HDFS-7240
>            Reporter: Anu Engineer
>            Assignee: Anu Engineer
>             Fix For: HDFS-7240
>
>         Attachments: HDFS-11001-HDFS-7240.001.patch, 
> HDFS-11001-HDFS-7240.002.patch
>
>
> Adds support for a datanode registration. Right now SCM relies on Namenode 
> for the datanode registration. With this change we will be able to run SCM 
> independently if needed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to