@Override protected void updateMeta(final byte[] oldRegion1, final byte[] oldRegion2, HRegion newRegion) throws IOException { byte[][] regionsToDelete = {oldRegion1, oldRegion2}; for (int r = 0; r < regionsToDelete.length; r++) { if (Bytes.equals(regionsToDelete[r], latestRegion.getRegionName())) { latestRegion = null; } Delete delete = new Delete(regionsToDelete[r]); table.delete(delete); if (LOG.isDebugEnabled()) { LOG.debug("updated columns in row: " + Bytes.toStringBinary(regionsToDelete[r])); } } newRegion.getRegionInfo().setOffline(true); Put put = new Put(newRegion.getRegionName()); put.add( HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER, Writables.getBytes(newRegion.getRegionInfo())); table.put(put); if (LOG.isDebugEnabled()) { LOG.debug("updated columns in row: " + Bytes.toStringBinary(newRegion.getRegionName())); } }
@Override protected void updateMeta(final byte[] oldRegion1, final byte[] oldRegion2, HRegion newRegion) throws IOException { byte[][] regionsToDelete = {oldRegion1, oldRegion2}; for (int r = 0; r < regionsToDelete.length; r++) { Delete delete = new Delete(regionsToDelete[r]); delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER); delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER); delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER); delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER); root.delete(delete, null, true); if (LOG.isDebugEnabled()) { LOG.debug("updated columns in row: " + Bytes.toStringBinary(regionsToDelete[r])); } } HRegionInfo newInfo = newRegion.getRegionInfo(); newInfo.setOffline(true); Put put = new Put(newRegion.getRegionName()); put.add( HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER, Writables.getBytes(newInfo)); root.put(put); if (LOG.isDebugEnabled()) { LOG.debug("updated columns in row: " + Bytes.toStringBinary(newRegion.getRegionName())); } }
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; } }
OfflineMerger(Configuration conf, FileSystem fs) throws IOException { super(conf, fs, HConstants.META_TABLE_NAME); Path rootTableDir = HTableDescriptor.getTableDir( fs.makeQualified(new Path(conf.get(HConstants.HBASE_DIR))), HConstants.ROOT_TABLE_NAME); // Scan root region to find all the meta regions root = HRegion.newHRegion( rootTableDir, hlog, fs, conf, HRegionInfo.ROOT_REGIONINFO, HTableDescriptor.ROOT_TABLEDESC, null); root.initialize(); Scan scan = new Scan(); scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); InternalScanner rootScanner = root.getScanner(scan); try { List<KeyValue> results = new ArrayList<KeyValue>(); boolean hasMore; do { hasMore = rootScanner.next(results); for (KeyValue kv : results) { HRegionInfo info = Writables.getHRegionInfoOrNull(kv.getValue()); if (info != null) { metaRegions.add(info); } } } while (hasMore); } finally { rootScanner.close(); try { root.close(); } catch (IOException e) { LOG.error(e); } } }
@Override public <T> PType<T> as(PType<T> ptype) { if (ptype instanceof WritableType || ptype instanceof WritableTableType || ptype instanceof WritableGroupedTableType) { return ptype; } if (ptype instanceof PGroupedTableType) { PTableType ptt = ((PGroupedTableType) ptype).getTableType(); return new WritableGroupedTableType((WritableTableType) as(ptt)); } PType<T> prim = Writables.getPrimitiveType(ptype.getTypeClass()); if (prim != null) { return prim; } return PTypeUtils.convert(ptype, this); }
public PType<Double> doubles() { return Writables.doubles(); }
public <V1, V2> PType<Pair<V1, V2>> pairs(PType<V1> p1, PType<V2> p2) { return Writables.pairs(p1, p2); }
public <K, V> PTableType<K, V> tableOf(PType<K> key, PType<V> value) { if (!(key instanceof WritableType) || !(value instanceof WritableType)) { throw new IllegalArgumentException("Cannot use non-WritableType in Writables.tableOf"); } return Writables.tableOf((WritableType) key, (WritableType) value); }
public <W extends Writable> PType<W> writables(Class<W> clazz) { return Writables.writables(clazz); }
public <T> PType<T> records(Class<T> clazz) { return Writables.records(clazz); }
public PType<ByteBuffer> bytes() { return Writables.bytes(); }
public <V1, V2, V3, V4> PType<Tuple4<V1, V2, V3, V4>> quads( PType<V1> p1, PType<V2> p2, PType<V3> p3, PType<V4> p4) { return Writables.quads(p1, p2, p3, p4); }
public PType<Float> floats() { return Writables.floats(); }
public PType<Integer> ints() { return Writables.ints(); }
public PType<Long> longs() { return Writables.longs(); }
public PType<String> strings() { return Writables.strings(); }
public <T> PType<Collection<T>> collections(PType<T> ptype) { return Writables.collections(ptype); }
public PType<TupleN> tuples(PType... ptypes) { return Writables.tuples(ptypes); }
public PType<Boolean> booleans() { return Writables.booleans(); }
public <V1, V2, V3> PType<Tuple3<V1, V2, V3>> triples(PType<V1> p1, PType<V2> p2, PType<V3> p3) { return Writables.triples(p1, p2, p3); }