use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestCompactor method setup.
@Before
public void setup() throws Exception {
File f = new File(TEST_WAREHOUSE_DIR);
if (f.exists()) {
FileUtil.fullyDelete(f);
}
if (!(new File(TEST_WAREHOUSE_DIR).mkdirs())) {
throw new RuntimeException("Could not create " + TEST_WAREHOUSE_DIR);
}
HiveConf hiveConf = new HiveConf(this.getClass());
hiveConf.setVar(HiveConf.ConfVars.PREEXECHOOKS, "");
hiveConf.setVar(HiveConf.ConfVars.POSTEXECHOOKS, "");
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, TEST_WAREHOUSE_DIR);
hiveConf.setVar(HiveConf.ConfVars.HIVEINPUTFORMAT, HiveInputFormat.class.getName());
hiveConf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
TxnDbUtil.setConfValues(hiveConf);
TxnDbUtil.cleanDb(hiveConf);
TxnDbUtil.prepDb(hiveConf);
conf = hiveConf;
msClient = new HiveMetaStoreClient(conf);
driver = DriverFactory.newDriver(hiveConf);
SessionState.start(new CliSessionState(hiveConf));
int LOOP_SIZE = 3;
String[] input = new String[LOOP_SIZE * LOOP_SIZE];
int k = 0;
for (int i = 1; i <= LOOP_SIZE; i++) {
String si = i + "";
for (int j = 1; j <= LOOP_SIZE; j++) {
String sj = "S" + j + "S";
input[k] = si + "\t" + sj;
k++;
}
}
createTestDataFile(BASIC_FILE_NAME, input);
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestHiveHistory method testHiveHistoryConfigDisabled.
/**
* Check if HiveHistory class is a Proxy class when hive history is disabled
* @throws Exception
*/
public void testHiveHistoryConfigDisabled() throws Exception {
HiveConf conf = new HiveConf(SessionState.class);
conf.setBoolVar(ConfVars.HIVE_SESSION_HISTORY_ENABLED, false);
SessionState ss = new CliSessionState(conf);
SessionState.start(ss);
HiveHistory hHistory = ss.getHiveHistory();
assertTrue("checking hive history class when history is disabled", hHistory.getClass() != HiveHistoryImpl.class);
System.err.println("hHistory.getClass" + hHistory.getClass());
assertTrue("verifying proxy class is used when history is disabled", Proxy.isProxyClass(hHistory.getClass()));
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class TestHiveHistory method testHiveHistoryConfigEnabled.
/**
* Check if HiveHistoryImpl class is returned when hive history is enabled
* @throws Exception
*/
public void testHiveHistoryConfigEnabled() throws Exception {
HiveConf conf = new HiveConf(SessionState.class);
conf.setBoolVar(ConfVars.HIVE_SESSION_HISTORY_ENABLED, true);
SessionState ss = new CliSessionState(conf);
SessionState.start(ss);
HiveHistory hHistory = ss.getHiveHistory();
assertEquals("checking hive history class when history is enabled", hHistory.getClass(), HiveHistoryImpl.class);
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class WarehouseInstance method initialize.
private void initialize(String cmRoot, String warehouseRoot, Map<String, String> overridesForHiveConf) throws Exception {
hiveConf = new HiveConf(miniDFSCluster.getConfiguration(0), TestReplicationScenarios.class);
for (Map.Entry<String, String> entry : overridesForHiveConf.entrySet()) {
hiveConf.set(entry.getKey(), entry.getValue());
}
String metaStoreUri = System.getProperty("test." + HiveConf.ConfVars.METASTOREURIS.varname);
String hiveWarehouseLocation = System.getProperty("test.warehouse.dir", "/tmp") + Path.SEPARATOR + TestReplicationScenarios.class.getCanonicalName().replace('.', '_') + "_" + System.nanoTime();
if (metaStoreUri != null) {
hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, metaStoreUri);
return;
}
// hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_IN_TEST, hiveInTest);
// turn on db notification listener on meta store
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, warehouseRoot);
hiveConf.setVar(HiveConf.ConfVars.METASTORE_TRANSACTIONAL_EVENT_LISTENERS, LISTENER_CLASS);
hiveConf.setBoolVar(HiveConf.ConfVars.REPLCMENABLED, true);
hiveConf.setBoolVar(HiveConf.ConfVars.FIRE_EVENTS_FOR_DML, true);
hiveConf.setVar(HiveConf.ConfVars.REPLCMDIR, cmRoot);
hiveConf.setVar(HiveConf.ConfVars.REPL_FUNCTIONS_ROOT_DIR, functionsRoot);
hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY, "jdbc:derby:memory:${test.tmp.dir}/APP;create=true");
hiveConf.setVar(HiveConf.ConfVars.REPLDIR, hiveWarehouseLocation + "/hrepl" + uniqueIdentifier + "/");
hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
Path testPath = new Path(hiveWarehouseLocation);
FileSystem testPathFileSystem = FileSystem.get(testPath.toUri(), hiveConf);
testPathFileSystem.mkdirs(testPath);
driver = DriverFactory.newDriver(hiveConf);
SessionState.start(new CliSessionState(hiveConf));
client = new HiveMetaStoreClient(hiveConf);
// change the value for the next instance.
++uniqueIdentifier;
}
use of org.apache.hadoop.hive.cli.CliSessionState in project hive by apache.
the class StorageBasedMetastoreTestBase method setUp.
@Before
public void setUp() throws Exception {
// Turn on metastore-side authorization
System.setProperty(HiveConf.ConfVars.METASTORE_PRE_EVENT_LISTENERS.varname, AuthorizationPreEventListener.class.getName());
System.setProperty(HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER.varname, getAuthorizationProvider());
System.setProperty(HiveConf.ConfVars.HIVE_METASTORE_AUTHENTICATOR_MANAGER.varname, InjectableDummyAuthenticator.class.getName());
clientHiveConf = createHiveConf();
MetaStoreTestUtils.startMetaStoreWithRetry(clientHiveConf);
// Turn off client-side authorization
clientHiveConf.setBoolVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED, false);
clientHiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
clientHiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
clientHiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
clientHiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
ugi = Utils.getUGI();
SessionState.start(new CliSessionState(clientHiveConf));
msc = new HiveMetaStoreClient(clientHiveConf);
driver = DriverFactory.newDriver(clientHiveConf);
setupFakeUser();
InjectableDummyAuthenticator.injectMode(false);
}
Aggregations