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


Java HBaseTestingUtility.randomFreePort方法代码示例

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


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

示例1: ProcessBasedLocalHBaseCluster

import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
/**
 * Constructor. Modifies the passed configuration.
 * @param hbaseHome the top directory of the HBase source tree
 */
public ProcessBasedLocalHBaseCluster(Configuration conf,
    int numDataNodes, int numRegionServers) {
  this.conf = conf;
  this.hbaseHome = HBaseHomePath.getHomePath();
  this.numMasters = 1;
  this.numRegionServers = numRegionServers;
  this.workDir = hbaseHome + "/target/local_cluster";
  this.numDataNodes = numDataNodes;

  hbaseDaemonScript = hbaseHome + "/bin/hbase-daemon.sh";
  zkClientPort = HBaseTestingUtility.randomFreePort();

  this.rsPorts = sortedPorts(numRegionServers);
  this.masterPorts = sortedPorts(numMasters);

  conf.set(HConstants.ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
  conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ProcessBasedLocalHBaseCluster.java

示例2: runThriftServer

import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
private void runThriftServer(int customHeaderSize) throws Exception {
  List<String> args = new ArrayList<String>();
  port = HBaseTestingUtility.randomFreePort();
  args.add("-" + ThriftServer.PORT_OPTION);
  args.add(String.valueOf(port));
  args.add("start");

  thriftServer = new ThriftServer(TEST_UTIL.getConfiguration());
  startHttpServerThread(args.toArray(new String[args.size()]));

  // wait up to 10s for the server to start
  for (int i = 0; i < 100
      && ( thriftServer.serverRunner == null ||  thriftServer.serverRunner.httpServer ==
      null); i++) {
    Thread.sleep(100);
  }

  try {
    talkToThriftServer(customHeaderSize);
  } catch (Exception ex) {
    clientSideException = ex;
  } finally {
    stopHttpServerThread();
  }

  if (clientSideException != null) {
    LOG.error("Thrift client threw an exception " + clientSideException);
    if (clientSideException instanceof  TTransportException) {
      throw clientSideException;
    } else {
      throw new Exception(clientSideException);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestThriftHttpServer.java

示例3: testRunThriftServer

import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
@Test(timeout=600000)
public void testRunThriftServer() throws Exception {
  List<String> args = new ArrayList<String>();
  if (implType != null) {
    String serverTypeOption = implType.toString();
    assertTrue(serverTypeOption.startsWith("-"));
    args.add(serverTypeOption);
  }
  port = HBaseTestingUtility.randomFreePort();
  args.add("-" + ThriftServer.PORT_OPTION);
  args.add(String.valueOf(port));
  if (specifyFramed) {
    args.add("-" + ThriftServer.FRAMED_OPTION);
  }
  if (specifyBindIP) {
    args.add("-" + ThriftServer.BIND_OPTION);
    args.add(InetAddress.getLocalHost().getHostName());
  }
  if (specifyCompact) {
    args.add("-" + ThriftServer.COMPACT_OPTION);
  }
  args.add("start");

  thriftServer = new ThriftServer(TEST_UTIL.getConfiguration());
  startCmdLineThread(args.toArray(new String[args.size()]));

  // wait up to 10s for the server to start
  for (int i = 0; i < 100
      && (thriftServer.serverRunner == null || thriftServer.serverRunner.tserver == null); i++) {
    Thread.sleep(100);
  }

  Class<? extends TServer> expectedClass = implType != null ?
      implType.serverClass : TBoundedThreadPoolServer.class;
  assertEquals(expectedClass,
               thriftServer.serverRunner.tserver.getClass());

  try {
    talkToThriftServer();
  } catch (Exception ex) {
    clientSideException = ex;
  } finally {
    stopCmdLineThread();
  }

  if (clientSideException != null) {
    LOG.error("Thrift client threw an exception. Parameters:" +
        getParametersString(), clientSideException);
    throw new Exception(clientSideException);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:52,代码来源:TestThriftServerCmdLine.java

示例4: generateConfig

import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
private final String generateConfig(ServerType serverType, int rpcPort,
    String daemonDir) {
  StringBuilder sb = new StringBuilder();
  Map<String, Object> confMap = new TreeMap<String, Object>();
  confMap.put(HConstants.CLUSTER_DISTRIBUTED, true);

  if (serverType == ServerType.MASTER) {
    confMap.put(HConstants.MASTER_PORT, rpcPort);

    int masterInfoPort = HBaseTestingUtility.randomFreePort();
    reportWebUIPort("master", masterInfoPort);
    confMap.put(HConstants.MASTER_INFO_PORT, masterInfoPort);
  } else if (serverType == ServerType.RS) {
    confMap.put(HConstants.REGIONSERVER_PORT, rpcPort);

    int rsInfoPort = HBaseTestingUtility.randomFreePort();
    reportWebUIPort("region server", rsInfoPort);
    confMap.put(HConstants.REGIONSERVER_INFO_PORT, rsInfoPort);
  } else {
    confMap.put(HConstants.ZOOKEEPER_DATA_DIR, daemonDir);
  }

  confMap.put(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort);
  confMap.put(HConstants.HREGION_MAX_FILESIZE, MAX_FILE_SIZE_OVERRIDE);

  if (dfsCluster != null) {
    String fsURL = "hdfs://" + HConstants.LOCALHOST + ":" + dfsCluster.getNameNodePort();
    confMap.put("fs.defaultFS", fsURL);
    confMap.put("hbase.rootdir", fsURL + "/hbase_test");
  }

  sb.append("<configuration>\n");
  for (Map.Entry<String, Object> entry : confMap.entrySet()) {
    sb.append("  <property>\n");
    sb.append("    <name>" + entry.getKey() + "</name>\n");
    sb.append("    <value>" + entry.getValue() + "</value>\n");
    sb.append("  </property>\n");
  }
  sb.append("</configuration>\n");
  return sb.toString();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:ProcessBasedLocalHBaseCluster.java


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