/** * @param bytes serialized bytes * @return A HRegionInfo instance built out of passed <code>bytes</code> * or <code>null</code> if passed bytes are null or an empty array. * @throws IOException e */ public static HRegionInfo getHRegionInfoOrNull(final byte [] bytes) throws IOException { return (bytes == null || bytes.length <= 0)? null : getHRegionInfo(bytes); }
HRegionInfo splitA = Writables.getHRegionInfo(rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER)); HRegionInfo splitB = Writables.getHRegionInfo(rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER));
public static HRegionInfo getHRegionInfo( Result data) throws IOException { byte [] bytes = data.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (bytes == null) return null; HRegionInfo info = Writables.getHRegionInfo(bytes); LOG.info("Current INFO from scan results = " + info); return info; }
/** * Get HRegionInfo from passed Map of row values. * @param result Map to do lookup in. * @return Null if not found (and logs fact that expected COL_REGIONINFO * was missing) else deserialized {@link HRegionInfo} * @throws IOException */ static HRegionInfo getHRegionInfo(final Result result) throws IOException { byte [] bytes = result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (bytes == null) { LOG.warn("REGIONINFO_QUALIFIER is empty in " + result); return null; } return Writables.getHRegionInfo(bytes); }
@Override public boolean processRowInternal(Result result) throws IOException { if (result == null || result.isEmpty()) { return true; } byte [] bytes = result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (bytes == null) { LOG.warn("Null REGIONINFO_QUALIFIER: " + result); return true; } HRegionInfo regionInfo = Writables.getHRegionInfo(bytes); // If region offline AND we are not to include offlined regions, return. if (regionInfo.isOffline() && !offlined) return true; regions.add(regionInfo); return true; } };
static void checkSplit(final Result r, final Put p, final byte [] which) throws IOException { byte [] hriSplitBytes = getBytes(r, which); if (!isMigrated(hriSplitBytes)) { // This will convert the HRI from 090 to 092 HRI. HRegionInfo hri = Writables.getHRegionInfo(hriSplitBytes); p.add(HConstants.CATALOG_FAMILY, which, Writables.getBytes(hri)); } }
/** * Returns all rows from the .META. table for a given user table * * @throws IOException When reading the rows fails. */ public List<byte[]> getMetaTableRows(byte[] tableName) throws IOException { // TODO: Redo using MetaReader. HTable t = new HTable(new Configuration(this.conf), HConstants.META_TABLE_NAME); List<byte[]> rows = new ArrayList<byte[]>(); ResultScanner s = t.getScanner(new Scan()); for (Result result : s) { byte[] val = result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (val == null) { LOG.error("No region info for row " + Bytes.toString(result.getRow())); // TODO figure out what to do for this new hosed case. continue; } HRegionInfo info = Writables.getHRegionInfo(val); if (Bytes.compareTo(info.getTableName(), tableName) == 0) { LOG.info("getMetaTableRows: row -> " + Bytes.toStringBinary(result.getRow()) + info); rows.add(result.getRow()); } } s.close(); t.close(); return rows; }
@Override public boolean processRowInternal(Result rowResult) throws IOException { HRegionInfo info = Writables.getHRegionInfo( rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER)); byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER); String hostAndPort = null; if (value != null && value.length > 0) { hostAndPort = Bytes.toString(value); } value = rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER); long startcode = -1L; if (value != null && value.length > 0) startcode = Bytes.toLong(value); if (!(info.isOffline() || info.isSplit())) { ServerName sn = null; if (hostAndPort != null && hostAndPort.length() > 0) { sn = new ServerName(hostAndPort, startcode); } regions.put(new UnmodifyableHRegionInfo(info), sn); } return true; } };
private HRegionInfo nextRegion() throws IOException { try { Result results = getMetaRow(); if (results == null) { return null; } byte[] regionInfoValue = results.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); if (regionInfoValue == null || regionInfoValue.length == 0) { throw new NoSuchElementException("meta region entry missing " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" + Bytes.toString(HConstants.REGIONINFO_QUALIFIER)); } HRegionInfo region = Writables.getHRegionInfo(regionInfoValue); if (!Bytes.equals(region.getTableName(), this.tableName)) { return null; } return region; } catch (IOException e) { e = RemoteExceptionHandler.checkIOException(e); LOG.error("meta scanner error", e); metaScanner.close(); throw e; } }
private void mergeTwoMetaRegions() throws IOException { HRegion rootRegion = utils.getRootRegion(); Get get = new Get(region1); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); List<KeyValue> cells1 = rootRegion.get(get, null).list(); HRegionInfo info1 = Writables.getHRegionInfo((cells1 == null)? null: cells1.get(0).getValue()); get = new Get(region2); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); List<KeyValue> cells2 = rootRegion.get(get, null).list(); HRegionInfo info2 = Writables.getHRegionInfo((cells2 == null)? null: cells2.get(0).getValue()); HRegion merged = merge(HTableDescriptor.META_TABLEDESC, info1, rootRegion, info2, rootRegion); LOG.info("Adding " + merged.getRegionInfo() + " to " + rootRegion.getRegionInfo()); HRegion.addRegionToMETA(rootRegion, merged); merged.close(); }
regionInfo = Writables.getHRegionInfo(value);
while ((result = scanner.next()) != null) { byte[] familyQualifierBytes = result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); HRegionInfo hri = Writables.getHRegionInfo(familyQualifierBytes); HTableDescriptor htd = hri.getTableDesc(); Path p = HTableDescriptor.getTableDir(hbaseRootDir, htd.getName());
throw new IOException("no information for row " + Bytes.toString(row)); HRegionInfo info = Writables.getHRegionInfo(value); Put put = new Put(row); info.setOffline(onlineOffline);
+ Bytes.toString(row)); HRegionInfo regionInfo = Writables.getHRegionInfo(value); TRegionInfo region = new TRegionInfo(); region.setStartKey(regionInfo.getStartKey());
Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow)); HRegionInfo regionInfo = Writables.getHRegionInfo(value);
List<KeyValue> cells1 = metaRegion1.get(get, null).list(); HRegionInfo info1 = Writables.getHRegionInfo((cells1 == null)? null: cells1.get(0).getValue()); if (info1 == null) { throw new NullPointerException("info1 is null using key " + get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); List<KeyValue> cells2 = metaRegion2.get(get, null).list(); HRegionInfo info2 = Writables.getHRegionInfo((cells2 == null)? null: cells2.get(0).getValue()); if (info2 == null) { throw new NullPointerException("info2 is null using key " + meta2);