Search in sources :

Example 1 with ConnectorManagerRepository

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

the class TestRequest method helpProcessMessage.

private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws TeiidComponentException, TeiidProcessingException {
    Request request = null;
    if (cache != null) {
        request = new PreparedStatementRequest(cache);
    } else {
        request = new Request();
    }
    ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
    workContext.getVDB().addAttchment(ConnectorManagerRepository.class, repo);
    Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
    request.initialize(message, Mockito.mock(BufferManager.class), new FakeDataManager(), new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
    DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
    request.setAuthorizationValidator(drav);
    request.processRequest();
    return request;
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) FakeDataManager(org.teiid.query.processor.FakeDataManager) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) AutoGenDataService(org.teiid.dqp.service.AutoGenDataService) BufferManager(org.teiid.common.buffer.BufferManager)

Example 2 with ConnectorManagerRepository

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

the class TestDataTierManager method helpSetupDataTierManager.

private void helpSetupDataTierManager() {
    FakeBufferService bs = new FakeBufferService();
    rm = new DQPCore();
    rm.setTransactionService(new FakeTransactionService());
    rm.setBufferManager(bs.getBufferManager());
    CacheConfiguration config = new CacheConfiguration();
    config.setMaxAgeInSeconds(-1);
    rm.setResultsetCache(new SessionAwareCache<CachedResults>("resultset", new DefaultCacheFactory(config), SessionAwareCache.Type.RESULTSET, 0));
    rm.setPreparedPlanCache(new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0));
    rm.start(new DQPConfiguration());
    ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
    Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(connectorManager);
    vdb.addAttchment(ConnectorManagerRepository.class, repo);
    dtm = new DataTierManagerImpl(rm, bs.getBufferManager(), true);
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) FakeBufferService(org.teiid.dqp.service.FakeBufferService) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) CacheConfiguration(org.teiid.cache.CacheConfiguration)

Example 3 with ConnectorManagerRepository

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

the class TestConnectorCapabilitiesFinder method testFindRequiresSource.

@Test
public void testFindRequiresSource() throws Exception {
    // $NON-NLS-1$
    String modelName = "model";
    // $NON-NLS-1$
    String functionName = "fakeFunction";
    ArrayList<String> bindings = new ArrayList<String>();
    bindings.add(modelName);
    VDBMetaData vdb = Mockito.mock(VDBMetaData.class);
    ModelMetaData model = Mockito.mock(ModelMetaData.class);
    Mockito.stub(vdb.getModel(modelName)).toReturn(model);
    Mockito.stub(model.getSourceNames()).toReturn(bindings);
    BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
    basicSourceCapabilities.setFunctionSupport(functionName, true);
    ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
    ConnectorManager cm = Mockito.mock(ConnectorManager.class);
    Mockito.stub(cm.getCapabilities()).toThrow(new TranslatorException());
    Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(cm);
    CachedFinder finder = new CachedFinder(repo, vdb);
    // Test
    SourceCapabilities actual = finder.findCapabilities(modelName);
    // $NON-NLS-1$
    assertNotNull(actual);
    assertFalse(finder.isValid(modelName));
}
Also used : BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ArrayList(java.util.ArrayList) TranslatorException(org.teiid.translator.TranslatorException) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) SourceCapabilities(org.teiid.query.optimizer.capabilities.SourceCapabilities) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 4 with ConnectorManagerRepository

use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository 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 5 with ConnectorManagerRepository

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

the class VDBService method start.

@Override
public void start(final StartContext context) throws StartException {
    ConnectorManagerRepository cmr = new ConnectorManagerRepository();
    TranslatorRepository repo = new TranslatorRepository();
    this.vdb.addAttchment(TranslatorRepository.class, repo);
    // check if this is a VDB with index files, if there are then build the TransformationMetadata
    UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
    // add required connector managers; if they are not already there
    for (Translator t : this.vdb.getOverrideTranslators()) {
        VDBTranslatorMetaData data = (VDBTranslatorMetaData) t;
        String type = data.getType();
        VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
        data.setModuleName(parent.getModuleName());
        data.addAttchment(ClassLoader.class, parent.getAttachment(ClassLoader.class));
        data.setParent(parent);
        repo.addTranslatorMetadata(data.getName(), data);
    }
    createConnectorManagers(cmr, repo, this.vdb);
    final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
    this.vdbListener = new VDBLifeCycleListener() {

        @Override
        public void added(String name, CompositeVDB cvdb) {
        }

        @Override
        public void beforeRemove(String name, CompositeVDB cvdb) {
        }

        @Override
        public void removed(String name, CompositeVDB cvdb) {
        }

        @Override
        public void finishedDeployment(String name, CompositeVDB cvdb) {
            if (!VDBService.this.vdbKey.equals(cvdb.getVDBKey())) {
                return;
            }
            // clear out the indexmetadatarepository as it holds state that is no longer necessary
            // $NON-NLS-1$
            repositories.put("index", new IndexMetadataRepository());
            VDBMetaData vdbInstance = cvdb.getVDB();
            if (vdbInstance.getStatus().equals(Status.ACTIVE)) {
                vdbService.install();
            }
        }
    };
    getVDBRepository().addListener(this.vdbListener);
    MetadataStore store = new MetadataStore();
    try {
        // check to see if there is an index file.  if there is then we assume
        // that index is the default metadata repo
        MetadataRepository<?, ?> defaultRepo = null;
        for (String s : this.vdbResources.getEntriesPlusVisibilities().keySet()) {
            if (s.endsWith(VDBResources.INDEX_EXT)) {
                // $NON-NLS-1$
                defaultRepo = super.getMetadataRepository("index");
                break;
            }
        }
        this.assignMetadataRepositories(vdb, defaultRepo);
        // add transformation metadata to the repository.
        getVDBRepository().addVDB(this.vdb, store, vdbResources.getEntriesPlusVisibilities(), udf, cmr);
    } catch (VirtualDatabaseException e) {
        cleanup(context);
        throw new StartException(e);
    }
    this.vdb.removeAttachment(UDFMetaData.class);
    try {
        loadMetadata(this.vdb, cmr, store, this.vdbResources);
    } catch (TranslatorException e) {
        cleanup(context);
        throw new StartException(e);
    }
    this.runtimeVDB = buildRuntimeVDB(this.vdb, context.getController().getServiceContainer());
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) CompositeVDB(org.teiid.deployers.CompositeVDB) UDFMetaData(org.teiid.deployers.UDFMetaData) TranslatorRepository(org.teiid.dqp.internal.datamgr.TranslatorRepository) IndexMetadataRepository(org.teiid.metadata.index.IndexMetadataRepository) MetadataStore(org.teiid.metadata.MetadataStore) Translator(org.teiid.adminapi.Translator) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBLifeCycleListener(org.teiid.deployers.VDBLifeCycleListener) StartException(org.jboss.msc.service.StartException) TranslatorException(org.teiid.translator.TranslatorException) VirtualDatabaseException(org.teiid.deployers.VirtualDatabaseException) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData)

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