/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof HRegionInfo)) { return false; } return this.compareTo((HRegionInfo)o) == 0; }
@Override public int compareTo(TabletFragmentInfo o) { return tabletInfoImpl != null ? tabletInfoImpl.compareTo(o.tabletInfoImpl) : regionInfo.compareTo(o.regionInfo); }
@Test public void testLastRegionCompare() { HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); HRegionInfo hrip = new HRegionInfo( tableDesc.getTableName(), Bytes.toBytes("a"), new byte[0]); HRegionInfo hric = new HRegionInfo( tableDesc.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("b")); assertTrue(hrip.compareTo(hric) > 0); }
HRegionInfo older = new HRegionInfo(tableName, empty, empty, false, 0L); HRegionInfo newer = new HRegionInfo(tableName, empty, empty, false, 1L); assertTrue(older.compareTo(newer) < 0); assertTrue(newer.compareTo(older) > 0); assertEquals(0, older.compareTo(older)); assertEquals(0, newer.compareTo(newer)); assertNotEquals(0, a.compareTo(b)); HTableDescriptor t = new HTableDescriptor(TableName.valueOf("t")); byte [] midway = Bytes.toBytes("midway"); a = new HRegionInfo(t.getTableName(), null, midway); b = new HRegionInfo(t.getTableName(), midway, null); assertTrue(a.compareTo(b) < 0); assertTrue(b.compareTo(a) > 0); assertEquals(a, a); assertEquals(0, a.compareTo(a)); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g")); assertTrue(a.compareTo(b) < 0); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g")); assertTrue(a.compareTo(b) < 0); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("eeee")); assertTrue(a.compareTo(b) < 0);
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof HRegionInfo)) { return false; } return this.compareTo((HRegionInfo)o) == 0; }
@Override public int compareTo(RegionName o) { return hRegionInfo.compareTo(o.hRegionInfo); } }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof HRegionInfo)) { return false; } return this.compareTo((HRegionInfo)o) == 0; }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof HRegionInfo)) { return false; } return this.compareTo((HRegionInfo)o) == 0; }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof HRegionInfo)) { return false; } return this.compareTo((HRegionInfo)o) == 0; }
@Override public int compareTo(TabletFragmentInfo o) { return tabletInfoImpl != null ? tabletInfoImpl.compareTo(o.tabletInfoImpl) : regionInfo.compareTo(o.regionInfo); }
/** * Constructor * @param a region a to merge * @param b region b to merge * @param forcible if false, we will only merge adjacent regions * @param masterSystemTime the time at the master side */ public RegionMergeTransactionImpl(final Region a, final Region b, final boolean forcible, long masterSystemTime) { if (a.getRegionInfo().compareTo(b.getRegionInfo()) <= 0) { this.region_a = (HRegion)a; this.region_b = (HRegion)b; } else { this.region_a = (HRegion)b; this.region_b = (HRegion)a; } this.forcible = forcible; this.masterSystemTime = masterSystemTime; this.mergesdir = region_a.getRegionFileSystem().getMergesDir(); }
@Test public void testLastRegionCompare() { HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); HRegionInfo hrip = new HRegionInfo( tableDesc.getTableName(), Bytes.toBytes("a"), new byte[0]); HRegionInfo hric = new HRegionInfo( tableDesc.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("b")); assertTrue(hrip.compareTo(hric) > 0); }
HRegionInfo older = new HRegionInfo(tableName, empty, empty, false, 0L); HRegionInfo newer = new HRegionInfo(tableName, empty, empty, false, 1L); assertTrue(older.compareTo(newer) < 0); assertTrue(newer.compareTo(older) > 0); assertEquals(0, older.compareTo(older)); assertEquals(0, newer.compareTo(newer)); assertNotEquals(0, a.compareTo(b)); HTableDescriptor t = new HTableDescriptor(TableName.valueOf("t")); byte [] midway = Bytes.toBytes("midway"); a = new HRegionInfo(t.getTableName(), null, midway); b = new HRegionInfo(t.getTableName(), midway, null); assertTrue(a.compareTo(b) < 0); assertTrue(b.compareTo(a) > 0); assertEquals(a, a); assertEquals(0, a.compareTo(a)); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g")); assertTrue(a.compareTo(b) < 0); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g")); assertTrue(a.compareTo(b) < 0); a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd")); b = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("eeee")); assertTrue(a.compareTo(b) < 0);
byte[] endKey = null; if (a.compareTo(b) <= 0) { startKey = a.getStartKey(); } else {
throw new ServiceException(new MergeRegionException("Can't merge non-default replicas")); if (regionInfoA.compareTo(regionInfoB) == 0) { throw new ServiceException(new MergeRegionException( "Unable to merge a region to itself " + regionInfoA + ", " + regionInfoB));