Search in sources :

Example 36 with CliSessionState

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

the class HBaseIntegrationTests method setupDriver.

protected void setupDriver() {
    // This chicanery is necessary to make the driver work.  Hive tests need the pfile file
    // system, while the hbase one uses something else.  So first make sure we've configured our
    // hbase connection, then get a new config file and populate it as desired.
    HBaseReadWrite.setConf(conf);
    conf = new HiveConf();
    conf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
    conf.setVar(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL, "org.apache.hadoop.hive.metastore.hbase.HBaseStore");
    conf.setBoolVar(HiveConf.ConfVars.METASTORE_FASTPATH, true);
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    // Setup so we can test SQL standard auth
    conf.setBoolVar(HiveConf.ConfVars.HIVE_TEST_AUTHORIZATION_SQLSTD_HS2_MODE, true);
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, SQLStdHiveAuthorizerFactoryForTest.class.getName());
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateConfigUserAuthenticator.class.getName());
    conf.setBoolVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
    conf.setVar(HiveConf.ConfVars.USERS_IN_ADMIN_ROLE, System.getProperty("user.name"));
    conf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
    //HBaseReadWrite.setTestConnection(hconn);
    SessionState.start(new CliSessionState(conf));
    driver = new Driver(conf);
}
Also used : SessionStateConfigUserAuthenticator(org.apache.hadoop.hive.ql.security.SessionStateConfigUserAuthenticator) Driver(org.apache.hadoop.hive.ql.Driver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) SQLStdHiveAuthorizerFactoryForTest(org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest)

Example 37 with CliSessionState

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

the class TestHiveHistory method testQueryloglocParentDirNotExist.

public void testQueryloglocParentDirNotExist() throws Exception {
    String parentTmpDir = tmpdir + "/HIVE2654";
    Path parentDirPath = new Path(parentTmpDir);
    try {
        fs.delete(parentDirPath, true);
    } catch (Exception e) {
    }
    try {
        String actualDir = parentTmpDir + "/test";
        HiveConf conf = new HiveConf(SessionState.class);
        conf.set(HiveConf.ConfVars.HIVEHISTORYFILELOC.toString(), actualDir);
        SessionState ss = new CliSessionState(conf);
        HiveHistory hiveHistory = new HiveHistoryImpl(ss);
        Path actualPath = new Path(actualDir);
        if (!fs.exists(actualPath)) {
            fail("Query location path is not exist :" + actualPath.toString());
        }
    } finally {
        try {
            fs.delete(parentDirPath, true);
        } catch (Exception e) {
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) 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) LogInitializationException(org.apache.hadoop.hive.common.LogUtils.LogInitializationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 38 with CliSessionState

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

the class TestPartitionNameWhitelistValidation method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    System.setProperty(HiveConf.ConfVars.METASTORE_PARTITION_NAME_WHITELIST_PATTERN.varname, partitionValidationPattern);
    hiveConf = new HiveConf();
    SessionState.start(new CliSessionState(hiveConf));
    msc = new HiveMetaStoreClient(hiveConf);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) BeforeClass(org.junit.BeforeClass)

Example 39 with CliSessionState

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

the class TestHBaseMetastoreMetrics method before.

@Before
public void before() throws IOException {
    HBaseReadWrite.setConf(conf);
    conf = new HiveConf();
    conf.setVar(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL, "org.apache.hadoop.hive.metastore.hbase.HBaseStore");
    conf.setBoolVar(HiveConf.ConfVars.METASTORE_FASTPATH, true);
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    conf.setBoolVar(HiveConf.ConfVars.METASTORE_METRICS, true);
    conf.setVar(HiveConf.ConfVars.HIVE_METRICS_REPORTER, MetricsReporting.JSON_FILE.name() + "," + MetricsReporting.JMX.name());
    SessionState.start(new CliSessionState(conf));
    driver = new Driver(conf);
}
Also used : Driver(org.apache.hadoop.hive.ql.Driver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) Before(org.junit.Before)

Example 40 with CliSessionState

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

the class TestMetastoreVersion method testVersionRestriction.

/**
 * Test schema verification property
 * @throws Exception
 */
public void testVersionRestriction() throws Exception {
    System.setProperty(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString(), "true");
    hiveConf = new HiveConf(this.getClass());
    assertTrue(hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION));
    assertFalse(hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_AUTO_CREATE_ALL));
    // session creation should fail since the schema didn't get created
    try {
        SessionState.start(new CliSessionState(hiveConf));
        Hive.get(hiveConf).getMSC();
        fail("An exception is expected since schema is not created.");
    } catch (Exception re) {
        LOG.info("Exception in testVersionRestriction: " + re, re);
        String msg = HiveStringUtils.stringifyException(re);
        assertTrue("Expected 'Version information not found in metastore' in: " + msg, msg.contains("Version information not found in metastore"));
    }
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

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