use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testProcedureUpdateCount.
@Test
public void testProcedureUpdateCount() throws Exception {
// $NON-NLS-1$
String sql = "{? = call TEIIDSP8(1)}";
RequestMessage request = exampleRequestMessage(sql);
request.setResultsMode(ResultsMode.UPDATECOUNT);
request.setStatementType(StatementType.CALLABLE);
ResultsMessage rm = execute("A", 1, request);
assertNull(rm.getException());
assertEquals(1, rm.getResultsList().size());
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testFinalRow.
@Test
public void testFinalRow() throws Exception {
// $NON-NLS-1$
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
String sessionid = "1";
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(10);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(10, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
while (item.isProcessing()) ;
synchronized (item) {
for (int i = 0; i < 100; i++) {
Thread.sleep(10);
}
}
assertEquals(10, item.resultsBuffer.getRowCount());
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testProcedureMaxRows.
/**
* Ensure that the row limit is not misapplied.
* Note that it still could be applied in this example, but the
* resultset only returns a single row
*/
@Test
public void testProcedureMaxRows() throws Exception {
// $NON-NLS-1$
String sql = "{? = call TEIIDSP9(1, ?)}";
RequestMessage request = exampleRequestMessage(sql);
request.setRowLimit(1);
request.setStatementType(StatementType.CALLABLE);
ResultsMessage rm = execute("A", 1, request);
assertNull(rm.getException());
assertEquals(2, rm.getResultsList().size());
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testBufferReuse.
@Test
public void testBufferReuse() throws Exception {
// the sql should return 100 rows
// $NON-NLS-1$
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A, BQT1.SmallA as B ORDER BY A.IntKey";
// $NON-NLS-1$
String userName = "1";
// $NON-NLS-1$
String sessionid = "1";
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
((BufferManagerImpl) core.getBufferManager()).setProcessorBatchSize(1);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
assertNull(rm.getException());
assertEquals(8, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
assertEquals(100, item.resultsBuffer.getRowCount());
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCore method testLobConcurrency.
@Test
public void testLobConcurrency() throws Exception {
RequestMessage reqMsg = exampleRequestMessage("select to_bytes(stringkey, 'utf-8') FROM BQT1.SmallA");
reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF);
agds.setSleep(100);
ResultsFuture<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
final LobThread t = new LobThread(reqMsg);
t.start();
message.addCompletionListener(new ResultsFuture.CompletionListener<ResultsMessage>() {
@Override
public void onCompletion(ResultsFuture<ResultsMessage> future) {
try {
final BlobType bt = (BlobType) future.get().getResultsList().get(0).get(0);
synchronized (t) {
t.bt = bt;
t.workContext = DQPWorkContext.getWorkContext();
t.notify();
}
// give the Thread a chance to run
Thread.sleep(100);
} catch (Exception e) {
t.interrupt();
throw new RuntimeException(e);
}
}
});
message.get();
t.join();
assertNotNull(t.chunkFuture.get().getBytes());
}
Aggregations