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

Zhe Zhang commented on HDFS-8499:
---------------------------------

Thanks for the discussion Nicholas. I'll address your second question first:

bq. > ... I chose option A to avoid breaking the existing is-a relationship in 
trunk. ...
bq. Do you mean breaking the trunk code before HDFS-8499. If yes, Could you 
explain how Design #2 breaks the existing is-a relationship?
Below is the complete history of {{BlockInfo}} changes related to EC. Along the 
history, an invariant is that *an under-construction block is-a type of block*. 
This is the is-a relationship that I think design #2 breaks. 
# HDFS-7743 simply renamed {{BlockInfo}} as {{BlockInfoContiguous}} and 
{{BlockInfoUC}} as {{BlockInfoContiguousUC}}. IIUC this is only a temporary 
change to catch trunk changes on the two classes during branch development. It 
doesn't have any implication on is-a relationship *(B)* as Nicholas [summarized 
| 
https://issues.apache.org/jira/browse/HDFS-8499?focusedCommentId=14632040&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14632040].
# HDFS-8482 undid the above temporary renaming change for {{BlockInfo}}, and 
part of HDFS-8499 patch renamed {{BlockInfoUnderConstruction}} back.

Basically, before HDFS-7743, trunk always had {{BlockInfoUC}} representing *all 
under-construction blocks* and it is-a subclass of {{BlockInfo}}. Many places 
use it that way: 1) taking the block ID / genStamp of a {{BlockInfoUC}}; 2) 
adding a {{BlockInfoUC}} to an {{INodeFile}}; 3) using it as method parameter 
for type safety (e.g. {{StatefulBlockInfo}}), and so forth. Those are the 
practical code changes I'm concerned about. If we merge HDFS-7285 as-is, we'll 
be making those {{BlockInfoUC}} changes which are unrelated to EC.

HDFS-7743 and HDFS-8482 are just renames and I don't think they change the 
above analysis.

Thanks for sharing the thoughts on comparing the 2 is-a relationships. 

bq. BlockInfoContiguous and BlockInfoStriped could be implemented using 
completely different data structures. 
Compared with {{BlockInfoContiguous}}, {{BlockInfoStriped}} just needs an 
additional {{indices}} array to index into {{triplets}}.

bq. Therefore, BlockInfoContiguousUC and BlockInfoStripedUC may not share a lot 
of common code
Actually the two classes in HDFS-7285 branch have about 80% of logic. The only 
main difference is whether to use array or ArrayList to store {{replicas}}. I 
think that can be unified too.


bq. Also, if BlockInfoContiguousUC/BlockInfoStripedUC does not extend 
BlockInfoContiguous/BlockInfoStriped, their data structures cannot be made 
private to the classes.
In design #2 that argument applies to UC data structures like {{replicas}} 
(assuming we want to avoid duplicate code). Overall I still feel UC-complete 
and contiguous-striped are pretty symmetric dimensions. 

bq. ... so that the actual logic for contiguous BlockInfo is actually in the 
static methods in ContiguousBlockStorageOp. It is a procedural langage apporach 
but not OO apporach. 
I think this is the most fundamental issue we should discuss. Earlier 
discussions under this JIRA (before committing the patch) reached the 
conclusion that this is a multi-inheritance problem. Hence the solution of 
building shared Op / feature classes similar as {{INodeFile}} features. As 
mentioned above I plan to convert {{BlockInfoUC}} to an Op / feature class too, 
as a long term solution. Please advise if you disagree with the overall 
approach of summarizing contiguous / striped / UC operations as Op / feature 
classes or you see issues in the implementation of 
{{ContiguousBlockStorageOp}}. If the former, could you share some thoughts on 
how to solve the multi-inheritance problem?

> Refactor BlockInfo class hierarchy with static helper class
> -----------------------------------------------------------
>
>                 Key: HDFS-8499
>                 URL: https://issues.apache.org/jira/browse/HDFS-8499
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: namenode
>    Affects Versions: 2.7.0
>            Reporter: Zhe Zhang
>            Assignee: Zhe Zhang
>             Fix For: 2.8.0
>
>         Attachments: HDFS-8499.00.patch, HDFS-8499.01.patch, 
> HDFS-8499.02.patch, HDFS-8499.03.patch, HDFS-8499.04.patch, 
> HDFS-8499.05.patch, HDFS-8499.06.patch, HDFS-8499.07.patch, 
> HDFS-8499.UCFeature.patch, HDFS-bistriped.patch
>
>
> In HDFS-7285 branch, the {{BlockInfoUnderConstruction}} interface provides a 
> common abstraction for striped and contiguous UC blocks. This JIRA aims to 
> merge it to trunk.



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

Reply via email to