Search in sources :

Example 6 with FakeTransactionService

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

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

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

the class TestDQPCoreRequestHandling method testGetRequestsSessionToken3.

/**
 * Test for Collection getRequests(SessionToken) - 3 requests
 */
public void testGetRequestsSessionToken3() {
    DQPCore rm = new DQPCore();
    rm.setTransactionService(new FakeTransactionService());
    Set<RequestID> reqs = new HashSet<RequestID>();
    reqs.add(addRequest(rm, SESSION_STRING, 0));
    reqs.add(addRequest(rm, SESSION_STRING, 1));
    reqs.add(addRequest(rm, SESSION_STRING, 2));
    Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(SESSION_STRING);
    compareReqInfos(reqs, actualReqs);
}
Also used : RequestID(org.teiid.dqp.message.RequestID) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) HashSet(java.util.HashSet) RequestMetadata(org.teiid.adminapi.impl.RequestMetadata)

Example 9 with FakeTransactionService

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

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

the class TestPreparedStatement method helpGetProcessorPlan.

static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List<?> values, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb) throws TeiidComponentException, TeiidProcessingException {
    // Create Request
    RequestMessage request = new RequestMessage(preparedSql);
    if (callableStatement) {
        request.setStatementType(StatementType.CALLABLE);
    } else {
        request.setStatementType(StatementType.PREPARED);
    }
    request.setParameterValues(values);
    if (values != null && values.size() > 0 && values.get(0) instanceof List) {
        request.setBatchedUpdate(true);
    }
    if (limitResults) {
        request.setRowLimit(1);
    }
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
    workContext.getSession().setSessionId(String.valueOf(conn));
    PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache);
    ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
    Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
    serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, workContext, prepPlanCache);
    serverRequest.setMetadata(capFinder, metadata);
    DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
    serverRequest.setAuthorizationValidator(drav);
    serverRequest.processRequest();
    assertNotNull(serverRequest.processPlan);
    return serverRequest;
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) RequestMessage(org.teiid.client.RequestMessage) ArrayList(java.util.ArrayList) List(java.util.List) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) AutoGenDataService(org.teiid.dqp.service.AutoGenDataService)

Aggregations

FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)11 RequestMessage (org.teiid.client.RequestMessage)6 RequestID (org.teiid.dqp.message.RequestID)6 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)4 CacheConfiguration (org.teiid.cache.CacheConfiguration)3 DefaultCacheFactory (org.teiid.cache.DefaultCacheFactory)3 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)3 AutoGenDataService (org.teiid.dqp.service.AutoGenDataService)3 HashSet (java.util.HashSet)2 RequestMetadata (org.teiid.adminapi.impl.RequestMetadata)2 FakeBufferService (org.teiid.dqp.service.FakeBufferService)2 Command (org.teiid.query.sql.lang.Command)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataPolicy (org.teiid.adminapi.DataPolicy)1 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)1 BufferManager (org.teiid.common.buffer.BufferManager)1