Search in sources :

Example 1 with RequestMessage

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

the class TestRequest method testProcessRequestPreparedStatement.

/**
 * Test PreparedStatementRequest.processRequest().
 * Test processing the same query twice, and make sure that doesn't cause problems.
 * @throws Exception
 * @since 4.2
 */
@Test
public void testProcessRequestPreparedStatement() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.PREPAREDPLAN, 0);
    // Try before plan is cached.
    // If this doesn't throw an exception, assume it was successful.
    RequestMessage message = new RequestMessage(QUERY);
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
    message.setStatementType(StatementType.PREPARED);
    message.setParameterValues(new ArrayList<Object>());
    helpProcessMessage(message, cache, workContext);
    // Try again, now that plan is already cached.
    // If this doesn't throw an exception, assume it was successful.
    message = new RequestMessage(QUERY);
    message.setStatementType(StatementType.PREPARED);
    message.setParameterValues(new ArrayList<Object>());
    helpProcessMessage(message, cache, workContext);
}
Also used : RequestMessage(org.teiid.client.RequestMessage) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 2 with RequestMessage

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

the class TestRequest method testProcessRequest.

/**
 * Test Request.processRequest().
 * Test processing the same query twice, and make sure that doesn't cause problems.
 * See defect 17209.
 * @throws Exception
 * @since 4.2
 */
@Test
public void testProcessRequest() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // Try before plan is cached.
    // If this doesn't throw an exception, assume it was successful.
    RequestMessage message = new RequestMessage(QUERY);
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
    helpProcessMessage(message, null, workContext);
    // Try again, now that plan is already cached.
    // If this doesn't throw an exception, assume it was successful.
    message = new RequestMessage(QUERY);
    helpProcessMessage(message, null, workContext);
}
Also used : RequestMessage(org.teiid.client.RequestMessage) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 3 with RequestMessage

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

the class TestDQPCore method testRsCacheInvalidation.

@Test
public void testRsCacheInvalidation() throws Exception {
    // $NON-NLS-1$
    String sql = "select * FROM vqt.SmallB";
    // $NON-NLS-1$
    String userName = "1";
    // $NON-NLS-1$
    int sessionid = 1;
    RequestMessage reqMsg = exampleRequestMessage(sql);
    reqMsg.setUseResultSetCache(true);
    ResultsMessage rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    assertEquals(0, this.core.getRsCache().getCacheHitCount());
    // $NON-NLS-1$
    sql = "select * FROM vqt.SmallB";
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setUseResultSetCache(true);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    assertEquals(1, this.core.getRsCache().getCacheHitCount());
    Thread.sleep(100);
    // $NON-NLS-1$
    sql = "delete from bqt1.smalla";
    reqMsg = exampleRequestMessage(sql);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(1, rm.getResultsList().size());
    // $NON-NLS-1$
    sql = "select * FROM vqt.SmallB";
    reqMsg = exampleRequestMessage(sql);
    reqMsg.setUseResultSetCache(true);
    rm = execute(userName, sessionid, reqMsg);
    // $NON-NLS-1$
    assertEquals(10, rm.getResultsList().size());
    assertEquals(1, this.core.getRsCache().getCacheHitCount());
}
Also used : ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage) Test(org.junit.Test)

Example 4 with RequestMessage

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

the class TestDQPCore method exampleRequestMessage.

public RequestMessage exampleRequestMessage(String sql) {
    RequestMessage msg = new RequestMessage(sql);
    msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
    msg.setFetchSize(10);
    msg.setPartialResults(false);
    msg.setExecutionId(100);
    msg.setExecutionId(id++);
    return msg;
}
Also used : RequestMessage(org.teiid.client.RequestMessage)

Example 5 with RequestMessage

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

the class TestDQPCore method helpTestVisibilityFails.

public void helpTestVisibilityFails(String sql) throws Exception {
    RequestMessage reqMsg = exampleRequestMessage(sql);
    reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF);
    Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
    ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
    // $NON-NLS-1$
    assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString());
}
Also used : ResultsMessage(org.teiid.client.ResultsMessage) RequestMessage(org.teiid.client.RequestMessage)

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