Ejemplo n.º 1
0
    @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()));
      }
    }
Ejemplo n.º 2
0
    @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()));
      }
    }
Ejemplo n.º 3
0
 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;
   }
 }
Ejemplo n.º 4
0
    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);
        }
      }
    }
Ejemplo n.º 5
0
 @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);
 }
Ejemplo n.º 6
0
 public PType<Double> doubles() {
   return Writables.doubles();
 }
Ejemplo n.º 7
0
 public <V1, V2> PType<Pair<V1, V2>> pairs(PType<V1> p1, PType<V2> p2) {
   return Writables.pairs(p1, p2);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 public <W extends Writable> PType<W> writables(Class<W> clazz) {
   return Writables.writables(clazz);
 }
Ejemplo n.º 10
0
 public <T> PType<T> records(Class<T> clazz) {
   return Writables.records(clazz);
 }
Ejemplo n.º 11
0
 public PType<ByteBuffer> bytes() {
   return Writables.bytes();
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
 public PType<Float> floats() {
   return Writables.floats();
 }
Ejemplo n.º 14
0
 public PType<Integer> ints() {
   return Writables.ints();
 }
Ejemplo n.º 15
0
 public PType<Long> longs() {
   return Writables.longs();
 }
Ejemplo n.º 16
0
 public PType<String> strings() {
   return Writables.strings();
 }
Ejemplo n.º 17
0
 public <T> PType<Collection<T>> collections(PType<T> ptype) {
   return Writables.collections(ptype);
 }
Ejemplo n.º 18
0
 public PType<TupleN> tuples(PType... ptypes) {
   return Writables.tuples(ptypes);
 }
Ejemplo n.º 19
0
 public PType<Boolean> booleans() {
   return Writables.booleans();
 }
Ejemplo n.º 20
0
 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);
 }