public boolean equals(final Object other) { if (other == null || !(other instanceof RegionInfo)) { return false; } return compareTo((RegionInfo) other) == 0; }
/** * Creates a new {@link RegionInfo} from a META {@link KeyValue}. * @param kv The {@link KeyValue} to use, which is assumed to be from * the cell {@code info:regioninfo} of a {@code .META.} region. * @param out_start_key A (@code {new byte[1][]}). * The start row of the region will be stored in {@code out_start_key[0]}. * Think "pointer-to-pointer" in Java (yeah!). * @return A newly created {@link RegionInfo}. * If calling {@link #table} on the object returned gives a reference to * {@link HBaseClient#EMPTY_ARRAY}, then the META entry indicates that the * region has been split (and thus this entry shouldn't be used). * @throws RegionOfflineException if the META entry indicates that the * region is offline. * @throws BrokenMetaException if the {@link KeyValue} seems invalid. */ static RegionInfo fromKeyValue(final KeyValue kv, final byte[][] out_start_key) { switch (kv.value()[0]) { case 0: // pre 0.92 -- fall through. case 1: // 0.92 to 0.94 return deserializeOldRegionInfo(kv, out_start_key); case 80: // 0.95+ return deserializeProtobufRegionInfo(kv, out_start_key); default: throw new IllegalStateException("Unsupported region info version: " + kv.value()[0] + " in .META. entry: " + kv); } }
private int predictSerializedSize() { int size = 0; size += 4; // int: Number of parameters. size += 1; // byte: Type of the 1st parameter. size += 3; // vint: region name length (3 bytes => max length = 32768). size += region.name().length; // The region name. size += 1; // byte: Type of the 2nd parameter. size += 3; // vint: row key length (3 bytes => max length = 32768). size += key.length; // The row key. return size; }
/** * Constructor. * @param lock The lock we wanna release. * @param region The region corresponding to {@code lock.region()}. */ ReleaseRequest(final RowLock lock, final RegionInfo region) { super(region.table(), // This isn't actually the key we locked, but it doesn't matter // as this information is useless for this RPC, we simply supply // a key to the parent constructor to make it happy. region.stopKey()); this.lock = lock; }
public String toString() { final StringBuilder buf = new StringBuilder(stringSizeHint()); toStringbuf(buf); return buf.toString(); }
/** * Package private ctor as we want read-only information for the caller to play * with. We'll make copies of all of the arrays so that the user can't modify * anything used by AsyncHBase internally. * @param region_info The region info to pull the table, name and stop key from * @param start_key The start key of the region * @param host The region server hosting the region. May be null if the region * isn't hosted anywhere. * @param port The port for the region server. May be zero if the region isn't * hosted anywhere. */ RegionLocation(RegionInfo region_info, byte[] start_key, String host, int port) { table = Arrays.copyOf(region_info.table(), region_info.table().length); region_name = Arrays.copyOf(region_info.name(), region_info.name().length); // may be an empty array but shouldn't be null stop_key = Arrays.copyOf(region_info.stopKey(), region_info.stopKey().length); this.start_key = Arrays.copyOf(start_key, start_key.length); this.host = host; this.port = port; }
start_key = RegionInfo.startKeyFromRegionName(region.name()); } else{ start_key = region.stopKey();
for (final BatchableRpc rpc : batch) { final RegionInfo region = rpc.getRegion(); final boolean new_region = !Bytes.equals(prev_region, region.name()); if (new_region) { if (actions != null) { // If not the first iteration ... actions.setRegion(rpc.getRegion().toProtobuf()); prev_region = region.name();
? regions_cache.put(region_name, new RegionInfo(EMPTY_ARRAY, region_name, EMPTY_ARRAY)) : regions_cache.remove(region_name); final RegionInfo region = (oldregion != null ? oldregion : new RegionInfo(EMPTY_ARRAY, region_name, EMPTY_ARRAY)); final RegionClient client = region2client.remove(region); if (oldregion != null && !Bytes.equals(oldregion.name(), region_name)) {
if (has_root) { if (Bytes.equals(table, HBASE98_ROOT)) { // HBase 0.98 and up. return new RegionInfo(HBASE98_ROOT, HBASE98_ROOT_REGION, EMPTY_ARRAY); return new RegionInfo(ROOT, ROOT_REGION, EMPTY_ARRAY); entry = null; final byte[] stop_key = region.stopKey(); if (stop_key != EMPTY_ARRAY
if (Arrays.equals(REGIONINFO, qualifier)) { final byte[][] tmp = new byte[1][]; // Yes, this is ugly. region = RegionInfo.fromKeyValue(kv, tmp); if (knownToBeNSREd(region)) { invalidateRegionCache(region.name(), true, "has marked it as split."); return null; final byte[] region_name = region.name(); if (host == null) {
table = tableFromRegionName(region_name); } catch (IllegalArgumentException e) { throw BrokenMetaException.badKV(null, "an `info:regioninfo' cell" final RegionInfo region = new RegionInfo(split ? EMPTY_ARRAY : table, region_name, stop_key); out_start_key[0] = start_key;
/** * Returns true if this region is known to be NSRE'd and shouldn't be used. * @see #handleNSRE */ private static boolean knownToBeNSREd(final RegionInfo region) { return region.table() == EMPTY_ARRAY; }
return new RegionInfo(split ? EMPTY_ARRAY : table, region_name, stop_key);
if (Arrays.equals(REGIONINFO, qualifier)) { final byte[][] tmp = new byte[1][]; // Yes, this is ugly. region = RegionInfo.fromKeyValue(kv, tmp); start_key = tmp[0]; } else if (Arrays.equals(SERVER, qualifier)
private Deferred<ArrayList<ArrayList<KeyValue>>> scanFinished(boolean end) { final byte[] region_stop_key = region.stopKey(); final byte[] region_start_key = RegionInfo.startKeyFromRegionName( region.name());
public String toString() { // Try to rightsize the buffer. final String method = new String(this.method((byte) 0)); final StringBuilder buf = new StringBuilder(16 + method.length() + 2 + 8 + (table == null ? 4 : table.length + 2) // Assumption: ASCII => +2 + 6 + (key == null ? 4 : key.length * 2) // Assumption: binary => *2 + 9 + (region == null ? 4 : region.stringSizeHint()) + 10 + 1 + 1); buf.append("HBaseRpc(method="); buf.append(method); buf.append(", table="); Bytes.pretty(buf, table); buf.append(", key="); Bytes.pretty(buf, key); buf.append(", region="); if (region == null) { buf.append("null"); } else { region.toStringbuf(buf); } buf.append(", attempt=").append(attempt) .append(", timeout=").append(timeout) .append(", hasTimedout=").append(has_timedout); buf.append(')'); return buf.toString(); }
final boolean new_region = !Bytes.equals(prev_region, region.name()); if (new_region) { if (actions != null) { // If not the first iteration ... actions.setRegion(rpc.getRegion().toProtobuf()); prev_region = region.name();
/** * Constructor. * @param region The region we were looking up * (if known, can be {@code null} if not known). * @param msg A message describing as precisely as possible what's wrong * with the META table. */ BrokenMetaException(final RegionInfo region, final String msg) { super("Your .META. table seems broken for " + (region == null ? "(unknown table)" : region) + ". " + msg); this.table = region.table(); }