-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-14889. Ability to check if a block has a replica on provided storage. #1573
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| import com.google.common.base.Preconditions; | ||
| import org.apache.hadoop.classification.InterfaceAudience; | ||
| import org.apache.hadoop.fs.StorageType; | ||
| import org.apache.hadoop.hdfs.protocol.Block; | ||
| import org.apache.hadoop.hdfs.protocol.BlockType; | ||
|
|
||
|
|
@@ -28,12 +29,16 @@ | |
| @InterfaceAudience.Private | ||
| public class BlockInfoContiguous extends BlockInfo { | ||
|
|
||
| private boolean hasProvidedStorage; | ||
|
|
||
| public BlockInfoContiguous(short size) { | ||
| super(size); | ||
| hasProvidedStorage = false; | ||
| } | ||
|
|
||
| public BlockInfoContiguous(Block blk, short size) { | ||
| super(blk, size); | ||
| hasProvidedStorage = false; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -62,6 +67,9 @@ boolean addStorage(DatanodeStorageInfo storage, Block reportedBlock) { | |
| // find the last null node | ||
| int lastNode = ensureCapacity(1); | ||
| setStorageInfo(lastNode, storage); | ||
| if (storage.getStorageType() == StorageType.PROVIDED) { | ||
| hasProvidedStorage = true; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -77,9 +85,31 @@ boolean removeStorage(DatanodeStorageInfo storage) { | |
| setStorageInfo(dnIndex, getStorageInfo(lastNode)); | ||
| // set the last entry to null | ||
| setStorageInfo(lastNode, null); | ||
| if (storage.getStorageType() == StorageType.PROVIDED | ||
| && !hasProvidedStorages()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this already guarantee is false?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see is the other method which goes over each DN, nevermind.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you go over the overhead added to the regular pipeline without Provided?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the check and there is no invocation in the regular pipeline now. |
||
| hasProvidedStorage = false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| boolean isProvided() { | ||
| return hasProvidedStorage; | ||
| } | ||
|
|
||
| private boolean hasProvidedStorages() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High level javadoc. |
||
| int len = getCapacity(); | ||
| for(int idx = 0; idx < len; idx++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after the for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| DatanodeStorageInfo cur = getStorageInfo(idx); | ||
| if(cur != null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after the if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| if (cur.getStorageType() == StorageType.PROVIDED) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int numNodes() { | ||
| assert this.storages != null : "BlockInfo is not initialized"; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just set by default as false and not do it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it for now.