Search in sources :

Example 16 with CliSessionState

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);
}
Also used : HiveInputFormat(org.apache.hadoop.hive.ql.io.HiveInputFormat) HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) HiveConf(org.apache.hadoop.hive.conf.HiveConf) OrcFile(org.apache.hadoop.hive.ql.io.orc.OrcFile) File(java.io.File) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) HiveEndPoint(org.apache.hive.hcatalog.streaming.HiveEndPoint) Before(org.junit.Before)

Example 17 with CliSessionState

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()));
}
Also used : CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState)

Example 18 with CliSessionState

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);
}
Also used : CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState)

Example 19 with CliSessionState

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;
}
Also used : Path(org.apache.hadoop.fs.Path) HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) FileSystem(org.apache.hadoop.fs.FileSystem) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Map(java.util.Map) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState)

Example 20 with CliSessionState

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);
}
Also used : HiveMetaStoreClient(org.apache.hadoop.hive.metastore.HiveMetaStoreClient) AuthorizationPreEventListener(org.apache.hadoop.hive.ql.security.authorization.AuthorizationPreEventListener) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) Before(org.junit.Before)

Aggregations

CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)58 HiveConf (org.apache.hadoop.hive.conf.HiveConf)44 File (java.io.File)12 HiveMetaStoreClient (org.apache.hadoop.hive.metastore.HiveMetaStoreClient)12 Before (org.junit.Before)12 SessionState (org.apache.hadoop.hive.ql.session.SessionState)11 BeforeClass (org.junit.BeforeClass)9 Path (org.apache.hadoop.fs.Path)8 Driver (org.apache.hadoop.hive.ql.Driver)8 PrintStream (java.io.PrintStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 LogInitializationException (org.apache.hadoop.hive.common.LogUtils.LogInitializationException)6 Map (java.util.Map)5 CliDriver (org.apache.hadoop.hive.cli.CliDriver)5 CachingPrintStream (org.apache.hadoop.hive.common.io.CachingPrintStream)5 FileNotFoundException (java.io.FileNotFoundException)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 AuthorizationPreEventListener (org.apache.hadoop.hive.ql.security.authorization.AuthorizationPreEventListener)4 BufferedOutputStream (java.io.BufferedOutputStream)3 FileOutputStream (java.io.FileOutputStream)3