|
@@ -23,52 +23,88 @@ import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
- * BlockID of ozone (containerID localID).
|
|
|
+ * BlockID of Ozone (containerID + localID + blockCommitSequenceId).
|
|
|
*/
|
|
|
+
|
|
|
public class BlockID {
|
|
|
- private long containerID;
|
|
|
- private long localID;
|
|
|
+
|
|
|
+ private ContainerBlockID containerBlockID;
|
|
|
+ private long blockCommitSequenceId;
|
|
|
|
|
|
public BlockID(long containerID, long localID) {
|
|
|
- this.containerID = containerID;
|
|
|
- this.localID = localID;
|
|
|
+ this(containerID, localID, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private BlockID(long containerID, long localID, long bcsID) {
|
|
|
+ containerBlockID = new ContainerBlockID(containerID, localID);
|
|
|
+ blockCommitSequenceId = bcsID;
|
|
|
+ }
|
|
|
+
|
|
|
+ public BlockID(ContainerBlockID containerBlockID) {
|
|
|
+ this(containerBlockID, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private BlockID(ContainerBlockID containerBlockID, long bcsId) {
|
|
|
+ this.containerBlockID = containerBlockID;
|
|
|
+ blockCommitSequenceId = bcsId;
|
|
|
}
|
|
|
|
|
|
public long getContainerID() {
|
|
|
- return containerID;
|
|
|
+ return containerBlockID.getContainerID();
|
|
|
}
|
|
|
|
|
|
public long getLocalID() {
|
|
|
- return localID;
|
|
|
+ return containerBlockID.getLocalID();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String toString() {
|
|
|
- return new ToStringBuilder(this).
|
|
|
- append("containerID", containerID).
|
|
|
- append("localID", localID).
|
|
|
- toString();
|
|
|
+ public long getBlockCommitSequenceId() {
|
|
|
+ return blockCommitSequenceId;
|
|
|
}
|
|
|
|
|
|
- public HddsProtos.BlockID getProtobuf() {
|
|
|
- return HddsProtos.BlockID.newBuilder().
|
|
|
- setContainerID(containerID).setLocalID(localID).build();
|
|
|
+ public void setBlockCommitSequenceId(long blockCommitSequenceId) {
|
|
|
+ this.blockCommitSequenceId = blockCommitSequenceId;
|
|
|
}
|
|
|
|
|
|
- public static BlockID getFromProtobuf(HddsProtos.BlockID blockID) {
|
|
|
- return new BlockID(blockID.getContainerID(),
|
|
|
- blockID.getLocalID());
|
|
|
+ public ContainerBlockID getContainerBlockID() {
|
|
|
+ return containerBlockID;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setContainerBlockID(ContainerBlockID containerBlockID) {
|
|
|
+ this.containerBlockID = containerBlockID;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return new ToStringBuilder(this)
|
|
|
+ .append("containerID", containerBlockID.getContainerID())
|
|
|
+ .append("localID", containerBlockID.getLocalID())
|
|
|
+ .append("blockCommitSequenceId", blockCommitSequenceId)
|
|
|
+ .toString();
|
|
|
}
|
|
|
|
|
|
public ContainerProtos.DatanodeBlockID getDatanodeBlockIDProtobuf() {
|
|
|
return ContainerProtos.DatanodeBlockID.newBuilder().
|
|
|
- setContainerID(containerID).setLocalID(localID).build();
|
|
|
+ setContainerID(containerBlockID.getContainerID())
|
|
|
+ .setLocalID(containerBlockID.getLocalID())
|
|
|
+ .setBlockCommitSequenceId(blockCommitSequenceId).build();
|
|
|
}
|
|
|
|
|
|
public static BlockID getFromProtobuf(
|
|
|
ContainerProtos.DatanodeBlockID blockID) {
|
|
|
return new BlockID(blockID.getContainerID(),
|
|
|
- blockID.getLocalID());
|
|
|
+ blockID.getLocalID(), blockID.getBlockCommitSequenceId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public HddsProtos.BlockID getProtobuf() {
|
|
|
+ return HddsProtos.BlockID.newBuilder()
|
|
|
+ .setContainerBlockID(containerBlockID.getProtobuf())
|
|
|
+ .setBlockCommitSequenceId(blockCommitSequenceId).build();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static BlockID getFromProtobuf(HddsProtos.BlockID blockID) {
|
|
|
+ return new BlockID(
|
|
|
+ ContainerBlockID.getFromProtobuf(blockID.getContainerBlockID()),
|
|
|
+ blockID.getBlockCommitSequenceId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -80,11 +116,14 @@ public class BlockID {
|
|
|
return false;
|
|
|
}
|
|
|
BlockID blockID = (BlockID) o;
|
|
|
- return containerID == blockID.containerID && localID == blockID.localID;
|
|
|
+ return containerBlockID.equals(blockID.getContainerBlockID())
|
|
|
+ && blockCommitSequenceId == blockID.getBlockCommitSequenceId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(containerID, localID);
|
|
|
+ return Objects
|
|
|
+ .hash(containerBlockID.getContainerID(), containerBlockID.getLocalID(),
|
|
|
+ blockCommitSequenceId);
|
|
|
}
|
|
|
}
|