Search in sources :

Example 31 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCore method testUsingFinalBuffer.

@Test
public void testUsingFinalBuffer() throws Exception {
    String sql = "select intkey from bqt1.smalla order by intkey";
    ((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(2);
    agds.sleep = 50;
    RequestMessage reqMsg = exampleRequestMessage(sql);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(10, rm.getResultsList().size());
    message = core.processCursorRequest(reqMsg.getExecutionId(), 3, 2);
    rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(2, rm.getResultsList().size());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 32 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCore method helpTestPlanInvalidation.

private void helpTestPlanInvalidation(String query) throws InterruptedException, ExecutionException, TimeoutException, TeiidProcessingException {
    // $NON-NLS-1$
    String sql = "insert into #temp select * FROM vqt.SmallB";
    // $NON-NLS-1$
    String userName = "1";
    // $NON-NLS-1$
    int sessionid = 1;
    RequestMessage reqMsg = exampleRequestMessage(sql);
    ResultsMessage rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(1, rm.getResultsList().size());
    sql = query;
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setStatementType(StatementType.PREPARED);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    sql = query;
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setStatementType(StatementType.PREPARED);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    assertEquals(1, this.core.getPrepPlanCache().getCacheHitCount());
    Thread.sleep(100);
    // perform a minor update, we should still use the cache
    // $NON-NLS-1$
    sql = "delete from #temp where a12345 = '11'";
    reqMsg = exampleRequestMessage(sql);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(1, rm.getResultsList().size());
    sql = query;
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setStatementType(StatementType.PREPARED);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
    // perform a major update, it might purge the plan
    // $NON-NLS-1$
    sql = "delete from #temp";
    reqMsg = exampleRequestMessage(sql);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(1, rm.getResultsList().size());
    sql = query;
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setStatementType(StatementType.PREPARED);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(0, rm.getResultsList().size());
}
Also used : ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage)

Example 33 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCore method testBufferReuse1.

@Test
public void testBufferReuse1() throws Exception {
    // the sql should return 100 rows
    String sql = "SELECT IntKey FROM texttable('1112131415' columns intkey integer width 2 no row delimiter) t " + "union " + // $NON-NLS-1$
    "SELECT IntKey FROM bqt1.smalla order by intkey";
    // $NON-NLS-1$
    String userName = "1";
    // $NON-NLS-1$
    String sessionid = "1";
    agds.sleep = 50;
    agds.setUseIntCounter(true);
    RequestMessage reqMsg = exampleRequestMessage(sql);
    reqMsg.setRowLimit(11);
    reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
    DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
    DQPWorkContext.getWorkContext().getSession().setUserName(userName);
    BufferManagerImpl bufferManager = (BufferManagerImpl) core.getBufferManager();
    bufferManager.setProcessorBatchSize(20);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(10, rm.getResultsList().size());
    message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
    rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(5, rm.getResultsList().size());
    message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
    rm = message.get(500000, TimeUnit.MILLISECONDS);
    assertNull(rm.getException());
    assertEquals(1, rm.getResultsList().size());
    assertEquals(11, rm.getFirstRow());
    assertEquals(11, rm.getFinalRow());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 34 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCore method testLongRunningQuery.

@Test
public void testLongRunningQuery() throws Exception {
    RequestMessage reqMsg = exampleRequestMessage("select * FROM BQT1.SmallA");
    execute("A", 1, reqMsg);
    this.config.setQueryThresholdInMilli(5000);
    assertEquals(1, this.core.getRequests().size());
    assertEquals(0, this.core.getLongRunningRequests().size());
    this.config.setQueryThresholdInMilli(10);
    Thread.sleep(20);
    assertEquals(1, this.core.getLongRunningRequests().size());
}
Also used : RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 35 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCore method testPlanningException.

/**
 * Tests whether an exception result is sent when an exception occurs
 * @since 4.3
 */
@Test
public void testPlanningException() throws Exception {
    // $NON-NLS-1$
    String sql = "SELECT IntKey FROM BQT1.BadIdea ";
    RequestMessage reqMsg = exampleRequestMessage(sql);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    try {
        message.get(5000, TimeUnit.MILLISECONDS);
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof QueryResolverException);
    }
}
Also used : ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) ExecutionException(java.util.concurrent.ExecutionException) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Aggregations

RequestMessage (org.teiid.client.RequestMessage)44 ResultsMessage (org.teiid.client.ResultsMessage)23 Test (org.junit.Test)22 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)10 RequestID (org.teiid.dqp.message.RequestID)8 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)6 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)6 ResultsFuture (org.teiid.client.util.ResultsFuture)5 List (java.util.List)4 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)4 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 TeiidComponentException (org.teiid.core.TeiidComponentException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 Command (org.teiid.query.sql.lang.Command)3 TimeoutException (java.util.concurrent.TimeoutException)2 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)2 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)2 CommandContext (org.teiid.query.util.CommandContext)2 BatchUpdateException (java.sql.BatchUpdateException)1