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);
}
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());
}
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);
}
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();
}
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;
}
Aggregations