Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.base.Preconditions;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.client.BlockID;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;

import org.apache.hadoop.hdds.utils.db.Table;
Expand Down Expand Up @@ -196,16 +195,14 @@ public BlockData getBlock(Container container, BlockID blockID)
+ container.getContainerData().getContainerID() + " bcsId is "
+ containerBCSId + ".", UNKNOWN_BCSID);
}
byte[] kData = getBlockByID(db, blockID);
ContainerProtos.BlockData blockData =
ContainerProtos.BlockData.parseFrom(kData);
BlockData blockData = getBlockByID(db, blockID);
long id = blockData.getBlockID().getBlockCommitSequenceId();
if (id < bcsId) {
throw new StorageContainerException(
"bcsId " + bcsId + " mismatches with existing block Id "
+ id + " for block " + blockID + ".", BCSID_MISMATCH);
}
return BlockData.getFromProtoBuf(blockData);
return blockData;
}
}

Expand All @@ -226,9 +223,7 @@ public long getCommittedBlockLength(Container container, BlockID blockID)
// This is a post condition that acts as a hint to the user.
// Should never fail.
Preconditions.checkNotNull(db, DB_NULL_ERR_MSG);
byte[] kData = getBlockByID(db, blockID);
ContainerProtos.BlockData blockData =
ContainerProtos.BlockData.parseFrom(kData);
BlockData blockData = getBlockByID(db, blockID);
return blockData.getSize();
}
}
Expand Down Expand Up @@ -325,7 +320,7 @@ public void shutdown() {
BlockUtils.shutdownCache(ContainerCache.getInstance(config));
}

private byte[] getBlockByID(ReferenceCountedDB db, BlockID blockID)
private BlockData getBlockByID(ReferenceCountedDB db, BlockID blockID)
throws IOException {
String blockKey = Long.toString(blockID.getLocalID());

Expand All @@ -335,6 +330,6 @@ private byte[] getBlockByID(ReferenceCountedDB db, BlockID blockID)
NO_SUCH_BLOCK);
}

return blockData.getProtoBufMessage().toByteArray();
return blockData;
}
}