public void createConnectorManager(String sourceName, String translatorName, String jndiName, ExecutionFactoryProvider provider, boolean replace) throws ConnectorManagerException { ConnectorManager cm = getConnectorManager(sourceName); ExecutionFactory<Object, Object> ef = null; if (cm != null) { if (!cm.getTranslatorName().equals(translatorName) || !EquivalenceUtil.areEqual(cm.getConnectionName(), jndiName)) { if (!replace) { throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31103, sourceName)); } if (cm.getTranslatorName().equals(translatorName)) { ef = cm.getExecutionFactory(); } } else { return; } } if (ef == null) { ef = provider.getExecutionFactory(translatorName); if (ef == null) { throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31146, translatorName)); } } cm = createConnectorManager(translatorName, jndiName, ef); addConnectorManager(sourceName, cm); }
public String getStausMessage() { String msg = ""; //$NON-NLS-1$ ExecutionFactory<Object, Object> ef = getExecutionFactory(); if(ef != null) { if (ef.isSourceRequired()) { Object conn = null; try { conn = getConnectionFactory(); } catch (TranslatorException e) { // treat this as connection not found. } if (conn == null) { msg = QueryPlugin.Util.getString("datasource_not_found", this.connectionName); //$NON-NLS-1$ } } } else { msg = QueryPlugin.Util.getString("translator_not_found", this.translatorName); //$NON-NLS-1$ } return msg; }
void helpAssureOneState() throws Exception { csm.registerRequest(request); ConnectorWork state = csm.getState(request.getAtomicRequestID()); assertEquals(state, csm.getState(request.getAtomicRequestID())); }
public SourceCapabilities getCapabilities() throws TranslatorException, TeiidComponentException { if (cachedCapabilities != null) { return cachedCapabilities; } checkStatus(); ExecutionFactory<Object, Object> translator = getExecutionFactory(); synchronized (this) { if (cachedCapabilities != null) { return cachedCapabilities; } ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(translator.getClass().getClassLoader()); cachedCapabilities = buildCapabilities(translator); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } return cachedCapabilities; }
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$ try { this.connectionFactory = this.manager.getConnectionFactory(); } catch (TranslatorException e) { if (this.connector.isSourceRequired()) { throw new TranslatorException(QueryPlugin.Event.TEIID31108, QueryPlugin.Util.getString("datasource_not_found", this.manager.getConnectionName())); //$NON-NLS-1$); unwrapped = ((WrappedConnection)connection).unwrap(); } catch (ResourceException e) { throw new TranslatorException(QueryPlugin.Event.TEIID30477, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30477, this.manager.getConnectionName())); Execution exec = this.requestMsg.getCommandContext().getReusableExecution(this.manager.getId()); if (exec != null) { ((ReusableExecution)exec).reset(translatedCommand, this.securityContext, connection); manager.logSRCCommand(this.requestMsg, this.securityContext, Event.NEW, null, null);
lobStore = null; if (!manager.removeState(this.id)) { return; //already closed LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed execution"}); //$NON-NLS-1$ if (execution instanceof ReusableExecution<?>) { this.requestMsg.getCommandContext().putReusableExecution(this.manager.getId(), (ReusableExecution<?>) execution); manager.logSRCCommand(this.requestMsg, this.securityContext, Event.END, this.rowCount, time);
this.securityContext.setSession(requestMsg.getWorkContext().getSession()); this.connector = manager.getExecutionFactory(); VDBMetaData vdb = requestMsg.getWorkContext().getVDB(); QueryMetadataInterface qmi = vdb.getAttachment(QueryMetadataInterface.class); CommandContext context = requestMsg.getCommandContext(); try { SourceCapabilities capabilities = manager.getCapabilities();
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader()); return method.invoke(item, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } });
Object connectionFactory = null; try { connectionFactory = getConnectionFactory(); throw new TranslatorException(QueryPlugin.Event.TEIID31108, QueryPlugin.Util.getString("datasource_not_found", getConnectionName())); //$NON-NLS-1$); connection = ((WrappedConnection)connection).unwrap(); } catch (Exception e) { throw new TranslatorException(QueryPlugin.Event.TEIID30477, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30477, getConnectionName()));
@Test public void testConvertIn() throws Exception { Command command = helpGetCommand("select intkey from bqt1.smalla where stringkey in ('1', '2')", EXAMPLE_BQT); //$NON-NLS-1$ 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("SELECT SmallA.IntKey FROM SmallA WHERE SmallA.StringKey = '2' OR SmallA.StringKey = '1'", fc.getCommands().get(0).toString()); assertEquals(1, fc.getConnectionCount()); assertEquals(1, fc.getCloseCount()); }
caps = mgr.getCapabilities(); break; } catch(TeiidException e) {
String previousTranslatorName = cr.getTranslatorName(); String previousDsName = cr.getConnectionName();
@Test public void testSourcHints() throws Exception { Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$ command.setSourceHint(new SourceHint()); AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1); arm.setCommand(command); ConnectorManager cm = TestConnectorManager.getConnectorManager(); cm.registerRequest(arm); }
@Test public void testRemoveRequestState() throws Exception { helpAssureOneState(); csm.removeState(request.getAtomicRequestID()); assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$ }
cm.start(); try { cm.getCapabilities(); fail(); } catch (TranslatorException e) { cm.getCapabilities();
private boolean dsExists(String dsName, ConnectorManagerRepository cmr) { String baseDsName = VDBStatusChecker.stripContext(dsName); for (ConnectorManager cm : cmr.getConnectorManagers().values()) { if (baseDsName.equals(VDBStatusChecker.stripContext(cm.getConnectionName()))) { return true; } } return false; }
@Override public Object getConnectionFactory() throws TranslatorException { if (getConnectionName() == null) { return null; } ConnectionFactoryProvider<?> connectionFactoryProvider = connectionFactoryProviders.get(getConnectionName()); if (connectionFactoryProvider != null) { return connectionFactoryProvider.getConnectionFactory(); } return super.getConnectionFactory(); } };
protected ConnectorManager createConnectorManager(String name, String connection, ExecutionFactory<Object, Object> ef) throws ConnectorManagerException { return new ConnectorManager(name, connection, ef); }
public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { checkStatus(); AtomicRequestID atomicRequestId = message.getAtomicRequestID(); LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$ final ConnectorWorkItem item = new ConnectorWorkItem(message, this); ConnectorWork proxy = (ConnectorWork) Proxy.newProxyInstance(ConnectorWork.class.getClassLoader(), new Class[] { ConnectorWork.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader()); return method.invoke(item, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } }); Assertion.isNull(requestStates.put(atomicRequestId, proxy), "State already existed"); //$NON-NLS-1$ return proxy; }
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$ try { this.connectionFactory = this.manager.getConnectionFactory(); } catch (TranslatorException e) { if (this.connector.isSourceRequired()) { throw new TranslatorException(QueryPlugin.Event.TEIID31108, QueryPlugin.Util.getString("datasource_not_found", this.manager.getConnectionName())); //$NON-NLS-1$); unwrapped = ((WrappedConnection)connection).unwrap(); } catch (Exception e) { throw new TranslatorException(QueryPlugin.Event.TEIID30477, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30477, this.manager.getConnectionName())); Execution exec = this.requestMsg.getCommandContext().getReusableExecution(this.manager.getId()); if (exec != null) { ((ReusableExecution)exec).reset(translatedCommand, this.securityContext, connection); manager.logSRCCommand(this, this.requestMsg, this.securityContext, Event.NEW, null, null); if (this.span != null) { scope = TeiidTracingUtil.getInstance().activateSpan(this.span);