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


Java HRegionInfo.getEncodedNameAsBytes方法代碼示例

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


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

示例1: writeMarker

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private static long writeMarker(final WAL wal, final HTableDescriptor htd, final HRegionInfo hri,
    final WALEdit edit, final MultiVersionConcurrencyControl mvcc, final boolean sync)
throws IOException {
  // TODO: Pass in current time to use?
  WALKey key =
    new HLogKey(hri.getEncodedNameAsBytes(), hri.getTable(), System.currentTimeMillis(), mvcc);
  // Add it to the log but the false specifies that we don't need to add it to the memstore
  long trx = MultiVersionConcurrencyControl.NONE;
  try {
    trx = wal.append(htd, hri, key, edit, false);
    if (sync) wal.sync(trx);
  } finally {
    // If you get hung here, is it a real WAL or a mocked WAL? If the latter, you need to
    // trip the latch that is inside in getWriteEntry up in your mock. See down in the append
    // called from onEvent in FSHLog.
    MultiVersionConcurrencyControl.WriteEntry we = key.getWriteEntry();
    if (mvcc != null && we != null) mvcc.complete(we);
  }
  return trx;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:WALUtil.java

示例2: addEdits

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
protected void addEdits(WAL log,
                        HRegionInfo hri,
                        HTableDescriptor htd,
                        int times,
                        MultiVersionConcurrencyControl mvcc)
    throws IOException {
  final byte[] row = Bytes.toBytes("row");
  for (int i = 0; i < times; i++) {
    long timestamp = System.currentTimeMillis();
    WALEdit cols = new WALEdit();
    cols.add(new KeyValue(row, row, row, timestamp, row));
    WALKey key = new WALKey(hri.getEncodedNameAsBytes(), htd.getTableName(),
        WALKey.NO_SEQUENCE_ID, timestamp, WALKey.EMPTY_UUIDS, HConstants.NO_NONCE,
        HConstants.NO_NONCE, mvcc);
    log.append(htd, hri, key, cols, true);
  }
  log.sync();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestFSHLog.java

示例3: RegionReplicaReplayCallable

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public RegionReplicaReplayCallable(ClusterConnection connection,
    RpcControllerFactory rpcControllerFactory, TableName tableName,
    HRegionLocation location, HRegionInfo regionInfo, byte[] row,List<Entry> entries,
    AtomicLong skippedEntries) {
  super(connection, rpcControllerFactory, location, tableName, row, regionInfo.getReplicaId());
  this.entries = entries;
  this.skippedEntries = skippedEntries;
  this.initialEncodedRegionName = regionInfo.getEncodedNameAsBytes();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:RegionReplicaReplicationEndpoint.java

示例4: getLog

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * @return the WAL associated with the given region
 * @throws IOException e
 */
public synchronized WAL getLog(HRegionInfo info) throws IOException {
  if (this.walFactory == null) {
    String logName = 
        HConstants.HREGION_LOGDIR_NAME + "_" + System.currentTimeMillis();
    final Configuration walConf = new Configuration(this.conf);
    FSUtils.setRootDir(walConf, fs.getHomeDirectory());
    this.walFactory = new WALFactory(walConf, null, logName);
  }
  final byte[] region = info.getEncodedNameAsBytes();
  return info.isMetaRegion() ? walFactory.getMetaWAL(region) : walFactory.getWAL(region);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:16,代碼來源:MetaUtils.java

示例5: toRegionEventDescriptor

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public static RegionEventDescriptor toRegionEventDescriptor(
    EventType eventType, HRegionInfo hri, long seqId, ServerName server,
    Map<byte[], List<Path>> storeFiles) {
  final byte[] tableNameAsBytes = hri.getTable().getName();
  final byte[] encodedNameAsBytes = hri.getEncodedNameAsBytes();
  final byte[] regionNameAsBytes = hri.getRegionName();
  return toRegionEventDescriptor(eventType,
      tableNameAsBytes,
      encodedNameAsBytes,
      regionNameAsBytes,
      seqId,

      server,
      storeFiles);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:16,代碼來源:ProtobufUtil.java

示例6: isRegionStillOpening

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private boolean isRegionStillOpening(HRegionInfo regionInfo, RegionServerServices rsServices) {
  byte[] encodedName = regionInfo.getEncodedNameAsBytes();
  Boolean action = rsServices.getRegionsInTransitionInRS().get(encodedName);
  return Boolean.TRUE.equals(action); // true means opening for RIT
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:6,代碼來源:ZkOpenRegionCoordination.java

示例7: isRegionStillOpening

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private static boolean isRegionStillOpening(
    HRegionInfo regionInfo, RegionServerServices rsServices) {
  byte[] encodedName = regionInfo.getEncodedNameAsBytes();
  Boolean action = rsServices.getRegionsInTransitionInRS().get(encodedName);
  return Boolean.TRUE.equals(action); // true means opening for RIT
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:7,代碼來源:OpenRegionHandler.java

示例8: warmupRegion

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 *  Wamrmup a region on this server.
 *
 * This method should only be called by Master. It synchrnously opens the region and
 * closes the region bringing the most important pages in cache.
 * <p>
 *
 * @param controller the RPC controller
 * @param request the request
 * @throws ServiceException
 */
@Override
public WarmupRegionResponse warmupRegion(final RpcController controller,
    final WarmupRegionRequest request) throws ServiceException {

  RegionInfo regionInfo = request.getRegionInfo();
  final HRegionInfo region = HRegionInfo.convert(regionInfo);
  HTableDescriptor htd;
  WarmupRegionResponse response = WarmupRegionResponse.getDefaultInstance();

  try {
    checkOpen();
    String encodedName = region.getEncodedName();
    byte[] encodedNameBytes = region.getEncodedNameAsBytes();
    final Region onlineRegion = regionServer.getFromOnlineRegions(encodedName);

    if (onlineRegion != null) {
      LOG.info("Region already online. Skipping warming up " + region);
      return response;
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("Warming up Region " + region.getRegionNameAsString());
    }

    htd = regionServer.tableDescriptors.get(region.getTable());

    if (regionServer.getRegionsInTransitionInRS().containsKey(encodedNameBytes)) {
      LOG.info("Region is in transition. Skipping warmup " + region);
      return response;
    }

    HRegion.warmupHRegion(region, htd, regionServer.getWAL(region),
        regionServer.getConfiguration(), regionServer, null);

  } catch (IOException ie) {
    LOG.error("Failed warming up region " + region.getRegionNameAsString(), ie);
    throw new ServiceException(ie);
  }

  return response;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:53,代碼來源:RSRpcServices.java

示例9: testNonLegacyWALKeysDoNotExplode

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testNonLegacyWALKeysDoNotExplode() throws Exception {
  TableName tableName = TableName.valueOf(TEST_TABLE);
  final HTableDescriptor htd = createBasic3FamilyHTD(Bytes
      .toString(TEST_TABLE));
  final HRegionInfo hri = new HRegionInfo(tableName, null, null);
  MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();

  fs.mkdirs(new Path(FSUtils.getTableDir(hbaseRootDir, tableName), hri.getEncodedName()));

  final Configuration newConf = HBaseConfiguration.create(this.conf);

  final WAL wal = wals.getWAL(UNSPECIFIED_REGION);
  final SampleRegionWALObserver newApi = getCoprocessor(wal, SampleRegionWALObserver.class);
  newApi.setTestValues(TEST_TABLE, TEST_ROW, null, null, null, null, null, null);
  final SampleRegionWALObserver oldApi = getCoprocessor(wal,
      SampleRegionWALObserver.Legacy.class);
  oldApi.setTestValues(TEST_TABLE, TEST_ROW, null, null, null, null, null, null);

  LOG.debug("ensuring wal entries haven't happened before we start");
  assertFalse(newApi.isPreWALWriteCalled());
  assertFalse(newApi.isPostWALWriteCalled());
  assertFalse(newApi.isPreWALWriteDeprecatedCalled());
  assertFalse(newApi.isPostWALWriteDeprecatedCalled());
  assertFalse(oldApi.isPreWALWriteCalled());
  assertFalse(oldApi.isPostWALWriteCalled());
  assertFalse(oldApi.isPreWALWriteDeprecatedCalled());
  assertFalse(oldApi.isPostWALWriteDeprecatedCalled());

  LOG.debug("writing to WAL with non-legacy keys.");
  final int countPerFamily = 5;
  for (HColumnDescriptor hcd : htd.getFamilies()) {
    addWALEdits(tableName, hri, TEST_ROW, hcd.getName(), countPerFamily,
        EnvironmentEdgeManager.getDelegate(), wal, htd, mvcc);
  }

  LOG.debug("Verify that only the non-legacy CP saw edits.");
  assertTrue(newApi.isPreWALWriteCalled());
  assertTrue(newApi.isPostWALWriteCalled());
  assertFalse(newApi.isPreWALWriteDeprecatedCalled());
  assertFalse(newApi.isPostWALWriteDeprecatedCalled());
  // wish we could test that the log message happened :/
  assertFalse(oldApi.isPreWALWriteCalled());
  assertFalse(oldApi.isPostWALWriteCalled());
  assertFalse(oldApi.isPreWALWriteDeprecatedCalled());
  assertFalse(oldApi.isPostWALWriteDeprecatedCalled());

  LOG.debug("reseting cp state.");
  newApi.setTestValues(TEST_TABLE, TEST_ROW, null, null, null, null, null, null);
  oldApi.setTestValues(TEST_TABLE, TEST_ROW, null, null, null, null, null, null);

  LOG.debug("write a log edit that supports legacy cps.");
  final long now = EnvironmentEdgeManager.currentTime();
  final WALKey legacyKey = new HLogKey(hri.getEncodedNameAsBytes(), hri.getTable(), now);
  final WALEdit edit = new WALEdit();
  final byte[] nonce = Bytes.toBytes("1772");
  edit.add(new KeyValue(TEST_ROW, TEST_FAMILY[0], nonce, now, nonce));
  final long txid = wal.append(htd, hri, legacyKey, edit, true);
  wal.sync(txid);

  LOG.debug("Make sure legacy cps can see supported edits after having been skipped.");
  assertTrue("non-legacy WALObserver didn't see pre-write.", newApi.isPreWALWriteCalled());
  assertTrue("non-legacy WALObserver didn't see post-write.", newApi.isPostWALWriteCalled());
  assertFalse("non-legacy WALObserver shouldn't have seen legacy pre-write.",
      newApi.isPreWALWriteDeprecatedCalled());
  assertFalse("non-legacy WALObserver shouldn't have seen legacy post-write.",
      newApi.isPostWALWriteDeprecatedCalled());
  assertTrue("legacy WALObserver didn't see pre-write.", oldApi.isPreWALWriteCalled());
  assertTrue("legacy WALObserver didn't see post-write.", oldApi.isPostWALWriteCalled());
  assertTrue("legacy WALObserver didn't see legacy pre-write.",
      oldApi.isPreWALWriteDeprecatedCalled());
  assertTrue("legacy WALObserver didn't see legacy post-write.",
      oldApi.isPostWALWriteDeprecatedCalled());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:75,代碼來源:TestWALObserver.java

示例10: testFlushSequenceIdIsGreaterThanAllEditsInHFile

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Test flush for sure has a sequence id that is beyond the last edit appended.  We do this
 * by slowing appends in the background ring buffer thread while in foreground we call
 * flush.  The addition of the sync over HRegion in flush should fix an issue where flush was
 * returning before all of its appends had made it out to the WAL (HBASE-11109).
 * @throws IOException
 * @see HBASE-11109
 */
@Test
public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException {
  String testName = "testFlushSequenceIdIsGreaterThanAllEditsInHFile";
  final TableName tableName = TableName.valueOf(testName);
  final HRegionInfo hri = new HRegionInfo(tableName);
  final byte[] rowName = tableName.getName();
  final HTableDescriptor htd = new HTableDescriptor(tableName);
  htd.addFamily(new HColumnDescriptor("f"));
  HRegion r = HRegion.createHRegion(hri, TEST_UTIL.getDefaultRootDirPath(),
    TEST_UTIL.getConfiguration(), htd);
  HRegion.closeHRegion(r);
  final int countPerFamily = 10;
  final MutableBoolean goslow = new MutableBoolean(false);
  // subclass and doctor a method.
  FSHLog wal = new FSHLog(FileSystem.get(conf), TEST_UTIL.getDefaultRootDirPath(),
      testName, conf) {
    @Override
    void atHeadOfRingBufferEventHandlerAppend() {
      if (goslow.isTrue()) {
        Threads.sleep(100);
        LOG.debug("Sleeping before appending 100ms");
      }
      super.atHeadOfRingBufferEventHandlerAppend();
    }
  };
  HRegion region = HRegion.openHRegion(TEST_UTIL.getConfiguration(),
    TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath(), hri, htd, wal);
  EnvironmentEdge ee = EnvironmentEdgeManager.getDelegate();
  try {
    List<Put> puts = null;
    for (HColumnDescriptor hcd: htd.getFamilies()) {
      puts =
        TestWALReplay.addRegionEdits(rowName, hcd.getName(), countPerFamily, ee, region, "x");
    }

    // Now assert edits made it in.
    final Get g = new Get(rowName);
    Result result = region.get(g);
    assertEquals(countPerFamily * htd.getFamilies().size(), result.size());

    // Construct a WALEdit and add it a few times to the WAL.
    WALEdit edits = new WALEdit();
    for (Put p: puts) {
      CellScanner cs = p.cellScanner();
      while (cs.advance()) {
        edits.add(cs.current());
      }
    }
    // Add any old cluster id.
    List<UUID> clusterIds = new ArrayList<UUID>();
    clusterIds.add(UUID.randomUUID());
    // Now make appends run slow.
    goslow.setValue(true);
    for (int i = 0; i < countPerFamily; i++) {
      final HRegionInfo info = region.getRegionInfo();
      final WALKey logkey = new WALKey(info.getEncodedNameAsBytes(), tableName,
          System.currentTimeMillis(), clusterIds, -1, -1, region.getMVCC());
      wal.append(htd, info, logkey, edits, true);
    }
    region.flush(true);
    // FlushResult.flushSequenceId is not visible here so go get the current sequence id.
    long currentSequenceId = region.getSequenceId();
    // Now release the appends
    goslow.setValue(false);
    synchronized (goslow) {
      goslow.notifyAll();
    }
    assertTrue(currentSequenceId >= region.getSequenceId());
  } finally {
    region.close(true);
    wal.close();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:82,代碼來源:TestFSHLog.java


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