當前位置: 首頁>>代碼示例>>Java>>正文


Java HRegionInfo.encodeRegionName方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.encodeRegionName方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.encodeRegionName方法的具體用法?Java HRegionInfo.encodeRegionName怎麽用?Java HRegionInfo.encodeRegionName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HRegionInfo的用法示例。


在下文中一共展示了HRegionInfo.encodeRegionName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRegionInfo

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Get the HRegionInfo from cache, if not there, from the hbase:meta table
 * @param  regionName
 * @return HRegionInfo for the region
 */
@SuppressWarnings("deprecation")
protected HRegionInfo getRegionInfo(final byte [] regionName) {
  String encodedName = HRegionInfo.encodeRegionName(regionName);
  RegionState regionState = getRegionState(encodedName);
  if (regionState != null) {
    return regionState.getRegion();
  }

  try {
    Pair<HRegionInfo, ServerName> p =
      MetaTableAccessor.getRegion(server.getConnection(), regionName);
    HRegionInfo hri = p == null ? null : p.getFirst();
    if (hri != null) {
      createRegionState(hri);
    }
    return hri;
  } catch (IOException e) {
    server.abort("Aborting because error occoured while reading "
      + Bytes.toStringBinary(regionName) + " from hbase:meta", e);
    return null;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:RegionStates.java

示例2: handleHBCK

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Handle a ZK unassigned node transition triggered by HBCK repair tool.
 * <p>
 * This is handled in a separate code path because it breaks the normal rules.
 * @param rt
 */
@SuppressWarnings("deprecation")
private void handleHBCK(RegionTransition rt) {
  String encodedName = HRegionInfo.encodeRegionName(rt.getRegionName());
  LOG.info("Handling HBCK triggered transition=" + rt.getEventType() +
    ", server=" + rt.getServerName() + ", region=" +
    HRegionInfo.prettyPrint(encodedName));
  RegionState regionState = regionStates.getRegionTransitionState(encodedName);
  switch (rt.getEventType()) {
    case M_ZK_REGION_OFFLINE:
      HRegionInfo regionInfo;
      if (regionState != null) {
        regionInfo = regionState.getRegion();
      } else {
        try {
          byte [] name = rt.getRegionName();
          Pair<HRegionInfo, ServerName> p = MetaTableAccessor.getRegion(
            this.server.getConnection(), name);
          regionInfo = p.getFirst();
        } catch (IOException e) {
          LOG.info("Exception reading hbase:meta doing HBCK repair operation", e);
          return;
        }
      }
      LOG.info("HBCK repair is triggering assignment of region=" +
          regionInfo.getRegionNameAsString());
      // trigger assign, node is already in OFFLINE so don't need to update ZK
      assign(regionInfo, false);
      break;

    default:
      LOG.warn("Received unexpected region state from HBCK: " + rt.toString());
      break;
  }

}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:42,代碼來源:AssignmentManager.java

示例3: getRegionNameFromManifest

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Extract the region encoded name from the region manifest
 */
static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) {
  byte[] regionName = HRegionInfo.createRegionName(
          ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()),
          manifest.getRegionInfo().getStartKey().toByteArray(),
          manifest.getRegionInfo().getRegionId(), true);
  return HRegionInfo.encodeRegionName(regionName);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:11,代碼來源:SnapshotManifest.java

示例4: unbalanceRegions

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
protected void unbalanceRegions(ClusterStatus clusterStatus,
    List<ServerName> fromServers, List<ServerName> toServers,
    double fractionOfRegions) throws Exception {
  List<byte[]> victimRegions = new LinkedList<byte[]>();
  for (ServerName server : fromServers) {
    ServerLoad serverLoad = clusterStatus.getLoad(server);
    // Ugh.
    List<byte[]> regions = new LinkedList<byte[]>(serverLoad.getRegionsLoad().keySet());
    int victimRegionCount = (int)Math.ceil(fractionOfRegions * regions.size());
    LOG.debug("Removing " + victimRegionCount + " regions from " + server.getServerName());
    for (int i = 0; i < victimRegionCount; ++i) {
      int victimIx = RandomUtils.nextInt(regions.size());
      String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx));
      victimRegions.add(Bytes.toBytes(regionId));
    }
  }

  LOG.info("Moving " + victimRegions.size() + " regions from " + fromServers.size()
      + " servers to " + toServers.size() + " different servers");
  Admin admin = this.context.getHBaseIntegrationTestingUtility().getHBaseAdmin();
  for (byte[] victimRegion : victimRegions) {
    // Don't keep moving regions if we're
    // trying to stop the monkey.
    if (context.isStopping()) {
      break;
    }
    int targetIx = RandomUtils.nextInt(toServers.size());
    admin.move(victimRegion, Bytes.toBytes(toServers.get(targetIx).getServerName()));
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:Action.java

示例5: getRegionEncodedName

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Find the HRegion encoded name based on a region specifier
 *
 * @param regionSpecifier the region specifier
 * @return the corresponding region's encoded name
 * @throws DoNotRetryIOException if the specifier type is unsupported
 */
public static String getRegionEncodedName(
    final RegionSpecifier regionSpecifier) throws DoNotRetryIOException {
  byte[] value = regionSpecifier.getValue().toByteArray();
  RegionSpecifierType type = regionSpecifier.getType();
  switch (type) {
    case REGION_NAME:
      return HRegionInfo.encodeRegionName(value);
    case ENCODED_REGION_NAME:
      return Bytes.toString(value);
    default:
      throw new DoNotRetryIOException(
        "Unsupported region specifier type: " + type);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:ProtobufUtil.java

示例6: parseOptions

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public boolean parseOptions(String args[]) throws ParseException,
    IOException {
  if (args.length == 0) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("HFile", options, true);
    return false;
  }
  CommandLineParser parser = new PosixParser();
  CommandLine cmd = parser.parse(options, args);

  verbose = cmd.hasOption("v");
  printValue = cmd.hasOption("p");
  printKey = cmd.hasOption("e") || printValue;
  shouldPrintMeta = cmd.hasOption("m");
  printBlockIndex = cmd.hasOption("b");
  printBlockHeaders = cmd.hasOption("h");
  printStats = cmd.hasOption("s");
  checkRow = cmd.hasOption("k");
  checkFamily = cmd.hasOption("a");

  if (cmd.hasOption("f")) {
    files.add(new Path(cmd.getOptionValue("f")));
  }

  if (cmd.hasOption("w")) {
    String key = cmd.getOptionValue("w");
    if (key != null && key.length() != 0) {
      row = Bytes.toBytesBinary(key);
      isSeekToRow = true;
    } else {
      System.err.println("Invalid row is specified.");
      System.exit(-1);
    }
  }

  if (cmd.hasOption("r")) {
    String regionName = cmd.getOptionValue("r");
    byte[] rn = Bytes.toBytes(regionName);
    byte[][] hri = HRegionInfo.parseRegionName(rn);
    Path rootDir = FSUtils.getRootDir(getConf());
    Path tableDir = FSUtils.getTableDir(rootDir, TableName.valueOf(hri[0]));
    String enc = HRegionInfo.encodeRegionName(rn);
    Path regionDir = new Path(tableDir, enc);
    if (verbose)
      System.out.println("region dir -> " + regionDir);
    List<Path> regionFiles = HFile.getStoreFiles(FileSystem.get(getConf()),
        regionDir);
    if (verbose)
      System.out.println("Number of region files found -> "
          + regionFiles.size());
    if (verbose) {
      int i = 1;
      for (Path p : regionFiles) {
        if (verbose)
          System.out.println("Found file[" + i++ + "] -> " + p);
      }
    }
    files.addAll(regionFiles);
  }

  return true;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:63,代碼來源:HFilePrettyPrinter.java

示例7: getOnlineRegion

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * @param regionName
 * @return HRegion for the passed binary <code>regionName</code> or null if
 * named region is not member of the online regions.
 */
public Region getOnlineRegion(final byte[] regionName) {
  String encodedRegionName = HRegionInfo.encodeRegionName(regionName);
  return this.onlineRegions.get(encodedRegionName);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:HRegionServer.java

示例8: getRegion

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Protected utility method for safely obtaining an HRegion handle.
 *
 * @param regionName Name of online {@link Region} to return
 * @return {@link Region} for <code>regionName</code>
 * @throws NotServingRegionException
 */
protected Region getRegion(final byte[] regionName) throws NotServingRegionException {
  String encodedRegionName = HRegionInfo.encodeRegionName(regionName);
  return getRegionByEncodedName(regionName, encodedRegionName);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:HRegionServer.java


注:本文中的org.apache.hadoop.hbase.HRegionInfo.encodeRegionName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。