Package org.teiid.client

Examples of org.teiid.client.ResultsMessage


        reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
        DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
        DQPWorkContext.getWorkContext().getSession().setUserName(userName);
        ((BufferManagerImpl)core.getBufferManager()).setProcessorBatchSize(2);
        Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
        ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
        assertNull(rm.getException());
        assertEquals(2, rm.getResults().length);
        RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
        assertEquals(100, item.resultsBuffer.getRowCount());
    }
View Full Code Here


    @Test public void testPreparedPlanInvalidation() throws Exception {
        String sql = "insert into #temp select * FROM vqt.SmallB"; //$NON-NLS-1$
        String userName = "1"; //$NON-NLS-1$
        int sessionid = 1; //$NON-NLS-1$
        RequestMessage reqMsg = exampleRequestMessage(sql);
        ResultsMessage rm = execute(userName, sessionid, reqMsg);
        assertEquals(1, rm.getResults().length); //$NON-NLS-1$
       
        sql = "select * from #temp"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setStatementType(StatementType.PREPARED);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
       
        sql = "select * from #temp"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setStatementType(StatementType.PREPARED);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
       
        assertEquals(1, this.core.getPrepPlanCache().getCacheHitCount());

        Thread.sleep(100);

        //perform a minor update, we should still use the cache
        sql = "delete from #temp where a12345 = '11'"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(1, rm.getResults().length); //$NON-NLS-1$

        sql = "select * from #temp"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setStatementType(StatementType.PREPARED);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
       
        assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());

        //perform a major update, we will purge the plan
        sql = "delete from #temp"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(1, rm.getResults().length); //$NON-NLS-1$
       
        sql = "select * from #temp"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setStatementType(StatementType.PREPARED);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(0, rm.getResults().length); //$NON-NLS-1$
       
        assertEquals(2, this.core.getPrepPlanCache().getCacheHitCount());
    }
View Full Code Here

        String sql = "select * FROM vqt.SmallB"; //$NON-NLS-1$
        String userName = "1"; //$NON-NLS-1$
        int sessionid = 1; //$NON-NLS-1$
        RequestMessage reqMsg = exampleRequestMessage(sql);
        reqMsg.setUseResultSetCache(true);
        ResultsMessage rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
               
        sql = "select * FROM vqt.SmallB"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setUseResultSetCache(true);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
       
        assertEquals(1, this.core.getRsCache().getCacheHitCount());

        Thread.sleep(100);

        sql = "delete from bqt1.smalla"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(1, rm.getResults().length); //$NON-NLS-1$
       
        sql = "select * FROM vqt.SmallB"; //$NON-NLS-1$
        reqMsg = exampleRequestMessage(sql);
        reqMsg.setUseResultSetCache(true);
        rm = execute(userName, sessionid, reqMsg);
        assertEquals(10, rm.getResults().length); //$NON-NLS-1$
       
        assertEquals(1, this.core.getRsCache().getCacheHitCount());
    }
View Full Code Here

   
  public void helpTestVisibilityFails(String sql) throws Exception {
        RequestMessage reqMsg = exampleRequestMessage(sql);
        reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF);
        Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
        ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
        assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
  }
View Full Code Here

    private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
        RequestMessage reqMsg = exampleRequestMessage(sql);
        if (txnAutoWrap) {
          reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_ON);
        }
        ResultsMessage results = execute(userName, sessionid, reqMsg);
        core.terminateSession(String.valueOf(sessionid));
        assertNull(core.getClientState(String.valueOf(sessionid), false));
        if (results.getException() != null) {
          throw results.getException();
        }
        return results;
    }
View Full Code Here

    DQPWorkContext.getWorkContext().getSession().setSessionId(String.valueOf(sessionid));
        DQPWorkContext.getWorkContext().getSession().setUserName(userName);

        Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
        assertNotNull(core.getClientState(String.valueOf(sessionid), false));
        ResultsMessage results = message.get(500000, TimeUnit.MILLISECONDS);
    return results;
  }
