Search in sources :

Example 1 with ConnectorManagerException

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.

the class TeiidAdd method buildConnectorManagerRepository.

private ConnectorManagerRepository buildConnectorManagerRepository(final TranslatorRepository translatorRepo) {
    ConnectorManagerRepository cmr = new ConnectorManagerRepository();
    ConnectorManagerRepository.ExecutionFactoryProvider provider = new ConnectorManagerRepository.ExecutionFactoryProvider() {

        HashMap<String, ExecutionFactory<Object, Object>> map = new HashMap<String, ExecutionFactory<Object, Object>>();

        @Override
        public ExecutionFactory<Object, Object> getExecutionFactory(String name) throws ConnectorManagerException {
            VDBTranslatorMetaData translator = translatorRepo.getTranslatorMetaData(name);
            if (translator == null) {
                throw new ConnectorManagerException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50110, name));
            }
            ExecutionFactory<Object, Object> ef = map.get(name);
            if (ef == null) {
                ef = TranslatorUtil.buildDelegateAwareExecutionFactory(translator, this);
                map.put(name, ef);
            }
            return ef;
        }
    };
    cmr.setProvider(provider);
    return cmr;
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) HashMap(java.util.HashMap) ExecutionFactory(org.teiid.translator.ExecutionFactory) TeiidConstants.asString(org.teiid.jboss.TeiidConstants.asString) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData)

Example 2 with ConnectorManagerException

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.

the class TranslatorUtil method getExecutionFactory.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static ExecutionFactory<Object, Object> getExecutionFactory(String name, TranslatorRepository vdbRepo, TranslatorRepository repo, VDBMetaData deployment, IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map, HashSet<String> building) throws ConnectorManagerException {
    if (!building.add(name)) {
        throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40138, building));
    }
    VDBTranslatorMetaData translator = vdbRepo.getTranslatorMetaData(name);
    if (translator == null) {
        translator = repo.getTranslatorMetaData(name);
    }
    if (translator == null) {
        return null;
    }
    ExecutionFactory<Object, Object> ef = map.get(translator);
    if (ef == null) {
        try {
            ef = TranslatorUtil.buildExecutionFactory(translator);
        } catch (TeiidException e) {
            throw new ConnectorManagerException(e);
        }
        if (ef instanceof DelegatingExecutionFactory) {
            DelegatingExecutionFactory delegator = (DelegatingExecutionFactory) ef;
            String delegateName = delegator.getDelegateName();
            if (delegateName != null) {
                ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName, vdbRepo, repo, deployment, map, building);
                if (delegate == null) {
                    if (deployment != null) {
                        throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31146, deployment.getName(), deployment.getVersion(), delegateName));
                    }
                    throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40136, delegateName));
                }
                ((DelegatingExecutionFactory<Object, Object>) ef).setDelegate(delegate);
            }
        }
        map.put(translator, ef);
    }
    return ef;
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) DelegatingExecutionFactory(org.teiid.translator.DelegatingExecutionFactory) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) TeiidException(org.teiid.core.TeiidException)

Example 3 with ConnectorManagerException

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.

the class VDBService method createConnectorManagers.

private void createConnectorManagers(ConnectorManagerRepository cmr, final TranslatorRepository repo, final VDBMetaData deployment) throws StartException {
    final IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map = new IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
    try {
        ConnectorManagerRepository.ExecutionFactoryProvider provider = new ConnectorManagerRepository.ExecutionFactoryProvider() {

            @Override
            public ExecutionFactory<Object, Object> getExecutionFactory(String name) throws ConnectorManagerException {
                return TranslatorUtil.getExecutionFactory(name, repo, getTranslatorRepository(), deployment, map, new HashSet<String>());
            }
        };
        cmr.setProvider(provider);
        cmr.createConnectorManagers(deployment, provider);
    } catch (ConnectorManagerException e) {
        if (e.getCause() != null) {
            // $NON-NLS-1$
            throw new StartException(IntegrationPlugin.Event.TEIID50035.name() + " " + e.getMessage(), e.getCause());
        }
        throw new StartException(e.getMessage());
    }
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) Translator(org.teiid.adminapi.Translator) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) IdentityHashMap(java.util.IdentityHashMap) ExecutionFactory(org.teiid.translator.ExecutionFactory) StartException(org.jboss.msc.service.StartException)

