@Test
  public void testHashAndEqualsCode() {
    ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
    HRegionLocation hrl1 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1);
    HRegionLocation hrl2 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1);
    assertEquals(hrl1.hashCode(), hrl2.hashCode());
    assertTrue(hrl1.equals(hrl2));
    HRegionLocation hrl3 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa1);
    assertNotSame(hrl1, hrl3);
    // They are equal because they have same location even though they are
    // carrying different regions or timestamp.
    assertTrue(hrl1.equals(hrl3));
    ServerName hsa2 = ServerName.valueOf("localhost", 12345, -1L);
    HRegionLocation hrl4 = new HRegionLocation(RegionInfoBuilder.FIRST_META_REGIONINFO, hsa2);
    // These have same HRI but different locations so should be different.
    assertFalse(hrl3.equals(hrl4));
    HRegionLocation hrl5 =
      new HRegionLocation(hrl4.getRegion(), hrl4.getServerName(), hrl4.getSeqNum() + 1);
    assertTrue(hrl4.equals(hrl5));
  }
HRegionLocations are equal if they have the same 'location' -- i.e. host and port -- even if
they are carrying different regions. Verify that is indeed the case.
hbase-server/src/test/java/org/apache/hadoop/hbase/TestHRegionLocation.java