Search in sources :

Example 36 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDQPCoreRequestHandling method addRequest.

private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
    // $NON-NLS-1$
    RequestMessage r0 = new RequestMessage("test command");
    RequestID id = new RequestID(sessionId, executionId);
    addRequest(rm, r0, id, null, null);
    return id;
}
Also used : RequestID(org.teiid.dqp.message.RequestID) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage)

Example 37 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestDataTierManager method helpSetupRequest.

private AtomicRequestMessage helpSetupRequest(String sql, int nodeId, QueryMetadataInterface metadata) throws Exception {
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
    Command command = helpGetCommand(sql, metadata);
    RequestMessage original = new RequestMessage();
    original.setExecutionId(id++);
    original.setPartialResults(true);
    RequestID requestID = workContext.getRequestID(original.getExecutionId());
    context = new CommandContext();
    context.setSession(workContext.getSession());
    // $NON-NLS-1$
    context.setVdbName("test");
    context.setVdbVersion(1);
    context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(dtm.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
    workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
    context.setWorkItem(workItem);
    AtomicRequestMessage request = new AtomicRequestMessage(original, workContext, nodeId);
    request.setCommand(command);
    // $NON-NLS-1$
    request.setConnectorName("FakeConnectorID");
    request.setCommandContext(context);
    return request;
}
Also used : RequestID(org.teiid.dqp.message.RequestID) CommandContext(org.teiid.query.util.CommandContext) Command(org.teiid.query.sql.lang.Command) BatchedUpdateCommand(org.teiid.query.sql.lang.BatchedUpdateCommand) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage)

Example 38 with RequestMessage

use of org.teiid.client.RequestMessage 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 39 with RequestMessage

use of org.teiid.client.RequestMessage 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)

Example 40 with RequestMessage

use of org.teiid.client.RequestMessage in project teiid by teiid.

the class TestRequest method testValidateEntitlement.

/**
 * Test Request.validateEntitlement().
 * Make sure that this can be called both before and after metadata is initialized.
 * See defect 17209.
 * @throws Exception
 * @since 4.2
 */
@Test
public void testValidateEntitlement() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    Request request = new Request();
    Command command = QueryParser.getQueryParser().parseCommand(QUERY);
    QueryResolver.resolveCommand(command, metadata);
    RequestMessage message = new RequestMessage();
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
    request.initialize(message, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
    request.initMetadata();
    DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
    DataRolePolicyDecider drpd = new DataRolePolicyDecider();
    drpd.setAllowCreateTemporaryTablesByDefault(true);
    drpd.setAllowFunctionCallsByDefault(true);
    drav.setPolicyDecider(drpd);
    request.setAuthorizationValidator(drav);
    request.validateAccess(new String[] { QUERY }, command, CommandType.USER);
}
Also used : Command(org.teiid.query.sql.lang.Command) RequestMessage(org.teiid.client.RequestMessage) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) Test(org.junit.Test)

Aggregations

RequestMessage (org.teiid.client.RequestMessage)44 ResultsMessage (org.teiid.client.ResultsMessage)23 Test (org.junit.Test)22 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)10 RequestID (org.teiid.dqp.message.RequestID)8 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)6 FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)6 ResultsFuture (org.teiid.client.util.ResultsFuture)5 List (java.util.List)4 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)4 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 TeiidComponentException (org.teiid.core.TeiidComponentException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 Command (org.teiid.query.sql.lang.Command)3 TimeoutException (java.util.concurrent.TimeoutException)2 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)2 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)2 CommandContext (org.teiid.query.util.CommandContext)2 BatchUpdateException (java.sql.BatchUpdateException)1