Skip to content

Commit

Permalink
[SMALLFIX] Improve block location naming
Browse files Browse the repository at this point in the history
Cherry-pick of existing commit.
orig-pr: #12509
orig-commit: 3dc8d1d
orig-commit-author: Jiacheng Liu <[email protected]>

pr-link: #12518
change-id: cid-9d69248cbab45b0953559932b25bdecab0d390f9
  • Loading branch information
alluxio-bot authored Nov 17, 2020
1 parent fdef847 commit 6b3236a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static BlockStoreLocation anyDirInTier(String tierAlias) {
* @param mediumType mediumType this returned block store location will represent
* @return a BlockStoreLocation of any dir in any tier with a specific medium
*/
public static BlockStoreLocation anyDirInTierWithMedium(String mediumType) {
public static BlockStoreLocation anyDirInAnyTierWithMedium(String mediumType) {
return new BlockStoreLocation(ANY_TIER, ANY_DIR, mediumType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public String createBlock(long sessionId, long blockId, String tierAlias,
if (medium.isEmpty()) {
loc = BlockStoreLocation.anyDirInTier(tierAlias);
} else {
loc = BlockStoreLocation.anyDirInTierWithMedium(medium);
loc = BlockStoreLocation.anyDirInAnyTierWithMedium(medium);
}
TempBlockMeta createdBlock;
try {
Expand Down Expand Up @@ -353,7 +353,7 @@ public void createBlockRemote(long sessionId, long blockId, String tierAlias,
if (medium.isEmpty()) {
loc = BlockStoreLocation.anyDirInTier(tierAlias);
} else {
loc = BlockStoreLocation.anyDirInTierWithMedium(medium);
loc = BlockStoreLocation.anyDirInAnyTierWithMedium(medium);
}
mBlockStore.createBlock(sessionId, blockId, AllocateOptions.forCreate(initialBytes, loc));
}
Expand Down Expand Up @@ -438,7 +438,7 @@ public void moveBlock(long sessionId, long blockId, String tierAlias)
public void moveBlockToMedium(long sessionId, long blockId, String mediumType)
throws BlockDoesNotExistException, BlockAlreadyExistsException, InvalidWorkerStateException,
WorkerOutOfSpaceException, IOException {
BlockStoreLocation dst = BlockStoreLocation.anyDirInTierWithMedium(mediumType);
BlockStoreLocation dst = BlockStoreLocation.anyDirInAnyTierWithMedium(mediumType);
long lockId = mBlockStore.lockBlock(sessionId, blockId);
try {
BlockMeta meta = mBlockStore.getBlockMeta(sessionId, blockId, lockId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private StorageDirView allocateBlock(long sessionId, long blockSize,

String mediumType = location.mediumType();
if (!mediumType.equals(BlockStoreLocation.ANY_MEDIUM)
&& location.equals(BlockStoreLocation.anyDirInTierWithMedium(mediumType))) {
&& location.equals(BlockStoreLocation.anyDirInAnyTierWithMedium(mediumType))) {
for (StorageTierView tierView : mMetadataView.getTierViews()) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getMediumType().equals(mediumType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ private StorageDirView allocateBlock(long sessionId, long blockSize,
} else if (location.equals(BlockStoreLocation.anyDirInTier(location.tierAlias()))) {
StorageTierView tierView = mMetadataView.getTierView(location.tierAlias());
candidateDirView = getCandidateDirInTier(tierView, blockSize, BlockStoreLocation.ANY_MEDIUM);
} else if (location.equals(BlockStoreLocation.anyDirInTierWithMedium(location.mediumType()))) {
} else if (location.equals(BlockStoreLocation.anyDirInAnyTierWithMedium(
location.mediumType()))) {
for (StorageTierView tierView : mMetadataView.getTierViews()) {
candidateDirView = getCandidateDirInTier(tierView, blockSize, location.mediumType());
if (candidateDirView != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private StorageDirView allocateBlock(long sessionId, long blockSize,
mTierAliasToLastDirMap.put(tierView.getTierViewAlias(), dirViewIndex);
return tierView.getDirView(dirViewIndex);
}
} else if (location.equals(BlockStoreLocation.anyDirInTierWithMedium(location.mediumType()))) {
} else if (location.equals(BlockStoreLocation.anyDirInAnyTierWithMedium(
location.mediumType()))) {
String medium = location.mediumType();
int tierIndex = 0; // always starting from the first tier
for (int i = 0; i < mMetadataView.getTierViews().size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testBelongTo() {
BlockStoreLocation dirInMEM = new BlockStoreLocation("MEM", 1);
BlockStoreLocation dirInHDD = new BlockStoreLocation("HDD", 2);
BlockStoreLocation dirWithMediumType = new BlockStoreLocation("MEM", 1, "MEM");
BlockStoreLocation anyTierWithMEM = BlockStoreLocation.anyDirInTierWithMedium("MEM");
BlockStoreLocation anyTierWithMEM = BlockStoreLocation.anyDirInAnyTierWithMedium("MEM");

assertTrue(anyTier.belongsTo(anyTier));
assertFalse(anyTier.belongsTo(anyDirInTierMEM));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ public void createBlockMetaWithoutEviction() throws Exception {

@Test
public void createBlockMetaWithMediumType() throws Exception {
BlockStoreLocation loc = BlockStoreLocation.anyDirInTierWithMedium("MEM");
BlockStoreLocation loc = BlockStoreLocation.anyDirInAnyTierWithMedium("MEM");
TempBlockMeta tempBlockMeta = mBlockStore.createBlock(SESSION_ID1, TEMP_BLOCK_ID,
AllocateOptions.forCreate(1, loc));
assertEquals(1, tempBlockMeta.getBlockSize());
assertEquals(mTestDir2, tempBlockMeta.getParentDir());

BlockStoreLocation loc2 = BlockStoreLocation.anyDirInTierWithMedium("SSD");
BlockStoreLocation loc2 = BlockStoreLocation.anyDirInAnyTierWithMedium("SSD");
TempBlockMeta tempBlockMeta2 = mBlockStore.createBlock(SESSION_ID1, TEMP_BLOCK_ID2,
AllocateOptions.forCreate(1, loc2));
assertEquals(1, tempBlockMeta2.getBlockSize());
Expand Down

0 comments on commit 6b3236a

Please sign in to comment.