Search in sources :

Example 96 with HiveConf

use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.

the class SemanticAnalyzer method isPathReadOnly.

/**
   * Checks if a given path has read-only access permissions.
   *
   * @param path The path to check for read-only permissions.
   * @return True if the path is read-only; False otherwise.
   * @throws HiveException If an error occurs while checking file permissions.
   */
private boolean isPathReadOnly(Path path) throws HiveException {
    HiveConf conf = SessionState.get().getConf();
    try {
        FileSystem fs = path.getFileSystem(conf);
        UserGroupInformation ugi = Utils.getUGI();
        FileStatus status = fs.getFileStatus(path);
        // We just check for writing permissions. If it fails with AccessControException, then it
        // means the location may be read-only.
        FileUtils.checkFileAccessWithImpersonation(fs, status, FsAction.WRITE, ugi.getUserName());
        // Path has writing permissions
        return false;
    } catch (AccessControlException e) {
        // but we take it as if our path is read-only
        return true;
    } catch (Exception e) {
        throw new HiveException("Unable to determine if " + path + " is read only: " + e, e);
    }
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) FileSystem(org.apache.hadoop.fs.FileSystem) AccessControlException(java.security.AccessControlException) HiveConf(org.apache.hadoop.hive.conf.HiveConf) IOException(java.io.IOException) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) SerDeException(org.apache.hadoop.hive.serde2.SerDeException) PatternSyntaxException(java.util.regex.PatternSyntaxException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(java.security.AccessControlException) InvalidTableException(org.apache.hadoop.hive.ql.metadata.InvalidTableException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 97 with HiveConf

use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.

the class TestHBaseStoreCached method init.

@Before
public void init() throws IOException {
    MockitoAnnotations.initMocks(this);
    HiveConf conf = new HiveConf();
    store = MockUtils.init(conf, htable, rows);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) Before(org.junit.Before)

Example 98 with HiveConf

use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.

the class Task method cloneConf.

protected void cloneConf() {
    if (!clonedConf) {
        clonedConf = true;
        conf = new HiveConf(conf);
    }
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf)

Example 99 with HiveConf

use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.

the class TezSessionPoolManager method reopenSession.

/** Reopens the session that was found to not be running. */
public void reopenSession(TezSessionState sessionState, HiveConf conf, String[] additionalFiles, boolean keepTmpDir) throws Exception {
    HiveConf sessionConf = sessionState.getConf();
    if (sessionConf != null && sessionConf.get(TezConfiguration.TEZ_QUEUE_NAME) != null) {
        // user has explicitly specified queue name
        conf.set(TezConfiguration.TEZ_QUEUE_NAME, sessionConf.get(TezConfiguration.TEZ_QUEUE_NAME));
    } else {
        // default queue name when the initial session was created
        if (sessionState.getQueueName() != null) {
            conf.set(TezConfiguration.TEZ_QUEUE_NAME, sessionState.getQueueName());
        }
    }
    // TODO: close basically resets the object to a bunch of nulls.
    //       We should ideally not reuse the object because it's pointless and error-prone.
    // Clean up stuff.
    sessionState.close(keepTmpDir);
    sessionState.open(conf, additionalFiles);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf)

Example 100 with HiveConf

use of org.apache.hadoop.hive.conf.HiveConf in project hive by apache.

the class TezSessionPoolManager method startInitialSession.

private void startInitialSession(TezSessionPoolSession sessionState) throws Exception {
    // TODO Why is this configuration management not happening inside TezSessionPool.
    HiveConf newConf = new HiveConf(initConf);
    // Makes no senses for it to be mixed up like this.
    boolean isUsable = sessionState.tryUse();
    if (!isUsable)
        throw new IOException(sessionState + " is not usable at pool startup");
    newConf.set(TezConfiguration.TEZ_QUEUE_NAME, sessionState.getQueueName());
    sessionState.open(newConf);
    if (sessionState.returnAfterUse()) {
        defaultQueuePool.put(sessionState);
    }
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) IOException(java.io.IOException)

Aggregations

HiveConf (org.apache.hadoop.hive.conf.HiveConf)404 BeforeClass (org.junit.BeforeClass)73 Test (org.junit.Test)66 Path (org.apache.hadoop.fs.Path)54 Before (org.junit.Before)50 Driver (org.apache.hadoop.hive.ql.Driver)46 CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)44 IOException (java.io.IOException)39 ArrayList (java.util.ArrayList)37 File (java.io.File)31 HashMap (java.util.HashMap)26 FileSystem (org.apache.hadoop.fs.FileSystem)26 SessionState (org.apache.hadoop.hive.ql.session.SessionState)22 LinkedHashMap (java.util.LinkedHashMap)17 List (java.util.List)16 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)15 MiniHS2 (org.apache.hive.jdbc.miniHS2.MiniHS2)14 Map (java.util.Map)12 HiveMetaStoreClient (org.apache.hadoop.hive.metastore.HiveMetaStoreClient)12 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)12