View Full Code Here

  /**
   * Send results if they have been requested.  This should only be called from the processing thread.
   */
  protected boolean sendResultsIfNeeded(TupleBatch batch) throws TeiidComponentException {
    ResultsMessage response = null;
    ResultsReceiver<ResultsMessage> receiver = null;
    boolean result = true;
    synchronized (this) {
      if (this.resultsReceiver == null
          || (this.begin > (batch != null?batch.getEndRow():this.resultsBuffer.getRowCount()) && !doneProducingBatches)
          || (this.transactionState == TransactionState.ACTIVE)) {
        return result;
      }
   
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
        LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID:", requestID, "resultsID:", this.resultsBuffer, "done:", doneProducingBatches );   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
 
      //TODO: support fetching more than 1 batch
      boolean fromBuffer = false;
        if (batch == null || !(batch.containsRow(this.begin) || (batch.getTerminationFlag() && batch.getEndRow() <= this.begin))) {
          if (savedBatch != null && savedBatch.containsRow(this.begin)) {
            batch = savedBatch;
          } else {
            batch = resultsBuffer.getBatch(begin);
          }
          savedBatch = null;
          fromBuffer = true;
        }
        int count = this.end - this.begin + 1;
        if (batch.getRowCount() > count) {
          int beginRow = Math.min(this.begin, batch.getEndRow() - count + 1);
          int endRow = Math.min(beginRow + count - 1, batch.getEndRow());
          boolean last = false;
          if (endRow == batch.getEndRow()) {
            last = batch.getTerminationFlag();
          } else if (fromBuffer && isForwardOnly()) {
              savedBatch = batch;
          }
                List<List<?>> memoryRows = batch.getTuples();
                batch = new TupleBatch(beginRow, memoryRows.subList(beginRow - batch.getBeginRow(), endRow - batch.getBeginRow() + 1));
                batch.setTerminationFlag(last);
        } else if (!fromBuffer){
          result = !isForwardOnly();
        }
          int finalRowCount = this.resultsBuffer.isFinal()?this.resultsBuffer.getRowCount():(batch.getTerminationFlag()?batch.getEndRow():-1);
         
          response = createResultsMessage(batch.getAllTuples(), this.originalCommand.getProjectedSymbols());
          response.setFirstRow(batch.getBeginRow());
          response.setLastRow(batch.getEndRow());
          response.setUpdateResult(this.returnsUpdateCount);
          // set final row
          response.setFinalRow(finalRowCount);
 
          // send any warnings with the response object
          List<Throwable> responseWarnings = new ArrayList<Throwable>();
          if (this.processor != null) {
        List<Exception> currentWarnings = processor.getAndClearWarnings();
          if (currentWarnings != null) {
            responseWarnings.addAll(currentWarnings);
          }
          }
        synchronized (warnings) {
            responseWarnings.addAll(this.warnings);
            this.warnings.clear();
        }
          response.setWarnings(responseWarnings);
         
          // If it is stored procedure, set parameters
          if (originalCommand instanceof StoredProcedure) {
            StoredProcedure proc = (StoredProcedure)originalCommand;
            if (proc.returnParameters()) {
              response.setParameters(getParameterInfo(proc));
            }
          }
          /*
           * mark the results sent at this point.
           * communication exceptions will be treated as non-recoverable
View Full Code Here

        for(int i=0; i<columnSymbols.size(); i++) {
            SingleElementSymbol symbol = (SingleElementSymbol) columnSymbols.get(i);
            columnNames[i] = SingleElementSymbol.getShortName(symbol.getOutputName());
            dataTypes[i] = DataTypeManager.getDataTypeName(symbol.getType());
        }
        ResultsMessage result = new ResultsMessage(requestMsg, batch, columnNames, dataTypes);
        setAnalysisRecords(result);
        return result;
    }
View Full Code Here

          LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Unable to send error to client as results were already sent.", requestID); //$NON-NLS-1$
          return;
        }
      }
    LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Sending error to client", requestID); //$NON-NLS-1$
        ResultsMessage response = new ResultsMessage(requestMsg);
        response.setException(processingException);
        setAnalysisRecords(response);
        receiver.receiveResults(response);
    }
View Full Code Here

    Mockito.stub(logonResult.getTimeZone()).toReturn(TimeZone.getDefault());

    // a dummy result message that is specific to this test case
    ResultsFuture<ResultsMessage> results = new ResultsFuture<ResultsMessage>();
    Mockito.stub(dqp.executeRequest(Matchers.anyLong(), (RequestMessage)Matchers.anyObject())).toReturn(results);
    ResultsMessage rm = new ResultsMessage();
    rm.setResults(new List<?>[] {Arrays.asList(0), Arrays.asList(0), Arrays.asList(0)});
    rm.setUpdateResult(true);
    results.getResultsReceiver().receiveResults(rm);
    Mockito.stub(conn.getDQP()).toReturn(dqp);
   
    // some update SQL
    String sqlCommand = "delete from table where col=?"; //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.teiid.client.ResultsMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.