Search in sources :

Example 11 with RequestID

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;
}
Also used : RequestID(org.teiid.dqp.message.RequestID) ArrayList(java.util.ArrayList) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata)

Example 12 with RequestID

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());
}
Also used : AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) RequestID(org.teiid.dqp.message.RequestID) AtomicRequestID(org.teiid.dqp.message.AtomicRequestID) Test(org.junit.Test)

Example 13 with RequestID

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;
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) RequestID(org.teiid.dqp.message.RequestID) CommandContext(org.teiid.query.util.CommandContext) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage)

Example 14 with RequestID

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);
}
Also used : RequestID(org.teiid.dqp.message.RequestID) HashSet(java.util.HashSet) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata)

Example 15 with RequestID

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);
}
Also used : RequestID(org.teiid.dqp.message.RequestID) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) HashSet(java.util.HashSet) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata)

Aggregations

RequestID (org.teiid.dqp.message.RequestID)25 RequestMessage (org.teiid.client.RequestMessage)8 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)8 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)6 RequestMetadata (org.teiid.adminapi.impl.RequestMetadata)4 HashSet (java.util.HashSet)3 TeiidComponentException (org.teiid.core.TeiidComponentException)2 QueryProcessor (org.teiid.query.processor.QueryProcessor)2 Command (org.teiid.query.sql.lang.Command)2 CommandContext (org.teiid.query.util.CommandContext)2 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 PreParser (org.teiid.PreParser)1 CacheConfiguration (org.teiid.cache.CacheConfiguration)1 DefaultCacheFactory (org.teiid.cache.DefaultCacheFactory)1 ResultsMessage (org.teiid.client.ResultsMessage)1 PlanNode (org.teiid.client.plan.PlanNode)1 ResultsFuture (org.teiid.client.util.ResultsFuture)1 DQPWorkContext (org.teiid.dqp.internal.process.DQPWorkContext)1