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;
}
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;
}
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());
}
}
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;
}
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);
}
Aggregations