private AtomicRequestMessage createRequest(RequestWorkItem workItem, Command command, String modelName, String connectorBindingId, int nodeID) throws TeiidComponentException { RequestMessage request = workItem.requestMsg; // build the atomic request based on original request + context info AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID); aqr.setCommand(command); aqr.setModelName(modelName); aqr.setMaxResultRows(requestMgr.getMaxSourceRows()); aqr.setExceptionOnMaxRows(requestMgr.isExceptionOnMaxSourceRows()); aqr.setPartialResults(request.supportsPartialResults()); aqr.setSerial(requestMgr.getUserRequestSourceConcurrency() == 1); aqr.setTransactionContext(workItem.getTransactionContext()); aqr.setBufferManager(this.getBufferManager()); if (connectorBindingId == null) { VDBMetaData vdb = workItem.getDqpWorkContext().getVDB(); ModelMetaData model = vdb.getModel(modelName); List<String> bindings = model.getSourceNames(); if (bindings == null || bindings.size() != 1) { // this should not happen, but it did occur when setting up the SystemAdmin models throw new TeiidComponentException(QueryPlugin.Event.TEIID30554, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30554, modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion())); } connectorBindingId = bindings.get(0); Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$ } aqr.setConnectorName(connectorBindingId); return aqr; }
private AtomicRequestMessage createRequest(RequestWorkItem workItem, Command command, String modelName, String connectorBindingId, int nodeID) throws TeiidComponentException { RequestMessage request = workItem.requestMsg; // build the atomic request based on original request + context info AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID); aqr.setCommand(command); aqr.setModelName(modelName); aqr.setMaxResultRows(requestMgr.getMaxSourceRows()); aqr.setExceptionOnMaxRows(requestMgr.isExceptionOnMaxSourceRows()); aqr.setPartialResults(request.supportsPartialResults()); aqr.setSerial(requestMgr.getUserRequestSourceConcurrency() == 1); aqr.setTransactionContext(workItem.getTransactionContext()); aqr.setBufferManager(this.getBufferManager()); if (connectorBindingId == null) { VDBMetaData vdb = workItem.getDqpWorkContext().getVDB(); ModelMetaData model = vdb.getModel(modelName); List<String> bindings = model.getSourceNames(); if (bindings == null || bindings.size() != 1) { // this should not happen, but it did occur when setting up the SystemAdmin models throw new TeiidComponentException(QueryPlugin.Event.TEIID30554, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30554, modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion())); } connectorBindingId = bindings.get(0); Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$ } aqr.setConnectorName(connectorBindingId); return aqr; }
private AtomicRequestMessage createRequest(RequestWorkItem workItem, Command command, String modelName, String connectorBindingId, int nodeID) throws TeiidComponentException { RequestMessage request = workItem.requestMsg; // build the atomic request based on original request + context info AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID); aqr.setCommand(command); aqr.setModelName(modelName); aqr.setMaxResultRows(requestMgr.getMaxSourceRows()); aqr.setExceptionOnMaxRows(requestMgr.isExceptionOnMaxSourceRows()); aqr.setPartialResults(request.supportsPartialResults()); aqr.setSerial(requestMgr.getUserRequestSourceConcurrency() == 1); aqr.setTransactionContext(workItem.getTransactionContext()); aqr.setBufferManager(this.getBufferManager()); if (connectorBindingId == null) { VDBMetaData vdb = workItem.getDqpWorkContext().getVDB(); ModelMetaData model = vdb.getModel(modelName); List<String> bindings = model.getSourceNames(); if (bindings == null || bindings.size() != 1) { // this should not happen, but it did occur when setting up the SystemAdmin models throw new TeiidComponentException(QueryPlugin.Event.TEIID30554, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30554, modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion())); } connectorBindingId = bindings.get(0); Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$ } aqr.setConnectorName(connectorBindingId); return aqr; }
@Ignore @Test public void testIsImmutablePropertySucceeds() 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 TRUE, we should SUCCEED */ ConnectorManager cm = TestConnectorManager.getConnectorManager(); ((FakeConnector)cm.getExecutionFactory()).setImmutable(true); // command must not be a SELECT Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$ 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); }
@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 Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$ 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); }
@Test public void testIsThreadBound() throws Exception { Command command = helpGetCommand("SELECT intkey FROM bqt1.smalla", EXAMPLE_BQT); //$NON-NLS-1$ AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1); TransactionContext tc = new TransactionContext(); tc.setTransactionType(Scope.LOCAL); arm.setTransactionContext(tc); arm.setCommand(command); final FakeConnector c = new FakeConnector() { public boolean supportsMultipleOpenExecutions() { return false; } }; ConnectorManager cm = new ConnectorManager("FakeConnector","FakeConnector") { //$NON-NLS-1$ //$NON-NLS-2$ public ExecutionFactory getExecutionFactory() { return c; } public Object getConnectionFactory(){ return c; } }; cm.start(); ConnectorWorkItem cwi = new ConnectorWorkItem(arm, cm); assertTrue(cwi.isThreadBound()); cwi = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager()); assertFalse(cwi.isThreadBound()); }