private HiveConf configure() throws Exception {
TestUtils.delete(new File("/tmp/hive"));
Configuration cfg = new Configuration();
HiveConf conf = new HiveConf(cfg, HiveConf.class);
refreshConfig(conf);
HdpBootstrap.hackHadoopStagingOnWin();
// work-around for NTFS FS
// set permissive permissions since otherwise, on some OS it fails
if (TestUtils.isWindows()) {
conf.set("fs.file.impl", NTFSLocalFileSystem.class.getName());
conf.set("hive.scratch.dir.permission", "650");
conf.setVar(ConfVars.SCRATCHDIRPERMISSION, "650");
conf.set("hive.server2.enable.doAs", "false");
conf.set("hive.execution.engine", "mr");
//conf.set("hadoop.bin.path", getClass().getClassLoader().getResource("hadoop.cmd").getPath());
System.setProperty("path.separator", ";");
conf.setVar(HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER,
DummyHiveAuthenticationProvider.class.getName());
}
else {
conf.set("hive.scratch.dir.permission", "777");
conf.setVar(ConfVars.SCRATCHDIRPERMISSION, "777");
}
int random = new Random().nextInt();
conf.set("hive.metastore.warehouse.dir", "/tmp/hive/warehouse" + random);
conf.set("hive.metastore.metadb.dir", "/tmp/hive/metastore_db" + random);
conf.set("hive.exec.scratchdir", "/tmp/hive");
conf.set("fs.permissions.umask-mode", "022");
conf.set("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=/tmp/hive/metastore_db" + random + ";create=true");
conf.set("hive.metastore.local", "true");
conf.set("hive.aux.jars.path", "");
conf.set("hive.added.jars.path", "");
conf.set("hive.added.files.path", "");
conf.set("hive.added.archives.path", "");
conf.set("fs.default.name", "file:///");
// clear mapred.job.tracker - Hadoop defaults to 'local' if not defined. Hive however expects this to be set to 'local' - if it's not, it does a remote execution (i.e. no child JVM)
Field field = Configuration.class.getDeclaredField("properties");
field.setAccessible(true);
Properties props = (Properties) field.get(conf);
props.remove("mapred.job.tracker");
props.remove("mapreduce.framework.name");
props.setProperty("fs.default.name", "file:///");
// intercept SessionState to clean the threadlocal
Field tss = SessionState.class.getDeclaredField("tss");
tss.setAccessible(true);
tss.set(null, new InterceptingThreadLocal());
return new HiveConf(conf);
}