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


Java ServerName.parseFrom方法代碼示例

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


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

示例1: testZookeeperNodesForReplicas

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
@Test
public void testZookeeperNodesForReplicas() throws Exception {
  // Checks all the znodes exist when meta's replicas are enabled
  ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
  Configuration conf = TEST_UTIL.getConfiguration();
  String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
      HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
  String primaryMetaZnode = ZKUtil.joinZNode(baseZNode,
      conf.get("zookeeper.znode.metaserver", "meta-region-server"));
  // check that the data in the znode is parseable (this would also mean the znode exists)
  byte[] data = ZKUtil.getData(zkw, primaryMetaZnode);
  ServerName.parseFrom(data);
  for (int i = 1; i < 3; i++) {
    String secZnode = ZKUtil.joinZNode(baseZNode,
        conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
    String str = zkw.getZNodeForReplica(i);
    assertTrue(str.equals(secZnode));
    // check that the data in the znode is parseable (this would also mean the znode exists)
    data = ZKUtil.getData(zkw, secZnode);
    ServerName.parseFrom(data);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:TestMetaWithReplicas.java

示例2: testMetaAddressChange

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
@Test
public void testMetaAddressChange() throws Exception {
  // checks that even when the meta's location changes, the various
  // caches update themselves. Uses the master operations to test
  // this
  Configuration conf = TEST_UTIL.getConfiguration();
  ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
  String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
      HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
  String primaryMetaZnode = ZKUtil.joinZNode(baseZNode,
      conf.get("zookeeper.znode.metaserver", "meta-region-server"));
  // check that the data in the znode is parseable (this would also mean the znode exists)
  byte[] data = ZKUtil.getData(zkw, primaryMetaZnode);
  ServerName currentServer = ServerName.parseFrom(data);
  Collection<ServerName> liveServers = TEST_UTIL.getHBaseAdmin().getClusterStatus().getServers();
  ServerName moveToServer = null;
  for (ServerName s : liveServers) {
    if (!currentServer.equals(s)) {
      moveToServer = s;
    }
  }
  assert(moveToServer != null);
  String tableName = "randomTable5678";
  TEST_UTIL.createTable(TableName.valueOf(tableName), "f");
  assertTrue(TEST_UTIL.getHBaseAdmin().tableExists(tableName));
  TEST_UTIL.getHBaseAdmin().move(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(),
      Bytes.toBytes(moveToServer.getServerName()));
  int i = 0;
  do {
    Thread.sleep(10);
    data = ZKUtil.getData(zkw, primaryMetaZnode);
    currentServer = ServerName.parseFrom(data);
    i++;
  } while (!moveToServer.equals(currentServer) && i < 1000); //wait for 10 seconds overall
  assert(i != 1000);
  TEST_UTIL.getHBaseAdmin().disableTable("randomTable5678");
  assertTrue(TEST_UTIL.getHBaseAdmin().isTableDisabled("randomTable5678"));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:TestMetaWithReplicas.java

示例3: getMasterAddress

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
/**
 * Get the address of the current master if one is available.  Returns null
 * if no current master. If refresh is set, try to load the data from ZK again,
 * otherwise, cached data will be used.
 *
 * @param refresh whether to refresh the data by calling ZK directly.
 * @return Server name or null if timed out.
 */
public ServerName getMasterAddress(final boolean refresh) {
  try {
    return ServerName.parseFrom(super.getData(refresh));
  } catch (DeserializationException e) {
    LOG.warn("Failed parse", e);
    return null;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:MasterAddressTracker.java

示例4: testHBaseFsck

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
@Test (timeout=180000)
public void testHBaseFsck() throws Exception {
  assertNoErrors(doFsck(conf, false));
  TableName table = TableName.valueOf("tableBadMetaAssign");
  HTableDescriptor desc = new HTableDescriptor(table);
  HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toString(FAM));
  desc.addFamily(hcd); // If a table has no CF's it doesn't get checked
  createTable(TEST_UTIL, desc, null);

  // We created 1 table, should be fine
  assertNoErrors(doFsck(conf, false));

  // Now let's mess it up and change the assignment in hbase:meta to
  // point to a different region server
  Table meta = connection.getTable(TableName.META_TABLE_NAME, tableExecutorService);
  Scan scan = new Scan();
  scan.setStartRow(Bytes.toBytes(table+",,"));
  ResultScanner scanner = meta.getScanner(scan);
  HRegionInfo hri = null;

  Result res = scanner.next();
  ServerName currServer =
    ServerName.parseFrom(res.getValue(HConstants.CATALOG_FAMILY,
        HConstants.SERVER_QUALIFIER));
  long startCode = Bytes.toLong(res.getValue(HConstants.CATALOG_FAMILY,
      HConstants.STARTCODE_QUALIFIER));

  for (JVMClusterUtil.RegionServerThread rs :
      TEST_UTIL.getHBaseCluster().getRegionServerThreads()) {

    ServerName sn = rs.getRegionServer().getServerName();

    // When we find a diff RS, change the assignment and break
    if (!currServer.getHostAndPort().equals(sn.getHostAndPort()) ||
        startCode != sn.getStartcode()) {
      Put put = new Put(res.getRow());
      put.setDurability(Durability.SKIP_WAL);
      put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
        Bytes.toBytes(sn.getHostAndPort()));
      put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
        Bytes.toBytes(sn.getStartcode()));
      meta.put(put);
      hri = MetaTableAccessor.getHRegionInfo(res);
      break;
    }
  }

  // Try to fix the data
  assertErrors(doFsck(conf, true), new ERROR_CODE[]{
      ERROR_CODE.SERVER_DOES_NOT_MATCH_META});

  TEST_UTIL.getHBaseCluster().getMaster()
    .getAssignmentManager().waitForAssignment(hri);

  // Should be fixed now
  assertNoErrors(doFsck(conf, false));

  // comment needed - what is the purpose of this line
  Table t = connection.getTable(table, tableExecutorService);
  ResultScanner s = t.getScanner(new Scan());
  s.close();
  t.close();

  scanner.close();
  meta.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:67,代碼來源:TestHBaseFsck.java


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