Search in sources :

Example 6 with CliDriver

use of org.apache.hadoop.hive.cli.CliDriver in project hive by apache.

the class TestCLIAuthzSessionContext method beforeTest.

@BeforeClass
public static void beforeTest() throws Exception {
    HiveConf conf = new HiveConf();
    conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, MockedHiveAuthorizerFactory.class.getName());
    conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateUserAuthenticator.class.getName());
    conf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    // once SessionState for thread is set, CliDriver picks conf from it
    CliSessionState ss = new CliSessionState(conf);
    ss.err = System.err;
    ss.out = System.out;
    SessionState.start(ss);
    TestCLIAuthzSessionContext.driver = new CliDriver();
}
Also used : SessionStateUserAuthenticator(org.apache.hadoop.hive.ql.security.SessionStateUserAuthenticator) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) CliDriver(org.apache.hadoop.hive.cli.CliDriver) BeforeClass(org.junit.BeforeClass)

Example 7 with CliDriver

use of org.apache.hadoop.hive.cli.CliDriver in project phoenix by apache.

the class HiveTestUtil method cleanUp.

public void cleanUp() throws Exception {
    if (!isSessionStateStarted) {
        startSessionState();
    }
    if (System.getenv(QTEST_LEAVE_FILES) != null) {
        return;
    }
    clearTablesCreatedDuringTests();
    SessionState.get().getConf().setBoolean("hive.test.shutdown.phase", true);
    if (cleanupScript != "") {
        String cleanupCommands = readEntireFileIntoString(new File(cleanupScript));
        LOG.info("Cleanup (" + cleanupScript + "):\n" + cleanupCommands);
        if (cliDriver == null) {
            cliDriver = new CliDriver();
        }
        cliDriver.processLine(cleanupCommands);
    }
    SessionState.get().getConf().setBoolean("hive.test.shutdown.phase", false);
    // delete any contents in the warehouse dir
    Path p = new Path(testWarehouse);
    FileSystem fs = p.getFileSystem(conf);
    try {
        FileStatus[] ls = fs.listStatus(p);
        for (int i = 0; (ls != null) && (i < ls.length); i++) {
            fs.delete(ls[i].getPath(), true);
        }
    } catch (FileNotFoundException e) {
    // Best effort
    }
    FunctionRegistry.unregisterTemporaryUDF("test_udaf");
    FunctionRegistry.unregisterTemporaryUDF("test_error");
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) FileSystem(org.apache.hadoop.fs.FileSystem) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) CliDriver(org.apache.hadoop.hive.cli.CliDriver)

Example 8 with CliDriver

use of org.apache.hadoop.hive.cli.CliDriver in project phoenix by apache.

the class HiveTestUtil method createSources.

public void createSources() throws Exception {
    if (!isSessionStateStarted) {
        startSessionState();
    }
    conf.setBoolean("hive.test.init.phase", true);
    if (cliDriver == null) {
        cliDriver = new CliDriver();
    }
    cliDriver.processLine("set test.data.dir=" + testFiles + ";");
    conf.setBoolean("hive.test.init.phase", false);
}
Also used : CliDriver(org.apache.hadoop.hive.cli.CliDriver)

Aggregations

CliDriver (org.apache.hadoop.hive.cli.CliDriver)8 File (java.io.File)5 CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)4 Path (org.apache.hadoop.fs.Path)3 BufferedOutputStream (java.io.BufferedOutputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 PrintStream (java.io.PrintStream)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 CachingPrintStream (org.apache.hadoop.hive.common.io.CachingPrintStream)2 DigestPrintStream (org.apache.hadoop.hive.common.io.DigestPrintStream)2 SortAndDigestPrintStream (org.apache.hadoop.hive.common.io.SortAndDigestPrintStream)2 SortPrintStream (org.apache.hadoop.hive.common.io.SortPrintStream)2 HiveConf (org.apache.hadoop.hive.conf.HiveConf)2 SessionState (org.apache.hadoop.hive.ql.session.SessionState)2 TezSessionState (org.apache.hadoop.hive.ql.exec.tez.TezSessionState)1 SessionStateUserAuthenticator (org.apache.hadoop.hive.ql.security.SessionStateUserAuthenticator)1 HCatSemanticAnalyzer (org.apache.hive.hcatalog.cli.SemanticAnalysis.HCatSemanticAnalyzer)1