Search in sources :

Example 1 with HiveServer2

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

the class ThriftCliServiceMessageSizeTest method setUpBeforeClass.

/**
   * @throws java.lang.Exception
   */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    // Find a free port
    port = MetaStoreUtils.findFreePort();
    hiveServer2 = new HiveServer2();
    hiveConf = new HiveConf();
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) HiveConf(org.apache.hadoop.hive.conf.HiveConf) BeforeClass(org.junit.BeforeClass)

Example 2 with HiveServer2

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

the class ThriftCliServiceMessageSizeTest method testMessageSize.

@Test
public void testMessageSize() throws Exception {
    String transportMode = "binary";
    hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
    hiveConf.setVar(ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, host);
    hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_PORT, port);
    hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, AuthTypes.NONE.toString());
    hiveConf.setVar(ConfVars.HIVE_SERVER2_TRANSPORT_MODE, transportMode);
    HiveServer2 hiveServer2 = new HiveServer2();
    String url = "jdbc:hive2://localhost:" + port + "/default";
    Class.forName("org.apache.hive.jdbc.HiveDriver");
    try {
        // First start HS2 with high message size limit. This should allow connections
        hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_MESSAGE_SIZE, 100 * 1024 * 1024);
        startHiveServer2WithConf(hiveServer2, hiveConf);
        System.out.println("Started Thrift CLI service with message size limit " + hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_MESSAGE_SIZE));
        // With the high message size limit this connection should work
        Connection connection = DriverManager.getConnection(url, "hiveuser", "hive");
        Statement stmt = connection.createStatement();
        assertNotNull("Statement is null", stmt);
        stmt.execute("set hive.support.concurrency = false");
        connection.close();
        stopHiveServer2(hiveServer2);
        // Now start HS2 with low message size limit. This should prevent any connections
        hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_MESSAGE_SIZE, 1);
        hiveServer2 = new HiveServer2();
        startHiveServer2WithConf(hiveServer2, hiveConf);
        System.out.println("Started Thrift CLI service with message size limit " + hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_MAX_MESSAGE_SIZE));
        Exception caughtException = null;
        try {
            // This should fail
            connection = DriverManager.getConnection(url, "hiveuser", "hive");
        } catch (Exception err) {
            caughtException = err;
        }
        // Verify we hit an error while connecting
        assertNotNull(caughtException);
    } finally {
        stopHiveServer2(hiveServer2);
        hiveServer2 = null;
    }
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) Statement(java.sql.Statement) Connection(java.sql.Connection) Test(org.junit.Test)

Example 3 with HiveServer2

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

the class TestServerOptionsProcessor method test.

@Test
public void test() {
    ServerOptionsProcessor optProcessor = new ServerOptionsProcessor("HiveServer2");
    final String key = "testkey";
    final String value = "value123";
    String[] args = { "-hiveconf", key + "=" + value };
    Assert.assertEquals("checking system property before processing options", null, System.getProperty(key));
    optProcessor.parse(args);
    Assert.assertEquals("checking system property after processing options", value, System.getProperty(key));
}
Also used : ServerOptionsProcessor(org.apache.hive.service.server.HiveServer2.ServerOptionsProcessor) Test(org.junit.Test)

Example 4 with HiveServer2

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

the class HiveEmbeddedServer2 method start.

public void start() throws Exception {
    log.info("Starting Hive Local/Embedded Server...");
    if (hiveServer == null) {
        config = configure();
        hiveServer = new HiveServer2();
        port = MetaStoreUtils.findFreePort();
        config.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_PORT, port);
        hiveServer.init(config);
        hiveServer.start();
        waitForStartup();
    }
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2)

Example 5 with HiveServer2

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

the class TestServerSpecificConfig method testServerConfigsEmbeddedMetastore.

/**
 * Verify if appropriate server configuration (metastore, hiveserver2) get
 * loaded when the embedded clients are loaded
 *
 * Checks values used in the configs used for testing.
 *
 * @throws IOException
 * @throws Throwable
 */
@Test
public void testServerConfigsEmbeddedMetastore() throws IOException, Throwable {
    // set hive-site.xml to default hive-site.xml that has embedded metastore
    HiveConf.setHiveSiteLocation(oldDefaultHiveSite);
    HiveConf conf = new HiveConf();
    // check config properties expected with embedded metastore client
    assertTrue(HiveConf.isLoadMetastoreConfig());
    assertEquals("from.hivemetastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.override"));
    assertEquals("from.hivemetastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.metastoresite"));
    assertEquals("from.hive-site.xml", conf.get("hive.dummyparam.test.server.specific.config.hivesite"));
    // verify that hiveserver2 config is not loaded
    assertFalse(HiveConf.isLoadHiveServer2Config());
    assertNull(conf.get("hive.dummyparam.test.server.specific.config.hiveserver2site"));
    // check if hiveserver2 config gets loaded when HS2 is started
    new HiveServer2();
    conf = new HiveConf();
    verifyHS2ConfParams(conf);
    assertEquals("from.hivemetastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.metastoresite"));
}
Also used : HiveServer2(org.apache.hive.service.server.HiveServer2) HiveConf(org.apache.hadoop.hive.conf.HiveConf) Test(org.junit.Test)

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