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


Java MetaStoreUtils.findFreePort方法代码示例

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


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

示例1: start

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
public void start(Map<String, String> confOverlay) throws Exception {
  if (isMetastoreRemote) {
    int metaStorePort = MetaStoreUtils.findFreePort();
    getHiveConf().setVar(ConfVars.METASTOREURIS, "thrift://localhost:" + metaStorePort);
    MetaStoreUtils.startMetaStore(metaStorePort,
    ShimLoader.getHadoopThriftAuthBridge(), getHiveConf());
  }

  hiveServer2 = new HiveServer2();
  // Set confOverlay parameters
  for (Map.Entry<String, String> entry : confOverlay.entrySet()) {
    setConfProperty(entry.getKey(), entry.getValue());
  }
  hiveServer2.init(getHiveConf());
  hiveServer2.start();
  waitForStartup();
  setStarted(true);
}
 
开发者ID:bobfreitas,项目名称:hiveunit-mr2,代码行数:19,代码来源:MiniHS2.java

示例2: MiniHS2

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
private MiniHS2(HiveConf hiveConf, boolean useMiniMR, boolean useMiniKdc,
    String serverPrincipal, String serverKeytab, boolean isMetastoreRemote) throws Exception {
  super(hiveConf, "localhost", MetaStoreUtils.findFreePort(), MetaStoreUtils.findFreePort());
  this.useMiniMR = useMiniMR;
  this.useMiniKdc = useMiniKdc;
  this.serverPrincipal = serverPrincipal;
  this.serverKeytab = serverKeytab;
  this.isMetastoreRemote = isMetastoreRemote;
  baseDir = Files.createTempDir();
  localFS = FileSystem.getLocal(hiveConf);
  FileSystem fs;
  if (useMiniMR) {
    dfs = ShimLoader.getHadoopShims().getMiniDfs(hiveConf, 4, true, null);
    fs = dfs.getFileSystem();
    mr = ShimLoader.getHadoopShims().getMiniMrCluster(hiveConf, 4,
        fs.getUri().toString(), 1);
    // store the config in system properties
    mr.setupConfiguration(getHiveConf());
    baseDfsDir =  new Path(new Path(fs.getUri()), "/base");
  } else {
    fs = FileSystem.getLocal(hiveConf);
    baseDfsDir = new Path("file://"+ baseDir.toURI().getPath());
  }
  if (useMiniKdc) {
    hiveConf.setVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL, serverPrincipal);
    hiveConf.setVar(ConfVars.HIVE_SERVER2_KERBEROS_KEYTAB, serverKeytab);
    hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, "KERBEROS");
  }
  String metaStoreURL =  "jdbc:derby:" + baseDir.getAbsolutePath() + File.separator + "test_metastore-" +
      hs2Counter.incrementAndGet() + ";create=true";

  fs.mkdirs(baseDfsDir);
  Path wareHouseDir = new Path(baseDfsDir, "warehouse");
  // Create warehouse with 777, so that user impersonation has no issues.
  FileSystem.mkdirs(fs, wareHouseDir, FULL_PERM);

  fs.mkdirs(wareHouseDir);
  setWareHouseDir(wareHouseDir.toString());
  System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, metaStoreURL);
  hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY, metaStoreURL);
  // reassign a new port, just in case if one of the MR services grabbed the last one
  setBinaryPort(MetaStoreUtils.findFreePort());
  hiveConf.setVar(ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, getHost());
  hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_PORT, getBinaryPort());
  hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, getHttpPort());

  Path scratchDir = new Path(baseDfsDir, "scratch");
  // Create root scratchdir with write all, so that user impersonation has no issues.
  Utilities.createDirsWithPermission(hiveConf, scratchDir, WRITE_ALL_PERM, true);
  System.setProperty(HiveConf.ConfVars.SCRATCHDIR.varname, scratchDir.toString());
  hiveConf.setVar(ConfVars.SCRATCHDIR, scratchDir.toString());

  String localScratchDir = baseDir.getPath() + File.separator + "scratch";
  System.setProperty(HiveConf.ConfVars.LOCALSCRATCHDIR.varname, localScratchDir);
  hiveConf.setVar(ConfVars.LOCALSCRATCHDIR, localScratchDir);
}
 
开发者ID:bobfreitas,项目名称:hiveunit-mr2,代码行数:57,代码来源:MiniHS2.java

示例3: startHiveMetaStore

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
protected static void startHiveMetaStore() throws Exception {
  final int port = MetaStoreUtils.findFreePort();

  hiveConf.set(METASTOREURIS.varname, "thrift://localhost:" + port);

  MetaStoreUtils.startMetaStore(port, ShimLoader.getHadoopThriftAuthBridge(), hiveConf);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:BaseTestHiveImpersonation.java


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