Search in sources :

Example 1 with TSessionHandle

use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.

the class TestHs2ConnectionMetricsHttp method testOpenConnectionMetrics.

@Test
public void testOpenConnectionMetrics() throws Exception {
    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
    TCLIService.Client httpClient = getHttpClient();
    TOpenSessionReq openSessionReq = new TOpenSessionReq();
    TOpenSessionResp tOpenSessionResp = httpClient.OpenSession(openSessionReq);
    // wait a couple of sec to make sure the connection is closed
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 1);
    TSessionHandle sessionHandle = tOpenSessionResp.getSessionHandle();
    TCloseSessionReq closeSessionReq = new TCloseSessionReq(sessionHandle);
    httpClient.CloseSession(closeSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 2);
    tOpenSessionResp = httpClient.OpenSession(openSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 3);
    sessionHandle = tOpenSessionResp.getSessionHandle();
    closeSessionReq = new TCloseSessionReq(sessionHandle);
    httpClient.CloseSession(closeSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 4);
}
Also used : CodahaleMetrics(org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics) TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) TOpenSessionReq(org.apache.hive.service.rpc.thrift.TOpenSessionReq) TOpenSessionResp(org.apache.hive.service.rpc.thrift.TOpenSessionResp) TCloseSessionReq(org.apache.hive.service.rpc.thrift.TCloseSessionReq) TCLIService(org.apache.hive.service.rpc.thrift.TCLIService) Test(org.junit.Test)

Example 2 with TSessionHandle

use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.

the class TestHiveStatement method testSetFetchSizeZeroWithDefault.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. If the value specified is zero, then the hint
 * is ignored. Test for a value of zero (hint is ignored) and a default is
 * specified.
 */
@Test
public void testSetFetchSizeZeroWithDefault() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    // so it falls-back to a value 1000
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle, false, 0, 10)) {
        stmt.setFetchSize(0);
        assertEquals(10, stmt.getFetchSize());
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 3 with TSessionHandle

use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.

the class TestHiveStatement method testSetFetchSizeNegativeValue.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. If the value specified is zero, then the hint
 * is ignored. If the hint is less than zero, an error is thrown.
 *
 * @see Statement#setFetchSize(int)
 */
@Test(expected = SQLException.class)
public void testSetFetchSizeNegativeValue() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
        stmt.setFetchSize(-1);
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 4 with TSessionHandle

use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.

the class TestHiveStatement method testSetFetchSizeJdbcProperty.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. The fetch size can be passed in through the
 * JDBC connection string whereby every created {@code Statement} will start
 * with the fetch size specified if no explicit calls are made.
 *
 * @see Utils.JdbcConnectionParams#FETCH_SIZE
 */
@Test
public void testSetFetchSizeJdbcProperty() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle, false, 4, 1000)) {
        assertEquals(4, stmt.getFetchSize());
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 5 with TSessionHandle

use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.

the class TestHiveStatement method testaddBatch.

@Test(expected = SQLFeatureNotSupportedException.class)
public void testaddBatch() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
        stmt.addBatch(null);
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Aggregations

TSessionHandle (org.apache.hive.service.rpc.thrift.TSessionHandle)9 Test (org.junit.Test)8 Iface (org.apache.hive.service.rpc.thrift.TCLIService.Iface)6 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)2 TOpenSessionReq (org.apache.hive.service.rpc.thrift.TOpenSessionReq)2 TOpenSessionResp (org.apache.hive.service.rpc.thrift.TOpenSessionResp)2 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 CodahaleMetrics (org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics)1 OperationHandle (org.apache.hive.service.cli.OperationHandle)1 TCancelOperationReq (org.apache.hive.service.rpc.thrift.TCancelOperationReq)1 TCloseSessionReq (org.apache.hive.service.rpc.thrift.TCloseSessionReq)1 TExecuteStatementReq (org.apache.hive.service.rpc.thrift.TExecuteStatementReq)1 TExecuteStatementResp (org.apache.hive.service.rpc.thrift.TExecuteStatementResp)1 TStatus (org.apache.hive.service.rpc.thrift.TStatus)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 TTransport (org.apache.thrift.transport.TTransport)1