use of org.teiid.dqp.message.RequestID in project teiid by teiid.
the class DQPCore method buildRequestInfos.
private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids, long longRunningQueryThreshold) {
List<RequestMetadata> results = new ArrayList<RequestMetadata>();
for (RequestID requestID : ids) {
RequestWorkItem holder = requests.get(requestID);
if (holder != null && !holder.isCanceled() && (longRunningQueryThreshold == -1 || holder.getProcessingTimestamp() < longRunningQueryThreshold)) {
RequestMetadata req = new RequestMetadata();
req.setExecutionId(holder.requestID.getExecutionID());
req.setSessionId(holder.requestID.getConnectionID());
req.setCommand(holder.requestMsg.getCommandString());
req.setStartTime(holder.getProcessingTimestamp());
req.setState(holder.isCanceled() ? ProcessingState.CANCELED : (holder.isDoneProcessing() || holder.isCloseRequested()) ? ProcessingState.DONE : ProcessingState.PROCESSING);
switch(holder.getThreadState()) {
case DONE:
case IDLE:
req.setThreadState(ThreadState.IDLE);
break;
default:
if (holder.isProcessing()) {
req.setThreadState(ThreadState.RUNNING);
} else {
req.setThreadState(ThreadState.QUEUED);
}
}
if (holder.getTransactionContext() != null && holder.getTransactionContext().getTransactionType() != Scope.NONE) {
req.setTransactionId(holder.getTransactionContext().getTransactionId());
}
for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
String connectorName = conInfo.getConnectorName();
if (connectorName == null) {
continue;
}
// If the request has not yet completed processing, then
// add all the subrequest messages
AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
RequestMetadata info = new RequestMetadata();
if (conInfo.isQueued()) {
info.setThreadState(ThreadState.QUEUED);
} else if (conInfo.isRunning()) {
info.setThreadState(ThreadState.RUNNING);
} else {
info.setThreadState(ThreadState.IDLE);
}
info.setExecutionId(arm.getRequestID().getExecutionID());
info.setSessionId(holder.requestID.getConnectionID());
info.setCommand(arm.getCommand().toString());
info.setStartTime(arm.getProcessingTimestamp());
info.setSourceRequest(true);
info.setNodeId(arm.getAtomicRequestID().getNodeID());
info.setState(conInfo.isCanceled() ? ProcessingState.CANCELED : conInfo.isDone() ? ProcessingState.DONE : ProcessingState.PROCESSING);
results.add(info);
}
results.add(req);
}
}
return results;
}
use of org.teiid.dqp.message.RequestID in project teiid by teiid.
the class TestConnectorManager method testRemoveUnknownRequestState.
@Test
public void testRemoveUnknownRequestState() throws Exception {
helpAssureOneState();
// $NON-NLS-1$
csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5));
// $NON-NLS-1$
assertEquals("Expected size of 1", 1, csm.size());
}
use of org.teiid.dqp.message.RequestID in project teiid by teiid.
the class TestConnectorWorkItem method createNewAtomicRequestMessage.
static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(EXAMPLE_BQT, RealMetadataFactory.exampleBQTVDB());
workContext.getSession().setSessionId(String.valueOf(1));
// $NON-NLS-1$
workContext.getSession().setUserName("foo");
AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
// $NON-NLS-1$
request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT));
request.setRequestID(new RequestID(requestid));
// $NON-NLS-1$
request.setConnectorName("testing");
request.setFetchSize(5);
request.setCommandContext(new CommandContext());
return request;
}
use of org.teiid.dqp.message.RequestID in project teiid by teiid.
the class TestDQPCoreRequestHandling method compareReqInfos.
private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestMetadata> reqs2) {
Set<RequestID> reqIDs2 = new HashSet<RequestID>();
for (RequestMetadata requestInfo : reqs2) {
reqIDs2.add(new RequestID(requestInfo.getSessionId(), requestInfo.getExecutionId()));
}
// $NON-NLS-1$
assertEquals("Collections of request infos are not the same: ", new HashSet<RequestID>(reqs1), reqIDs2);
}
use of org.teiid.dqp.message.RequestID in project teiid by teiid.
the class TestDQPCoreRequestHandling method testGetRequestsSessionToken3.
/**
* Test for Collection getRequests(SessionToken) - 3 requests
*/
public void testGetRequestsSessionToken3() {
DQPCore rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
Set<RequestID> reqs = new HashSet<RequestID>();
reqs.add(addRequest(rm, SESSION_STRING, 0));
reqs.add(addRequest(rm, SESSION_STRING, 1));
reqs.add(addRequest(rm, SESSION_STRING, 2));
Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(SESSION_STRING);
compareReqInfos(reqs, actualReqs);
}
Aggregations