Search in sources :

Example 76 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class SetProcessor method dumpOptions.

private void dumpOptions(Properties p) {
    SessionState ss = SessionState.get();
    SortedMap<String, String> sortedMap = new TreeMap<String, String>();
    sortedMap.put("silent", (ss.getIsSilent() ? "on" : "off"));
    for (Object one : p.keySet()) {
        String oneProp = (String) one;
        String oneValue = p.getProperty(oneProp);
        if (ss.getConf().isHiddenConfig(oneProp)) {
            continue;
        }
        sortedMap.put(oneProp, oneValue);
    }
    // Inserting hive variables
    for (String s : ss.getHiveVariables().keySet()) {
        sortedMap.put(HIVEVAR_PREFIX + s, ss.getHiveVariables().get(s));
    }
    for (Map.Entry<String, String> entries : sortedMap.entrySet()) {
        ss.out.println(entries.getKey() + "=" + entries.getValue());
    }
    for (Map.Entry<String, String> entry : mapToSortedMap(System.getenv()).entrySet()) {
        if (isHidden(entry.getKey())) {
            continue;
        }
        ss.out.println(ENV_PREFIX + entry.getKey() + "=" + entry.getValue());
    }
    for (Map.Entry<String, String> entry : propertiesToSortedMap(System.getProperties()).entrySet()) {
        if (isHidden(entry.getKey())) {
            continue;
        }
        ss.out.println(SYSTEM_PREFIX + entry.getKey() + "=" + entry.getValue());
    }
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) MetadataTypedColumnsetSerDe.defaultNullString(org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe.defaultNullString) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 77 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class ThriftCLIService method getProgressedPercentage.

private double getProgressedPercentage(OperationHandle opHandle) throws HiveSQLException {
    checkArgument(OperationType.EXECUTE_STATEMENT.equals(opHandle.getOperationType()));
    Operation operation = cliService.getSessionManager().getOperationManager().getOperation(opHandle);
    SessionState state = operation.getParentSession().getSessionState();
    ProgressMonitor monitor = state.getProgressMonitor();
    return monitor == null ? 0.0 : monitor.progressedPercentage();
}
Also used : ProgressMonitor(org.apache.hadoop.hive.common.log.ProgressMonitor) SessionState(org.apache.hadoop.hive.ql.session.SessionState) Operation(org.apache.hive.service.cli.operation.Operation)

Example 78 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project incubator-atlas by apache.

the class HiveITBase method setUp.

