当前位置: 首页>>代码示例>>Java>>正文


Java Writables.getHRegionInfoOrNull方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.util.Writables.getHRegionInfoOrNull方法的典型用法代码示例。如果您正苦于以下问题:Java Writables.getHRegionInfoOrNull方法的具体用法?Java Writables.getHRegionInfoOrNull怎么用?Java Writables.getHRegionInfoOrNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.util.Writables的用法示例。


在下文中一共展示了Writables.getHRegionInfoOrNull方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isTableAvailable

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
public boolean isTableAvailable(final byte[] tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      byte[] value = row.getValue(HConstants.CATALOG_FAMILY,
          HConstants.REGIONINFO_QUALIFIER);
      HRegionInfo info = Writables.getHRegionInfoOrNull(value);
      if (info != null && !info.isSplitParent()) {
        if (Bytes.equals(tableName, info.getTableName())) {
          value = row.getValue(HConstants.CATALOG_FAMILY,
              HConstants.SERVER_QUALIFIER);
          if (value == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, this, visitor, null);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:HConnectionManager.java

示例2: isTableAvailable

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
public boolean isTableAvailable(final byte[] tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitor() {
    @Override
    public boolean processRow(Result row) throws IOException {
      byte[] value = row.getValue(HConstants.CATALOG_FAMILY,
          HConstants.REGIONINFO_QUALIFIER);
      HRegionInfo info = Writables.getHRegionInfoOrNull(value);
      if (info != null) {
        if (Bytes.equals(tableName, info.getTableName())) {
          value = row.getValue(HConstants.CATALOG_FAMILY,
              HConstants.SERVER_QUALIFIER);
          if (value == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, visitor);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:27,代码来源:HConnectionManager.java

示例3: getDaughterRegions

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Returns the daughter regions by reading the corresponding columns of the catalog table
 * Result.
 * @param data a Result object from the catalog table scan
 * @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split
 * parent
 */
public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException {
  HRegionInfo splitA = Writables.getHRegionInfoOrNull(data.getValue(HConstants.CATALOG_FAMILY,
    HConstants.SPLITA_QUALIFIER));
  HRegionInfo splitB = Writables.getHRegionInfoOrNull(data.getValue(HConstants.CATALOG_FAMILY,
    HConstants.SPLITB_QUALIFIER));
  return new PairOfSameType<HRegionInfo>(splitA, splitB);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:15,代码来源:MetaReader.java

示例4: getDaughterRegions

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Returns the daughter regions by reading from the corresponding columns of the .META. table
 * Result. If the region is not a split parent region, it returns PairOfSameType(null, null).
 */
public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException {
  HRegionInfo splitA = Writables.getHRegionInfoOrNull(
      data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER));
  HRegionInfo splitB = Writables.getHRegionInfoOrNull(
      data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER));
  return new PairOfSameType<HRegionInfo>(splitA, splitB);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:12,代码来源:MetaEditor.java

示例5: getRegionResultBlocking

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Returns region Result by querying the META table for regionName. It will block until
 * the region is found in META. It will also check for parent in META to make sure that
 * if parent is deleted, we no longer have to wait, and should continue (HBASE-8590)
 * @return Result object is daughter is found, or null if parent is gone from META
 * @throws TimeoutException if timeout is reached
 */
private Result getRegionResultBlocking(HTable metaTable, long timeout, byte[] parentRegionName, byte[] regionName)
    throws IOException, TimeoutException {
  boolean logged = false;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    Get get = new Get(regionName);
    Result result = metaTable.get(get);
    HRegionInfo info = Writables.getHRegionInfoOrNull(
        result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER));
    if (info != null) {
      return result;
    }

    // check whether parent is still there, if not it means we do not need to wait
    Get parentGet = new Get(parentRegionName);
    Result parentResult = metaTable.get(parentGet);
    HRegionInfo parentInfo = Writables.getHRegionInfoOrNull(
        parentResult.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER));
    if (parentInfo == null) {
      // this means that parent is no more (catalog janitor or somebody else deleted it)
      return null;
    }

    try {
      if (!logged) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("blocking until region is in META: " + Bytes.toStringBinary(regionName));
        }
        logged = true;
      }
      Thread.sleep(10);
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
      break;
    }
  }
  throw new TimeoutException("getRegionResultBlocking", start, System.currentTimeMillis(),
    timeout);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:47,代码来源:MetaScanner.java

示例6: processRow

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
@Override
public final boolean processRow(Result rowResult) throws IOException {
  HRegionInfo info = Writables.getHRegionInfoOrNull(
      rowResult.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER));
  if (info == null) {
    return true;
  }
  if (!(Bytes.equals(info.getTableName(), tableName))) {
    return false;
  }
  return super.processRow(rowResult);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:13,代码来源:MetaScanner.java

示例7: waitUntilAllRegionsAssigned

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Wait until all regions for a table in .META. have a non-empty
 * info:server, or until timeout.  This means all regions have been
 * deployed, master has been informed and updated .META. with the regions
 * deployed server.
 * @param tableName the table name
 * @param timeout timeout, in milliseconds
 * @throws IOException
 */
public void waitUntilAllRegionsAssigned(final byte[] tableName, final long timeout)
    throws IOException {
  long deadline = System.currentTimeMillis() + timeout;
  HTable meta = new HTable(getConfiguration(), HConstants.META_TABLE_NAME);
  try {
    while (true) {
      boolean allRegionsAssigned = true;
      Scan scan = new Scan();
      scan.addFamily(HConstants.CATALOG_FAMILY);
      ResultScanner s = meta.getScanner(scan);
      try {
        Result r;
        while ((r = s.next()) != null) {
          byte [] b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
          HRegionInfo info = Writables.getHRegionInfoOrNull(b);
          if (info != null && Bytes.equals(info.getTableName(), tableName)) {
            b = r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
            allRegionsAssigned &= (b != null);
          }
        }
      } finally {
        s.close();
      }
      if (allRegionsAssigned) {
        return;
      }
      long now = System.currentTimeMillis();
      if (now > deadline) {
        throw new IOException("Timeout waiting for all regions of " +
          Bytes.toStringBinary(tableName) + " to be assigned");
      }
      try {
        Thread.sleep(deadline - now < 200 ? deadline - now : 200);
      } catch (InterruptedException e) {
        throw new IOException(e);
      }
    }
  } finally {
    meta.close();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:51,代码来源:HBaseTestingUtility.java

示例8: createTable

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Creates a new table with an initial set of empty regions defined by the
 * specified split keys.  The total number of regions created will be the
 * number of split keys plus one. Synchronous operation.
 *
 * @param desc table descriptor for table
 * @param splitKeys array of split keys for the initial regions of the table
 *
 * @throws IllegalArgumentException if the table name is reserved
 * @throws MasterNotRunningException if master is not running
 * @throws TableExistsException if table already exists (If concurrent
 * threads, the table may have been created between test-for-existence
 * and attempt-at-creation).
 * @throws IOException
 */
public void createTable(final HTableDescriptor desc, byte [][] splitKeys)
throws IOException {
  HTableDescriptor.isLegalTableName(desc.getName());
  try {
    createTableAsync(desc, splitKeys);
  } catch (SocketTimeoutException ste) {
    LOG.warn("Creating " + desc.getNameAsString() + " took too long", ste);
  }
  int numRegs = splitKeys == null ? 1 : splitKeys.length + 1;
  int prevRegCount = 0;
  for (int tries = 0; tries < this.numRetries * this.retryLongerMultiplier;
    ++tries) {
    // Wait for new table to come on-line
    final AtomicInteger actualRegCount = new AtomicInteger(0);
    MetaScannerVisitor visitor = new MetaScannerVisitor() {
      @Override
      public boolean processRow(Result rowResult) throws IOException {
        HRegionInfo info = Writables.getHRegionInfoOrNull(
            rowResult.getValue(HConstants.CATALOG_FAMILY,
                HConstants.REGIONINFO_QUALIFIER));
        //If regioninfo is null, skip this row
        if (null == info) {
          return true;
        }
        if (!(Bytes.equals(info.getTableName(), desc.getName()))) {
          return false;
        }
        String hostAndPort = null;
        byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
            HConstants.SERVER_QUALIFIER);
        // Make sure that regions are assigned to server
        if (value != null && value.length > 0) {
          hostAndPort = Bytes.toString(value);
        }
        if (!(info.isOffline() || info.isSplit()) && hostAndPort != null) {
          actualRegCount.incrementAndGet();
        }
        return true;
      }
    };
    MetaScanner.metaScan(conf, visitor, desc.getName());
    if (actualRegCount.get() != numRegs) {
      if (tries == this.numRetries * this.retryLongerMultiplier - 1) {
        throw new RegionOfflineException("Only " + actualRegCount.get() +
          " of " + numRegs + " regions are online; retries exhausted.");
      }
      try { // Sleep
        Thread.sleep(getPauseTime(tries));
      } catch (InterruptedException e) {
        throw new InterruptedIOException("Interrupted when opening" +
            " regions; " + actualRegCount.get() + " of " + numRegs + 
            " regions processed so far");
      }
      if (actualRegCount.get() > prevRegCount) { // Making progress
        prevRegCount = actualRegCount.get();
        tries = -1;
      }
    } else {
      return;
    }
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:78,代码来源:HBaseAdmin.java

示例9: parseHRegionInfoFromCatalogResult

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Parse the content of the cell at {@link HConstants#CATALOG_FAMILY} and
 * <code>qualifier</code> as an HRegionInfo and return it, or null.
 * For use on catalog table {@link Result}.
 * @param r Result instance to pull from.
 * @param qualifier Column family qualifier -- either
 * {@link HConstants#SPLITA_QUALIFIER}, {@link HConstants#SPLITB_QUALIFIER} or
 * {@link HConstants#REGIONINFO_QUALIFIER}.
 * @return An HRegionInfo instance or null.
 * @throws IOException
 */
public static HRegionInfo parseHRegionInfoFromCatalogResult(final Result r,
    byte [] qualifier)
throws IOException {
  byte [] bytes = r.getValue(HConstants.CATALOG_FAMILY, qualifier);
  if (bytes == null || bytes.length <= 0) return null;
  return Writables.getHRegionInfoOrNull(bytes);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:MetaReader.java

示例10: getDaughterRegionInfo

import org.apache.hadoop.hbase.util.Writables; //导入方法依赖的package包/类
/**
 * Get daughter HRegionInfo out of parent info:splitA/info:splitB columns.
 * @param result
 * @param which Whether "info:splitA" or "info:splitB" column
 * @return Deserialized content of the info:splitA or info:splitB as a
 * HRegionInfo
 * @throws IOException
 */
private HRegionInfo getDaughterRegionInfo(final Result result,
  final byte [] which)
throws IOException {
  byte [] bytes = result.getValue(HConstants.CATALOG_FAMILY, which);
  return Writables.getHRegionInfoOrNull(bytes);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:15,代码来源:CatalogJanitor.java


注:本文中的org.apache.hadoop.hbase.util.Writables.getHRegionInfoOrNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。