Example 4 with ConnectorManagerException

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.

the class TranslatorUtil method buildDelegateAwareExecutionFactory.

public static ExecutionFactory<Object, Object> buildDelegateAwareExecutionFactory(VDBTranslatorMetaData translator, ExecutionFactoryProvider provider) throws ConnectorManagerException {
    ExecutionFactory<Object, Object> ef = null;
    try {
        ef = buildExecutionFactory(translator);
    } catch (TeiidException e) {
        throw new ConnectorManagerException(e);
    }
    if (ef instanceof DelegatingExecutionFactory) {
        DelegatingExecutionFactory delegator = (DelegatingExecutionFactory) ef;
        String delegateName = delegator.getDelegateName();
        if (delegateName != null) {
            ExecutionFactory<Object, Object> delegate = provider.getExecutionFactory(delegateName);
            if (delegate == null) {
                throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40155, delegateName));
            }
            ((DelegatingExecutionFactory<Object, Object>) ef).setDelegate(delegate);
        }
    }
    return ef;
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) DelegatingExecutionFactory(org.teiid.translator.DelegatingExecutionFactory) TeiidException(org.teiid.core.TeiidException)

Example 5 with ConnectorManagerException

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException in project teiid by teiid.

the class TestVDBStatusChecker method testDataSourceReplaced.

@Test
public void testDataSourceReplaced() throws Exception {
    final VDBRepository repo = new VDBRepository();
    repo.setSystemFunctionManager(RealMetadataFactory.SFM);
    repo.start();
    VDBStatusChecker vsc = new VDBStatusChecker() {

        @Override
        public VDBRepository getVDBRepository() {
            return repo;
        }

        @Override
        public Executor getExecutor() {
            return null;
        }
    };
    VDBTranslatorMetaData factory = new VDBTranslatorMetaData();
    factory.setExecutionFactoryClass(ExecutionFactory.class);
    assertFalse(vsc.dataSourceReplaced("x", "1", "y", "z", "t", "dsName"));
    MetadataStore metadataStore = RealMetadataFactory.exampleBQTCached().getMetadataStore();
    VDBMetaData vdb = TestCompositeVDB.createVDBMetadata(metadataStore, "bqt");
    ConnectorManagerRepository cmr = new ConnectorManagerRepository();
    cmr.setProvider(new ExecutionFactoryProvider() {

        @Override
        public ExecutionFactory<Object, Object> getExecutionFactory(String name) throws ConnectorManagerException {
            return new ExecutionFactory<Object, Object>();
        }
    });
    ExecutionFactory ef1 = new ExecutionFactory();
    ConnectorManager mgr = new ConnectorManager("oracle", "dsName", ef1);
    cmr.addConnectorManager("BQT1", mgr);
    repo.addVDB(vdb, metadataStore, null, null, cmr);
    assertTrue(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "oracle", "dsName1"));
    ExecutionFactory ef = cmr.getConnectorManager("BQT1").getExecutionFactory();
    assertSame(ef, ef1);
    assertFalse(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "sqlserver", "dsName1"));
    ExecutionFactory ef2 = cmr.getConnectorManager("BQT1").getExecutionFactory();
    assertNotNull(ef2);
    assertNotSame(ef, ef2);
    assertTrue(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "oracle", "dsName2"));
    ef = cmr.getConnectorManager("BQT1").getExecutionFactory();
    assertNotNull(ef);
    assertNotSame(ef, ef2);
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) ExecutionFactory(org.teiid.translator.ExecutionFactory) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) MetadataStore(org.teiid.metadata.MetadataStore) ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) ExecutionFactoryProvider(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ExecutionFactoryProvider) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) Test(org.junit.Test)

Aggregations

ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)3 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)3 ExecutionFactory (org.teiid.translator.ExecutionFactory)3 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 TeiidException (org.teiid.core.TeiidException)2 DelegatingExecutionFactory (org.teiid.translator.DelegatingExecutionFactory)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 StartException (org.jboss.msc.service.StartException)1 Test (org.junit.Test)1 Translator (org.teiid.adminapi.Translator)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1