當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。