Search in sources :

Example 26 with ConnectorManagerRepository

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;
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Example 27 with ConnectorManagerRepository

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"));
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Example 28 with ConnectorManagerRepository

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));
}
Also used : HashMap(java.util.HashMap) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) Execution(org.teiid.translator.Execution) ResultSetExecution(org.teiid.translator.ResultSetExecution) FunctionMethod(org.teiid.metadata.FunctionMethod) List(java.util.List) ArrayList(java.util.ArrayList) DataNotAvailableException(org.teiid.translator.DataNotAvailableException) FunctionParameter(org.teiid.metadata.FunctionParameter) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) ExecutionFactory(org.teiid.translator.ExecutionFactory) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) ResultSetExecution(org.teiid.translator.ResultSetExecution) ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) Collection(java.util.Collection) TranslatorException(org.teiid.translator.TranslatorException) BeforeClass(org.junit.BeforeClass)

Example 29 with ConnectorManagerRepository

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");
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) EmbeddedConfiguration(org.teiid.runtime.EmbeddedConfiguration) ExecutionFactory(org.teiid.translator.ExecutionFactory) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) ResultSetExecution(org.teiid.translator.ResultSetExecution) ExecutionContext(org.teiid.translator.ExecutionContext) TranslatorException(org.teiid.translator.TranslatorException) QueryExpression(org.teiid.language.QueryExpression) BeforeClass(org.junit.BeforeClass)

Example 30 with ConnectorManagerRepository

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);
    }
}
Also used : SocketServerConnectionFactory(org.teiid.net.socket.SocketServerConnectionFactory) CommunicationException(org.teiid.net.CommunicationException) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ConnectionProfile(org.teiid.jdbc.ConnectionProfile) ConnectionImpl(org.teiid.jdbc.ConnectionImpl) Properties(java.util.Properties) TeiidDriver(org.teiid.jdbc.TeiidDriver) AutoGenDataService(org.teiid.dqp.service.AutoGenDataService) ConnectionException(org.teiid.net.ConnectionException) Test(org.junit.Test)

Aggregations

ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)30 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)15 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)14 Test (org.junit.Test)9 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)9 MetadataStore (org.teiid.metadata.MetadataStore)8 ArrayList (java.util.ArrayList)5 ExecutionFactory (org.teiid.translator.ExecutionFactory)5 TranslatorException (org.teiid.translator.TranslatorException)5 AdminProcessingException (org.teiid.adminapi.AdminProcessingException)4 SourceMappingMetadata (org.teiid.adminapi.impl.SourceMappingMetadata)4 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)4 AutoGenDataService (org.teiid.dqp.service.AutoGenDataService)4 HashMap (java.util.HashMap)3 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)3 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)3 ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)3 List (java.util.List)2 BeforeClass (org.junit.BeforeClass)2 DataPolicy (org.teiid.adminapi.DataPolicy)2