use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestCompositeVDB method createCompositeVDB.
public static CompositeVDB createCompositeVDB(MetadataStore metadataStore, String vdbName) throws VirtualDatabaseException {
VDBMetaData vdbMetaData = createVDBMetadata(metadataStore, vdbName);
vdbMetaData.addAttchment(Foo.class, new Foo());
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("source", getConnectorManager("FakeTranslator", "FakeConnection", getFuncsOne()));
cmr.addConnectorManager("source2", getConnectorManager("FakeTranslator2", "FakeConnection2", getFuncsTwo()));
CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, null, RealMetadataFactory.SFM.getSystemFunctions(), cmr, null);
cvdb.metadataLoadFinished(true);
assertNotNull(cvdb.getVDB().getAttachment(Foo.class));
return cvdb;
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestCompositeVDB method testImportVisibility.
@Test
public void testImportVisibility() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = RealMetadataFactory.exampleBQTCached().getMetadataStore();
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdb = createVDBMetadata(RealMetadataFactory.exampleBusObjStore(), "example1");
vdb.addProperty("BQT1.visible", "false");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
assertTrue(vdb.isVisible("BQT1"));
vdb = repo.getLiveVDB("example1");
assertFalse(vdb.isVisible("BQT1"));
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestLocalConnections method oneTimeSetup.
@SuppressWarnings("serial")
@BeforeClass
public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
server.setConnectorManagerRepository(new ConnectorManagerRepository() {
@Override
public ConnectorManager getConnectorManager(String connectorName) {
return new ConnectorManager(connectorName, connectorName) {
@Override
public ExecutionFactory<Object, Object> getExecutionFactory() {
return new ExecutionFactory<Object, Object>() {
@Override
public boolean isSourceRequired() {
return false;
}
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
return new ResultSetExecution() {
boolean returnedRow = false;
@Override
public void execute() throws TranslatorException {
lock.lock();
try {
sourceCounter.release();
if (!wait.await(5, TimeUnit.SECONDS)) {
throw new RuntimeException();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
lock.unlock();
}
}
@Override
public void close() {
}
@Override
public void cancel() throws TranslatorException {
}
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (returnedRow) {
return null;
}
returnedRow = true;
return new ArrayList<Object>(Collections.singleton(null));
}
};
}
};
}
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
}
});
FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), false, FunctionMethod.Determinism.NONDETERMINISTIC);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
udfs.put("test", Arrays.asList(function));
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", new DeployVDBParameter(udfs, null));
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestExecutionReuse method oneTimeSetUp.
@BeforeClass
public static void oneTimeSetUp() throws Exception {
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setUserRequestSourceConcurrency(1);
server = new FakeServer(false);
server.setConnectorManagerRepository(new ConnectorManagerRepository() {
private ConnectorManager cm = new ConnectorManager("x", "y") {
private ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object, Object>() {
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
ec = executionContext;
return execution;
}
public boolean isSourceRequired() {
return false;
}
};
@Override
public ExecutionFactory<Object, Object> getExecutionFactory() {
return ef;
}
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
@Override
public ConnectorManager getConnectorManager(String connectorName) {
return cm;
}
});
server.start(config, false);
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestJDBCSocketTransport method testSyncTimeout.
/**
* Tests to ensure that a SynchronousTtl/synchTimeout does
* not cause a cancel.
* TODO: had to increase the values since the test would fail on slow machine runs
* @throws Exception
*/
@Test
public void testSyncTimeout() throws Exception {
TeiidDriver td = new TeiidDriver();
td.setSocketProfile(new ConnectionProfile() {
@Override
public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {
SocketServerConnectionFactory sscf = new SocketServerConnectionFactory();
sscf.initialize(info);
try {
return new ConnectionImpl(sscf.getConnection(info), info, url);
} catch (CommunicationException e) {
throw TeiidSQLException.create(e);
} catch (ConnectionException e) {
throw TeiidSQLException.create(e);
}
}
});
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
ConnectorManagerRepository cmr = server.getConnectorManagerRepository();
AutoGenDataService agds = new AutoGenDataService() {
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
// wait longer than the synch ttl/soTimeout, we should still succeed
agds.setSleep(2000);
cmr.addConnectorManager("source", agds);
try {
conn = td.connect("jdbc:teiid:parts@mm://" + addr.getHostName() + ":" + jdbcTransport.getPort(), p);
Statement s = conn.createStatement();
assertTrue(s.execute("select * from parts"));
} finally {
server.setConnectorManagerRepository(cmr);
}
}
Aggregations