virajjasani commented on a change in pull request #1922:
URL: https://github.com/apache/hbase/pull/1922#discussion_r442300846



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SplitNormalizationPlan.java
##########
@@ -33,11 +36,9 @@
   private static final Logger LOG = 
LoggerFactory.getLogger(SplitNormalizationPlan.class.getName());
 
   private RegionInfo regionInfo;

Review comment:
       Seems like a good candidate for `final` and `setRegionInfo()` can be 
removed?

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/MergeNormalizationPlan.java
##########
@@ -78,4 +82,30 @@ public void execute(Admin admin) {
       LOG.error("Error during region merge: ", ex);
     }
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    MergeNormalizationPlan that = (MergeNormalizationPlan) o;
+
+    return new EqualsBuilder()
+      .append(firstRegion, that.firstRegion)
+      .append(secondRegion, that.secondRegion)
+      .isEquals();
+  }
+
+  @Override
+  public int hashCode() {

Review comment:
       By introducing `hashCode()` and `equals()`, comparison is no more 
dependant on getter methods, can we also remove `getFirstRegion()` and 
`getSecondRegion()`? Although they are useful, but I don't think they will be 
used anymore. Thought?

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/MergeNormalizationPlan.java
##########
@@ -78,4 +82,30 @@ public void execute(Admin admin) {
       LOG.error("Error during region merge: ", ex);
     }
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    MergeNormalizationPlan that = (MergeNormalizationPlan) o;
+
+    return new EqualsBuilder()
+      .append(firstRegion, that.firstRegion)
+      .append(secondRegion, that.secondRegion)
+      .isEquals();
+  }
+
+  @Override
+  public int hashCode() {
+    return new HashCodeBuilder(17, 37)

Review comment:
       Nice one, since we have two `final RegionInfo` and hopefully they are 
not getting mutated after plan generation, we can do this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to