Search in sources :

Example 1 with CacheConfiguration

use of org.teiid.cache.CacheConfiguration 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 2 with CacheConfiguration

use of org.teiid.cache.CacheConfiguration in project teiid by teiid.

the class TestMetaDataProcessor method helpTestQuery.

private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql, VDBMetaData vdb) throws Exception {
    // Create components
    SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0);
    // Initialize components
    MetaDataProcessor mdProc = new MetaDataProcessor(new DQPCore(), prepPlanCache, "MyVDB", 1);
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
    return mdProc.processMessage(workContext.getRequestID(1), workContext, sql, true);
}
Also used : DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) CacheConfiguration(org.teiid.cache.CacheConfiguration)

Example 3 with CacheConfiguration

use of org.teiid.cache.CacheConfiguration in project teiid by teiid.

the class TestDQPCore method setUp.

@Before
public void setUp() throws Exception {
    agds = new AutoGenDataService();
    DQPWorkContext context = RealMetadataFactory.buildWorkContext(RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.exampleBQTCached().getMetadataStore(), "bqt"));
    // $NON-NLS-1$
    context.getVDB().getModel("BQT3").setVisible(false);
    // $NON-NLS-1$
    context.getVDB().getModel("VQT").setVisible(false);
    HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
    policies.put("foo", new DataPolicyMetadata());
    context.setPolicies(policies);
    ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
    context.getVDB().addAttchment(ConnectorManagerRepository.class, repo);
    Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(agds);
    BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
    bm.setInlineLobs(false);
    FakeBufferService bs = new FakeBufferService(bm, bm);
    core = new DQPCore();
    core.setBufferManager(bs.getBufferManager());
    core.setResultsetCache(new SessionAwareCache<CachedResults>("resultset", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.RESULTSET, 0));
    core.setPreparedPlanCache(new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0));
    core.setTransactionService(new FakeTransactionService());
    config = new DQPConfiguration();
    config.setMaxActivePlans(1);
    config.setUserRequestSourceConcurrency(2);
    DefaultAuthorizationValidator daa = new DefaultAuthorizationValidator();
    daa.setPolicyDecider(new DataRolePolicyDecider());
    config.setAuthorizationValidator(daa);
    core.start(config);
    core.getPrepPlanCache().setModTime(1);
    core.getRsCache().setTupleBufferCache(bs.getBufferManager());
}
Also used : BufferManagerImpl(org.teiid.common.buffer.impl.BufferManagerImpl) HashMap(java.util.HashMap) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) FakeBufferService(org.teiid.dqp.service.FakeBufferService) DataPolicyMetadata(org.teiid.adminapi.impl.DataPolicyMetadata) DataPolicy(org.teiid.adminapi.DataPolicy) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) AutoGenDataService(org.teiid.dqp.service.AutoGenDataService) CacheConfiguration(org.teiid.cache.CacheConfiguration) Before(org.junit.Before)

Example 4 with CacheConfiguration

use of org.teiid.cache.CacheConfiguration in project teiid by teiid.

the class TestMetaDataProcessor method helpGetMetadata.

public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception {
    // Prepare sql
    Command command = QueryParser.getQueryParser().parseCommand(sql);
    QueryResolver.resolveCommand(command, metadata);
    // Create components
    SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0);
    DQPCore requestMgr = new DQPCore();
    requestMgr.setTransactionService(new FakeTransactionService());
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
    // Initialize components
    RequestID requestID = workContext.getRequestID(1);
    RequestMessage requestMsg = new RequestMessage(sql);
    TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null);
    MetaDataProcessor mdProc = new MetaDataProcessor(requestMgr, prepPlanCache, "MyVDB", 1);
    return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
}
Also used : RequestID(org.teiid.dqp.message.RequestID) Command(org.teiid.query.sql.lang.Command) DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) RequestMessage(org.teiid.client.RequestMessage) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) CacheConfiguration(org.teiid.cache.CacheConfiguration)

Example 5 with CacheConfiguration

use of org.teiid.cache.CacheConfiguration in project teiid by teiid.

the class TestPreparedPlanCache method testNegativeSizeCacheUsesDefault.

// set init size to negative number, which should default to max
@Test
public void testNegativeSizeCacheUsesDefault() {
    CacheConfiguration config = new CacheConfiguration();
    config.setMaxEntries(-1);
    new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0);
// -1 means unlimited in the infinispan
}
Also used : DefaultCacheFactory(org.teiid.cache.DefaultCacheFactory) CacheConfiguration(org.teiid.cache.CacheConfiguration) Test(org.junit.Test)

Aggregations

CacheConfiguration (org.teiid.cache.CacheConfiguration)5 DefaultCacheFactory (org.teiid.cache.DefaultCacheFactory)5 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)3 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)2 FakeBufferService (org.teiid.dqp.service.FakeBufferService)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataPolicy (org.teiid.adminapi.DataPolicy)1 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)1 RequestMessage (org.teiid.client.RequestMessage)1 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)1 RequestID (org.teiid.dqp.message.RequestID)1 AutoGenDataService (org.teiid.dqp.service.AutoGenDataService)1 Command (org.teiid.query.sql.lang.Command)1