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;
}
}
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"));
}
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();
}
}
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");
}
use of org.apache.hive.service.server.HiveServer2 in project hive by apache.
the class ThriftCliServiceTestWithCookie 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();
hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_COOKIE_AUTH_ENABLED, true);
// Set the cookie max age to a very low value so that
// the server sends 401 very frequently
hiveConf.setTimeVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_COOKIE_MAX_AGE, 1, TimeUnit.SECONDS);
hiveConf.setVar(ConfVars.HIVE_SERVER2_TRANSPORT_MODE, "http");
hiveConf.setVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PATH, "cliservice");
assertNotNull(port);
assertNotNull(hiveServer2);
assertNotNull(hiveConf);
hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
hiveConf.setVar(ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, host);
hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, port);
hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, AuthTypes.NOSASL.toString());
startHiveServer2WithConf(hiveConf);
client = getServiceClientInternal();
}
Aggregations