Search in sources :

Example 11 with HiveServer2

use of org.apache.hive.service.server.HiveServer2 in project hive by apache.

the class TestCustomAuthentication method setUp.

@BeforeClass
public static void setUp() throws Exception {
    hiveConf = new HiveConf();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    hiveConf.writeXml(baos);
    baos.close();
    hiveConfBackup = baos.toByteArray();
    hiveConf.set("hive.server2.authentication", "CUSTOM");
    hiveConf.set("hive.server2.custom.authentication.class", "org.apache.hive.service.auth.TestCustomAuthentication$SimpleAuthenticationProviderImpl");
    FileOutputStream fos = new FileOutputStream(new File(hiveConf.getHiveSiteLocation().toURI()));
    hiveConf.writeXml(fos);
    fos.close();
    hiveserver2 = new HiveServer2();
    hiveserver2.init(hiveConf);
    hiveserver2.start();
    Thread.sleep(1000);
    System.out.println("hiveServer2 start ......");
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) FileOutputStream(java.io.FileOutputStream) HiveConf(org.apache.hadoop.hive.conf.HiveConf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 12 with HiveServer2

use of org.apache.hive.service.server.HiveServer2 in project hive by apache.

the class TestRetryingThriftCLIServiceClient method startHiveServer.

private void startHiveServer() throws InterruptedException {
    // Start hive server2
    server = new HiveServer2();
    server.init(hiveConf);
    server.start();
    Thread.sleep(5000);
    System.out.println("## HiveServer started");
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2)

Example 13 with HiveServer2

use of org.apache.hive.service.server.HiveServer2 in project hive by apache.

the class TestHs2Hooks method setUpBeforeClass.

/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    HiveConf hiveConf = new HiveConf();
    hiveConf.setVar(ConfVars.PREEXECHOOKS, PreExecHook.class.getName());
    hiveConf.setVar(ConfVars.POSTEXECHOOKS, PostExecHook.class.getName());
    hiveConf.setVar(ConfVars.SEMANTIC_ANALYZER_HOOK, SemanticAnalysisHook.class.getName());
    hiveConf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    hiveServer2 = new HiveServer2();
    hiveServer2.init(hiveConf);
    hiveServer2.start();
    Thread.sleep(2000);
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) HiveConf(org.apache.hadoop.hive.conf.HiveConf) BeforeClass(org.junit.BeforeClass)

Example 14 with HiveServer2

use of org.apache.hive.service.server.HiveServer2 in project hive by apache.

the class TestServerSpecificConfig method testHiveMetastoreRemoteConfig.

/**
 * Test to ensure that HiveConf does not try to load hivemetastore-site.xml,
 * when remote metastore is used.
 *
 * @throws IOException
 * @throws Throwable
 */
@Test
public void testHiveMetastoreRemoteConfig() throws IOException, Throwable {
    // switch to hive-site.xml with remote metastore
    setHiveSiteWithRemoteMetastore();
    // Set HiveConf statics to default values
    resetDefaults();
    // create hiveconf again to run initialization code, to see if value changes
    HiveConf conf = new HiveConf();
    // check the properties expected in hive client without metastore
    verifyMetastoreConfNotLoaded(conf);
    assertEquals("from.hive-site.xml", conf.get("hive.dummyparam.test.server.specific.config.override"));
    // get HS2 site.xml loaded
    new HiveServer2();
    conf = new HiveConf();
    verifyHS2ConfParams(conf);
    verifyMetastoreConfNotLoaded(conf);
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Test(org.junit.Test)

Example 15 with HiveServer2

use of org.apache.hive.service.server.HiveServer2 in project hive by apache.

the class MiniHS2 method start.

public void start(Map<String, String> confOverlay) throws Exception {
    if (isMetastoreRemote) {
        MetaStoreTestUtils.startMetaStoreWithRetry(getHiveConf());
    }
    // Set confOverlay parameters
    for (Map.Entry<String, String> entry : confOverlay.entrySet()) {
        setConfProperty(entry.getKey(), entry.getValue());
    }
    Exception hs2Exception = null;
    boolean hs2Started = false;
    for (int tryCount = 0; (tryCount < MetaStoreTestUtils.RETRY_COUNT); tryCount++) {
        try {
            hiveServer2 = new HiveServer2();
            if (pamAuthenticator != null) {
                hiveServer2.setPamAuthenticator(pamAuthenticator);
            }
            hiveServer2.init(getHiveConf());
            hiveServer2.start();
            hs2Started = true;
            break;
        } catch (Exception t) {
            hs2Exception = t;
            if (usePortsFromConf) {
                hs2Started = false;
                break;
            } else {
                HiveConf.setIntVar(getHiveConf(), HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, MetaStoreTestUtils.findFreePort());
                HiveConf.setIntVar(getHiveConf(), HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, MetaStoreTestUtils.findFreePort());
            }
        }
    }
    if (!hs2Started) {
        throw (hs2Exception);
    }
    waitForStartup();
    setStarted(true);
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) HashMap(java.util.HashMap) Map(java.util.Map) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

HiveServer2 (org.apache.hive.service.server.HiveServer2)15 HiveConf (org.apache.hadoop.hive.conf.HiveConf)9 BeforeClass (org.junit.BeforeClass)6 Test (org.junit.Test)6 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ServletContext (javax.servlet.ServletContext)1 ServerOptionsProcessor (org.apache.hive.service.server.HiveServer2.ServerOptionsProcessor)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1