当前位置: 首页>>代码示例>>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;未经允许,请勿转载。