Search in sources :

Example 6 with RequestMetadata

use of org.teiid.adminapi.impl.RequestMetadata in project teiid by teiid.

the class TestRequestMetadata method buildRequest.

private RequestMetadata buildRequest() {
    RequestMetadata request = new RequestMetadata();
    request.setState(ProcessingState.PROCESSING);
    // $NON-NLS-1$
    request.setCommand("select * from foo");
    request.setExecutionId(1234);
    // $NON-NLS-1$
    request.setName("request-name");
    // $NON-NLS-1$
    request.setSessionId("session-id");
    request.setSourceRequest(false);
    request.setStartTime(12345L);
    // $NON-NLS-1$
    request.setTransactionId("transaction-id");
    request.setThreadState(ThreadState.RUNNING);
    // request.setNodeId(1);
    return request;
}
Also used : RequestMetadata(org.teiid.adminapi.impl.RequestMetadata)

Example 7 with RequestMetadata

use of org.teiid.adminapi.impl.RequestMetadata in project teiid by teiid.

the class TestEmbeddedServerAdmin method testGetRequests.

@SuppressWarnings("unchecked")
@Test
public void testGetRequests() throws AdminException, SQLException {
    Connection conn = newSession();
    Statement stmt = conn.createStatement();
    String command = "SELECT * FROM helloworld";
    ResultSet rs = stmt.executeQuery(command);
    List<RequestMetadata> requests = (List<RequestMetadata>) admin.getRequests();
    assertEquals(1, requests.size());
    assertEquals(command, requests.get(0).getCommand());
    assertNotNull(requests.get(0).getSessionId());
    rs.close();
    stmt.close();
    conn.close();
}
Also used : Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) List(java.util.List) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata) Test(org.junit.Test)

Example 8 with RequestMetadata

use of org.teiid.adminapi.impl.RequestMetadata in project teiid by teiid.

the class TestODBCSocketTransport method testImplicitPortalClosing.

@Test
public void testImplicitPortalClosing() throws Exception {
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery("select session_id()");
    rs.next();
    String id = rs.getString(1);
    statement.close();
    PreparedStatement s = conn.prepareStatement("select 1");
    s.executeQuery();
    s.executeQuery();
    s.executeQuery();
    // due to asynch close, there may be several requests
    int runningCount = 0;
    for (RequestMetadata request : odbcServer.server.getDqp().getRequestsForSession(id)) {
        if (request.getState() == ProcessingState.PROCESSING) {
            runningCount++;
        }
    }
    assertEquals(1, runningCount);
    s.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata) Test(org.junit.Test)

Aggregations

RequestMetadata (org.teiid.adminapi.impl.RequestMetadata)8 RequestID (org.teiid.dqp.message.RequestID)4 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ModelNode (org.jboss.dmr.ModelNode)1 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)1