HDFS-3293. Add toString(), equals(..) and hashCode() to JournalInfo. Contributed by Hari Mankude

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1332458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2012-04-30 22:57:22 +00:00
parent 1e88c1f088
commit 2af70cb517
2 changed files with 28 additions and 0 deletions

View File

@ -74,6 +74,9 @@ Trunk (unreleased changes)
HDFS-2743. Streamline usage of bookkeeper journal manager.
(Ivan Kelly via umamahesh)
HDFS-3293. Add toString(), equals(..) and hashCode() to JournalInfo.
(Hari Mankude via szetszwo)
OPTIMIZATIONS
HDFS-2834. Add a ByteBuffer-based read API to DFSInputStream.

View File

@ -45,4 +45,29 @@ public String getClusterId() {
public int getNamespaceId() {
return namespaceId;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("lv=").append(layoutVersion).append(";cid=").append(clusterId)
.append(";nsid=").append(namespaceId);
return sb.toString();
}
@Override
public boolean equals(Object o) {
JournalInfo jInfo;
if (!(o instanceof JournalInfo)) {
return false;
}
jInfo = (JournalInfo) o;
return ((jInfo.clusterId.equals(this.clusterId))
&& (jInfo.namespaceId == this.namespaceId)
&& (jInfo.layoutVersion == this.layoutVersion));
}
@Override
public int hashCode() {
return (namespaceId ^ layoutVersion ^ clusterId.hashCode());
}
}