Search in sources :

Example 16 with AtomicRequestMessage

use of org.teiid.dqp.message.AtomicRequestMessage in project teiid by teiid.

the class TestConnectorWorkItem method testSourceNotRequired.

@Test
public void testSourceNotRequired() throws Exception {
    // $NON-NLS-1$
    Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT);
    AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
    arm.setCommand(command);
    ConnectorManager cm = TestConnectorManager.getConnectorManager();
    cm.getExecutionFactory().setSourceRequired(false);
    ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm);
    synchConnectorWorkItem.execute();
    synchConnectorWorkItem.close();
    FakeConnector fc = (FakeConnector) cm.getExecutionFactory();
    assertEquals(1, fc.getConnectionCount());
    assertEquals(1, fc.getCloseCount());
}
Also used : Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) Test(org.junit.Test)

Example 17 with AtomicRequestMessage

use of org.teiid.dqp.message.AtomicRequestMessage in project teiid by teiid.

the class TestConnectorWorkItem method testIsImmutablePropertyFails.

@Ignore
@Test(expected = TranslatorException.class)
public void testIsImmutablePropertyFails() throws Exception {
    /*
    	 * Setup:
    	 *  1. requestMsg.isTransactional() must be TRUE 
    	 *  2. manager.isXa() must be FALSE  ()
    	 *  3. command must NOT be a SELECT
    	 *  4. Then, set isImmutable to FALSE, and we should FAIL
    	 */
    ConnectorManager cm = TestConnectorManager.getConnectorManager();
    ((FakeConnector) cm.getExecutionFactory()).setImmutable(false);
    // command must not be a SELECT
    // $NON-NLS-1$
    Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT);
    AtomicRequestMessage requestMsg = createNewAtomicRequestMessage(1, 1);
    requestMsg.setCommand(command);
    // To make the AtomicRequestMessage transactional, construct your own
    requestMsg.setTransactionContext(new TransactionContext() {

        @Override
        public Xid getXid() {
            return Mockito.mock(Xid.class);
        }
    });
    new ConnectorWorkItem(requestMsg, cm);
}
Also used : Xid(javax.transaction.xa.Xid) Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) TransactionContext(org.teiid.dqp.service.TransactionContext) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with AtomicRequestMessage

use of org.teiid.dqp.message.AtomicRequestMessage in project teiid by teiid.

the class TestDataTierManager method helpSetupRequest.

private AtomicRequestMessage helpSetupRequest(String sql, int nodeId, QueryMetadataInterface metadata) throws Exception {
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
    Command command = helpGetCommand(sql, metadata);
    RequestMessage original = new RequestMessage();
    original.setExecutionId(id++);
    original.setPartialResults(true);
    RequestID requestID = workContext.getRequestID(original.getExecutionId());
    context = new CommandContext();
    context.setSession(workContext.getSession());
    // $NON-NLS-1$
    context.setVdbName("test");
    context.setVdbVersion(1);
    context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(dtm.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
    workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
    context.setWorkItem(workItem);
    AtomicRequestMessage request = new AtomicRequestMessage(original, workContext, nodeId);
    request.setCommand(command);
    // $NON-NLS-1$
    request.setConnectorName("FakeConnectorID");
    request.setCommandContext(context);
    return request;
}
Also used : RequestID(org.teiid.dqp.message.RequestID) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage)

Aggregations

AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)18 Test (org.junit.Test)9 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)8 Command (org.teiid.query.sql.lang.Command)8 RequestMessage (org.teiid.client.RequestMessage)5 RequestID (org.teiid.dqp.message.RequestID)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 BufferManager (org.teiid.common.buffer.BufferManager)3 AtomicResultsMessage (org.teiid.dqp.message.AtomicResultsMessage)3 QueryExpression (org.teiid.language.QueryExpression)3 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)3 Xid (javax.transaction.xa.Xid)2 Ignore (org.junit.Ignore)2 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)2 TransactionContext (org.teiid.dqp.service.TransactionContext)2 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)2 CommandContext (org.teiid.query.util.CommandContext)2 ExecutionContext (org.teiid.translator.ExecutionContext)2 ExecutionFactory (org.teiid.translator.ExecutionFactory)2