@BeforeClass
public void setUp() throws Exception {
    //Set-up hive session
    conf = new HiveConf();
    conf.setClassLoader(Thread.currentThread().getContextClassLoader());
    driver = new Driver(conf);
    ss = new SessionState(conf);
    ss = SessionState.start(ss);
    SessionState.setCurrentSessionState(ss);
    Configuration configuration = ApplicationProperties.get();
    String[] atlasEndPoint = configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT);
    if (atlasEndPoint == null || atlasEndPoint.length == 0) {
        atlasEndPoint = new String[] { DGI_URL };
    }
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        atlasClient = new AtlasClient(atlasEndPoint, new String[] { "admin", "admin" });
    } else {
        atlasClient = new AtlasClient(atlasEndPoint);
    }
    hiveMetaStoreBridge = new HiveMetaStoreBridge(configuration, conf, atlasClient);
    HiveConf conf = new HiveConf();
    conf.set("hive.exec.post.hooks", "");
    SessionState ss = new SessionState(conf);
    ss = SessionState.start(ss);
    SessionState.setCurrentSessionState(ss);
    driverWithoutContext = new Driver(conf);
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveMetaStoreBridge(org.apache.atlas.hive.bridge.HiveMetaStoreBridge) Configuration(org.apache.commons.configuration.Configuration) Driver(org.apache.hadoop.hive.ql.Driver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) AtlasClient(org.apache.atlas.AtlasClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 79 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project incubator-atlas by apache.

the class HiveLiteralRewriterTest method setup.

@BeforeClass(enabled = false)
public void setup() {
    conf = new HiveConf();
    conf.addResource("/hive-site.xml");
    SessionState ss = new SessionState(conf, "testuser");
    SessionState.start(ss);
    conf.set("hive.lock.manager", "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager");
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) BeforeClass(org.testng.annotations.BeforeClass)

Example 80 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project drill by apache.

the class TestStorageBasedHiveAuthorization method generateTestData.

private static void generateTestData() throws Exception {
    // Generate Hive test tables
    final SessionState ss = new SessionState(hiveConf);
    SessionState.start(ss);
    final Driver driver = new Driver(hiveConf);
    executeQuery(driver, "CREATE DATABASE " + db_general);
    createTable(driver, db_general, g_student_u0_700, studentDef, studentData, org1Users[0], org1Groups[0], (short) 0700);
    createTable(driver, db_general, g_student_u0g0_750, studentDef, studentData, org1Users[0], org1Groups[0], (short) 0750);
    createTable(driver, db_general, g_student_all_755, studentDef, studentData, org1Users[2], org1Groups[2], (short) 0755);
    createTable(driver, db_general, g_voter_u1_700, voterDef, voterData, org1Users[1], org1Groups[1], (short) 0700);
    createTable(driver, db_general, g_voter_u2g1_750, voterDef, voterData, org1Users[2], org1Groups[1], (short) 0750);
    createTable(driver, db_general, g_voter_all_755, voterDef, voterData, org1Users[1], org1Groups[1], (short) 0755);
    createPartitionedTable(driver, db_general, g_partitioned_student_u0_700, partitionStudentDef, "INSERT OVERWRITE TABLE %s.%s PARTITION(age) SELECT rownum, name, age, gpa, studentnum FROM %s.%s", g_student_all_755, org1Users[0], org1Groups[0], (short) 0700);
    changeDBPermissions(db_general, (short) 0755, org1Users[0], org1Groups[0]);
    executeQuery(driver, "CREATE DATABASE " + db_u1g1_only);
    createTable(driver, db_u1g1_only, u1g1_student_all_755, studentDef, studentData, org1Users[1], org1Groups[1], (short) 0755);
    createTable(driver, db_u1g1_only, u1g1_student_u1_700, studentDef, studentData, org1Users[1], org1Groups[1], (short) 0700);
    createTable(driver, db_u1g1_only, u1g1_voter_all_755, voterDef, voterData, org1Users[1], org1Groups[1], (short) 0755);
    createTable(driver, db_u1g1_only, u1g1_voter_u1_700, voterDef, voterData, org1Users[1], org1Groups[1], (short) 0700);
    changeDBPermissions(db_u1g1_only, (short) 0750, org1Users[1], org1Groups[1]);
    executeQuery(driver, "CREATE DATABASE " + db_u0_only);
    createTable(driver, db_u0_only, u0_student_all_755, studentDef, studentData, org1Users[0], org1Groups[0], (short) 0755);
    createTable(driver, db_u0_only, u0_voter_all_755, voterDef, voterData, org1Users[0], org1Groups[0], (short) 0755);
    changeDBPermissions(db_u0_only, (short) 0700, org1Users[0], org1Groups[0]);
    createView(org1Users[0], org1Groups[0], v_student_u0g0_750, String.format("SELECT rownum, name, age, studentnum FROM %s.%s.%s", hivePluginName, db_general, g_student_u0_700));
    createView(org1Users[1], org1Groups[1], v_student_u1g1_750, String.format("SELECT rownum, name, age FROM %s.%s.%s", MINIDFS_STORAGE_PLUGIN_NAME, "tmp", v_student_u0g0_750));
    createView(org1Users[0], org1Groups[0], v_partitioned_student_u0g0_750, String.format("SELECT rownum, name, age, studentnum FROM %s.%s.%s", hivePluginName, db_general, g_partitioned_student_u0_700));
    createView(org1Users[1], org1Groups[1], v_partitioned_student_u1g1_750, String.format("SELECT rownum, name, age FROM %s.%s.%s", MINIDFS_STORAGE_PLUGIN_NAME, "tmp", v_partitioned_student_u0g0_750));
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) Driver(org.apache.hadoop.hive.ql.Driver)

Aggregations

SessionState (org.apache.hadoop.hive.ql.session.SessionState)112 IOException (java.io.IOException)28 HiveConf (org.apache.hadoop.hive.conf.HiveConf)22 ArrayList (java.util.ArrayList)14 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)14 Path (org.apache.hadoop.fs.Path)13 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)13 LinkedList (java.util.LinkedList)12 CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)12 File (java.io.File)11 FileNotFoundException (java.io.FileNotFoundException)11 Map (java.util.Map)11 Test (org.junit.Test)10 PrintStream (java.io.PrintStream)9 ExecutionException (java.util.concurrent.ExecutionException)9 HashMap (java.util.HashMap)8 LinkedHashMap (java.util.LinkedHashMap)7 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)7 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)6 Callable (java.util.concurrent.Callable)6