HBASE-19406 Fix CompactionRequest equals and hashCode

This commit is contained in:
Andrew Purtell 2017-12-01 14:25:28 -08:00
parent d1e9c3d972
commit 99790a52ae
1 changed files with 74 additions and 0 deletions

View File

@ -136,6 +136,80 @@ public class CompactionRequestImpl implements CompactionRequest {
return tracker;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((filesToCompact == null) ? 0 : filesToCompact.hashCode());
result = prime * result + ((isMajor == null) ? 0 : isMajor.hashCode());
result = prime * result + (isOffPeak ? 1231 : 1237);
result = prime * result + priority;
result = prime * result + ((regionName == null) ? 0 : regionName.hashCode());
result = prime * result + (int) (selectionTime ^ (selectionTime >>> 32));
result = prime * result + ((storeName == null) ? 0 : storeName.hashCode());
result = prime * result + (int) (totalSize ^ (totalSize >>> 32));
result = prime * result + ((tracker == null) ? 0 : tracker.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CompactionRequestImpl other = (CompactionRequestImpl) obj;
if (filesToCompact == null) {
if (other.filesToCompact != null) {
return false;
}
} else if (!filesToCompact.equals(other.filesToCompact)) {
return false;
}
if (isMajor != other.isMajor) {
return false;
}
if (isOffPeak != other.isOffPeak) {
return false;
}
if (priority != other.priority) {
return false;
}
if (regionName == null) {
if (other.regionName != null) {
return false;
}
} else if (!regionName.equals(other.regionName)) {
return false;
}
if (selectionTime != other.selectionTime) {
return false;
}
if (storeName == null) {
if (other.storeName != null) {
return false;
}
} else if (!storeName.equals(other.storeName)) {
return false;
}
if (totalSize != other.totalSize) {
return false;
}
if (tracker == null) {
if (other.tracker != null) {
return false;
}
} else if (!tracker.equals(other.tracker)) {
return false;
}
return true;
}
@Override
public String toString() {
String fsList = filesToCompact.stream().filter(f -> f.getReader() != null)