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());
}
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());
}
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());
}
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());
}
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);
}
}
Aggregations