use of org.teiid.adminapi.impl.RequestMetadata in project teiid by teiid.
the class TestDQPCoreRequestHandling method testGetRequestsSessionToken2.
/**
* Test for Collection getRequests(SessionToken) - 1 request
*/
public void testGetRequestsSessionToken2() {
DQPCore rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
Set<RequestID> reqs = new HashSet<RequestID>();
RequestID id = addRequest(rm, SESSION_STRING, 1);
reqs.add(id);
Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(SESSION_STRING);
compareReqInfos(reqs, actualReqs);
}
use of org.teiid.adminapi.impl.RequestMetadata in project teiid by teiid.
the class TestRequestMetadata method testMapping.
@Test
public void testMapping() {
RequestMetadata request = buildRequest();
ModelNode node = VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, new ModelNode());
RequestMetadata actual = VDBMetadataMapper.RequestMetadataMapper.INSTANCE.unwrap(node);
assertEquals(request, actual);
assertEquals(request.getState(), actual.getState());
}
use of org.teiid.adminapi.impl.RequestMetadata 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.adminapi.impl.RequestMetadata 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.adminapi.impl.RequestMetadata 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