Search in sources :

Example 1 with MiniClusterType

use of org.apache.hive.jdbc.miniHS2.MiniHS2.MiniClusterType in project hive by apache.

the class StartMiniHS2Cluster method testRunCluster.

/**
   * Not a unit test - this simply runs a MiniHS2 cluster, which can be used for manual testing.
   */
@Test
public void testRunCluster() throws Exception {
    if (!Boolean.parseBoolean(System.getProperty("miniHS2.run", "false"))) {
        return;
    }
    MiniClusterType clusterType = MiniClusterType.valueOf(System.getProperty("miniHS2.clusterType", "MR").toUpperCase());
    String confFilesProperty = System.getProperty("miniHS2.conf", "../../data/conf/hive-site.xml");
    boolean usePortsFromConf = Boolean.parseBoolean(System.getProperty("miniHS2.usePortsFromConf", "false"));
    // Load conf files
    String[] confFiles = confFilesProperty.split(",");
    int idx;
    for (idx = 0; idx < confFiles.length; ++idx) {
        String confFile = confFiles[idx];
        if (confFile.isEmpty()) {
            continue;
        }
        HiveConf.setHiveSiteLocation(new URL("file://" + new File(confFile).toURI().getPath()));
        break;
    }
    HiveConf conf = new HiveConf();
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    conf.setBoolVar(HiveConf.ConfVars.HIVE_RPC_QUERY_PLAN, true);
    for (; idx < confFiles.length; ++idx) {
        String confFile = confFiles[idx];
        if (confFile.isEmpty()) {
            continue;
        }
        conf.addResource(new URL("file://" + new File(confFile).toURI().getPath()));
    }
    miniHS2 = new MiniHS2(conf, clusterType, usePortsFromConf);
    Map<String, String> confOverlay = new HashMap<String, String>();
    miniHS2.start(confOverlay);
    miniHS2.getDFS().getFileSystem().mkdirs(new Path("/apps_staging_dir/anonymous"));
    System.out.println("JDBC URL avaailable at " + miniHS2.getJdbcURL());
    // MiniHS2 cluster is up .. let it run until someone kills the test
    while (true) {
        Thread.sleep(1000);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MiniClusterType(org.apache.hive.jdbc.miniHS2.MiniHS2.MiniClusterType) HashMap(java.util.HashMap) HiveConf(org.apache.hadoop.hive.conf.HiveConf) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Path (org.apache.hadoop.fs.Path)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 MiniClusterType (org.apache.hive.jdbc.miniHS2.MiniHS2.MiniClusterType)1 Test (org.junit.Test)1