Search in sources :

Example 11 with HiveConf

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

the class TestAddResource method setup.

@Before
public void setup() throws IOException {
    conf = new HiveConf();
    t = ResourceType.JAR;
    //Generate test jar files
    for (int i = 1; i <= 5; i++) {
        Writer output = null;
        String dataFile = TEST_JAR_DIR + "testjar" + i + ".jar";
        File file = new File(dataFile);
        output = new BufferedWriter(new FileWriter(file));
        output.write("sample");
        output.close();
    }
}
Also used : FileWriter(java.io.FileWriter) HiveConf(org.apache.hadoop.hive.conf.HiveConf) File(java.io.File) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter) Before(org.junit.Before)

Example 12 with HiveConf

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

the class TestSessionState method testClassLoaderEquality.

@Test
public void testClassLoaderEquality() throws Exception {
    HiveConf conf = new HiveConf();
    final SessionState ss1 = new SessionState(conf);
    RegisterJarRunnable otherThread = new RegisterJarRunnable("./build/contrib/test/test-udfs.jar", ss1);
    Thread th1 = new Thread(otherThread);
    th1.start();
    th1.join();
    // set state in current thread
    SessionState.start(ss1);
    SessionState ss2 = SessionState.get();
    ClassLoader loader2 = ss2.getConf().getClassLoader();
    System.out.println("Loader1:(Set in other thread) " + otherThread.loader);
    System.out.println("Loader2:(Set in SessionState.conf) " + loader2);
    System.out.println("Loader3:(CurrentThread.getContextClassLoader()) " + Thread.currentThread().getContextClassLoader());
    assertEquals("Other thread loader and session state loader", otherThread.loader, loader2);
    assertEquals("Other thread loader and current thread loader", otherThread.loader, Thread.currentThread().getContextClassLoader());
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) Test(org.junit.Test)

Example 13 with HiveConf

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

the class CLIService method getOperationStatus.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getOperationStatus(org.apache.hive.service.cli.OperationHandle)
   */
@Override
public OperationStatus getOperationStatus(OperationHandle opHandle, boolean getProgressUpdate) throws HiveSQLException {
    Operation operation = sessionManager.getOperationManager().getOperation(opHandle);
    /**
     * If this is a background operation run asynchronously,
     * we block for a duration determined by a step function, before we return
     * However, if the background operation is complete, we return immediately.
     */
    HiveConf conf = operation.getParentSession().getHiveConf();
    if (operation.shouldRunAsync()) {
        long maxTimeout = HiveConf.getTimeVar(conf, HiveConf.ConfVars.HIVE_SERVER2_LONG_POLLING_TIMEOUT, TimeUnit.MILLISECONDS);
        final long elapsed = System.currentTimeMillis() - operation.getBeginTime();
        // A step function to increase the polling timeout by 500 ms every 10 sec, 
        // starting from 500 ms up to HIVE_SERVER2_LONG_POLLING_TIMEOUT
        final long timeout = Math.min(maxTimeout, (elapsed / TimeUnit.SECONDS.toMillis(10) + 1) * 500);
        try {
            operation.getBackgroundHandle().get(timeout, TimeUnit.MILLISECONDS);
        } catch (TimeoutException e) {
            // No Op, return to the caller since long polling timeout has expired
            LOG.trace(opHandle + ": Long polling timed out");
        } catch (CancellationException e) {
            // The background operation thread was cancelled
            LOG.trace(opHandle + ": The background operation was cancelled", e);
        } catch (ExecutionException e) {
            // Note: Hive ops do not use the normal Future failure path, so this will not happen
            //       in case of actual failure; the Future will just be done.
            // The background operation thread was aborted
            LOG.warn(opHandle + ": The background operation was aborted", e);
        } catch (InterruptedException e) {
        // No op, this thread was interrupted
        // In this case, the call might return sooner than long polling timeout
        }
    }
    OperationStatus opStatus = operation.getStatus();
    LOG.debug(opHandle + ": getOperationStatus()");
    opStatus.setJobProgressUpdate(progressUpdateLog(getProgressUpdate, operation, conf));
    return opStatus;
}
Also used : CancellationException(java.util.concurrent.CancellationException) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Operation(org.apache.hive.service.cli.operation.Operation) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 14 with HiveConf

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

the class TestHS2HttpServer method beforeTests.

@BeforeClass
public static void beforeTests() throws Exception {
    webUIPort = MetaStoreUtils.findFreePortExcepting(Integer.valueOf(ConfVars.HIVE_SERVER2_WEBUI_PORT.getDefaultValue()));
    hiveConf = new HiveConf();
    hiveConf.set(ConfVars.METASTOREPWD.varname, metastorePasswd);
    hiveConf.set(ConfVars.HIVE_SERVER2_WEBUI_PORT.varname, webUIPort.toString());
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    hiveServer2 = new HiveServer2();
    hiveServer2.init(hiveConf);
    hiveServer2.start();
    Thread.sleep(5000);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) BeforeClass(org.junit.BeforeClass)

Example 15 with HiveConf

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

the class TestRetryingThriftCLIServiceClient method init.

@Before
public void init() {
    hiveConf = new HiveConf();
    hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, "localhost");
    hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, 15000);
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
    hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_AUTHENTICATION, HiveAuthFactory.AuthTypes.NONE.toString());
    hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_TRANSPORT_MODE, "binary");
    hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_RETRY_LIMIT, 3);
    hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT, 3);
    hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_ASYNC_EXEC_THREADS, 10);
    hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_ASYNC_EXEC_SHUTDOWN_TIMEOUT, "1s");
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) Before(org.junit.Before)

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