Search in sources :

Example 16 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class TestAsyncTupleSource method testTupleSource.

@Test
public void testTupleSource() throws TeiidComponentException, TeiidProcessingException {
    AsyncTupleSource ats = new AsyncTupleSource(new Callable<TupleSource>() {

        @Override
        public TupleSource call() throws Exception {
            return new CollectionTupleSource(Arrays.asList(Arrays.asList(1), Arrays.asList(2)).iterator());
        }
    }, new CommandContext());
    for (int i = 0; i < 20; i++) {
        try {
            assertEquals(Arrays.asList(1), ats.nextTuple());
            break;
        } catch (BlockedException e) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
            }
        }
    }
    assertEquals(Arrays.asList(2), ats.nextTuple());
    assertNull(ats.nextTuple());
}
Also used : CommandContext(org.teiid.query.util.CommandContext) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) TupleSource(org.teiid.common.buffer.TupleSource) CollectionTupleSource(org.teiid.query.processor.CollectionTupleSource) BlockedException(org.teiid.common.buffer.BlockedException) BlockedException(org.teiid.common.buffer.BlockedException) TeiidComponentException(org.teiid.core.TeiidComponentException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) Test(org.junit.Test)

Example 17 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class TestSocketRemoting method testMethodInvocation.

@Test
public void testMethodInvocation() throws Exception {
    ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl() {

        @Override
        public ClassLoader getCallerClassloader() {
            return getClass().getClassLoader();
        }
    };
    csr.registerClientService(ILogon.class, new ILogon() {

        public ResultsFuture<?> logoff() throws InvalidSessionException {
            ResultsFuture<?> result = new ResultsFuture<Void>();
            // $NON-NLS-1$
            result.getResultsReceiver().exceptionOccurred(new TeiidComponentException("some exception"));
            return result;
        }

        public LogonResult logon(Properties connectionProperties) throws LogonException, TeiidComponentException {
            return new LogonResult();
        }

        // tests asynch where we don't care about the result
        public ResultsFuture<?> ping() throws InvalidSessionException, TeiidComponentException {
            return null;
        }

        @Override
        public ResultsFuture<?> ping(Collection<String> sessions) throws TeiidComponentException, CommunicationException {
            return null;
        }

        @Override
        public void assertIdentity(SessionToken sessionId) throws InvalidSessionException, TeiidComponentException {
        }

        @Override
        public LogonResult neogitiateGssLogin(Properties connectionProperties, byte[] serviceToken, boolean createSession) throws LogonException {
            return null;
        }
    }, // $NON-NLS-1$
    "foo");
    // $NON-NLS-1$
    csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo");
    final FakeClientServerInstance serverInstance = new FakeClientServerInstance(csr);
    SocketServerConnection connection = createFakeConnection(serverInstance);
    ILogon logon = connection.getService(ILogon.class);
    Future<?> result = logon.ping();
    assertNull(result.get(0, TimeUnit.MILLISECONDS));
    result = logon.logoff();
    try {
        result.get(0, TimeUnit.MICROSECONDS);
        // $NON-NLS-1$
        fail("exception expected");
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof TeiidComponentException);
    }
    FakeService service = connection.getService(FakeService.class);
    Future<Integer> asynchInteger = service.asynchResult();
    assertEquals(new Integer(5), asynchInteger.get(0, TimeUnit.MILLISECONDS));
    try {
        service.exceptionMethod();
        // $NON-NLS-1$
        fail("exception expected");
    } catch (TeiidProcessingException e) {
    }
    DQP dqp = connection.getService(DQP.class);
    try {
        ResultsFuture<?> future = dqp.begin();
        future.get();
        // $NON-NLS-1$
        fail("exception expected");
    } catch (Exception e) {
        // $NON-NLS-1$
        assertTrue(e.getMessage().indexOf("Component not found:") != -1);
    }
}
Also used : LogonResult(org.teiid.client.security.LogonResult) Properties(java.util.Properties) TeiidProcessingException(org.teiid.core.TeiidProcessingException) LogonException(org.teiid.client.security.LogonException) ExecutionException(java.util.concurrent.ExecutionException) InvalidSessionException(org.teiid.client.security.InvalidSessionException) DQP(org.teiid.client.DQP) CommunicationException(org.teiid.net.CommunicationException) SessionToken(org.teiid.client.security.SessionToken) ILogon(org.teiid.client.security.ILogon) InvalidSessionException(org.teiid.client.security.InvalidSessionException) TeiidComponentException(org.teiid.core.TeiidComponentException) LogonException(org.teiid.client.security.LogonException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) CommunicationException(org.teiid.net.CommunicationException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) ConnectionException(org.teiid.net.ConnectionException) ResultsFuture(org.teiid.client.util.ResultsFuture) TeiidComponentException(org.teiid.core.TeiidComponentException) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Example 18 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class Request method initMetadata.

/**
 * if the metadata has not been supplied via setMetadata, this method will create the appropriate state
 *
 * @throws TeiidComponentException
 */
protected void initMetadata() throws TeiidComponentException {
    if (this.metadata != null) {
        return;
    }
    // Prepare dependencies for running the optimizer
    this.capabilitiesFinder = new CachedFinder(this.connectorManagerRepo, workContext.getVDB());
    if (this.bufferManager.getOptions() != null) {
        this.capabilitiesFinder = new TempCapabilitiesFinder(this.capabilitiesFinder, this.bufferManager.getOptions().getDefaultNullOrder());
    } else {
        this.capabilitiesFinder = new TempCapabilitiesFinder(this.capabilitiesFinder);
    }
    VDBMetaData vdbMetadata = workContext.getVDB();
    metadata = vdbMetadata.getAttachment(QueryMetadataInterface.class);
    globalTables = vdbMetadata.getAttachment(GlobalTableStore.class);
    if (metadata == null) {
        throw new TeiidComponentException(QueryPlugin.Event.TEIID30489, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30489, this.vdbName, this.vdbVersion));
    }
    TempMetadataAdapter tma = new TempMetadataAdapter(metadata, this.tempTableStore.getMetadataStore());
    tma.setSession(true);
    this.metadata = tma;
}
Also used : TempMetadataAdapter(org.teiid.query.metadata.TempMetadataAdapter) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) TeiidComponentException(org.teiid.core.TeiidComponentException) TempCapabilitiesFinder(org.teiid.query.metadata.TempCapabilitiesFinder) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface)

Example 19 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class RequestWorkItem method requestCancel.

public boolean requestCancel(String reason) throws TeiidComponentException {
    synchronized (this) {
        if (this.isCanceled || this.closeRequested) {
            // $NON-NLS-1$ //$NON-NLS-2$
            LogManager.logDetail(LogConstants.CTX_DQP, "Ignoring cancel for", requestID, "since request is already cancelled/closed");
            return false;
        }
        this.isCanceled = true;
        this.cancelReason = QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30563, requestID, reason);
    }
    LogManager.logDetail(LogConstants.CTX_DQP, cancelReason);
    if (this.processor != null) {
        this.processor.requestCanceled();
    }
    // Cancel Connector atomic requests
    try {
        for (DataTierTupleSource connectorRequest : getConnectorRequests()) {
            connectorRequest.cancelRequest();
        }
    } finally {
        try {
            if (transactionService != null) {
                try {
                    transactionService.cancelTransactions(requestID.getConnectionID(), true);
                } catch (XATransactionException err) {
                    throw new TeiidComponentException(QueryPlugin.Event.TEIID30544, err);
                }
            }
        } finally {
            this.moreWork();
        }
    }
    return true;
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) XATransactionException(org.teiid.client.xa.XATransactionException)

Example 20 with TeiidComponentException

use of org.teiid.core.TeiidComponentException in project teiid by teiid.

the class LobWorkItem method run.

public void run() {
    LobChunk chunk = null;
    Exception ex = null;
    boolean shouldClose = false;
    try {
        // save for future
        if (stream == null) {
            stream = createLobStream(streamId);
        }
        // now get the chunk from stream
        chunk = stream.getNextChunk();
        parent.dataBytes.addAndGet(chunk.getBytes().length);
        shouldClose = chunk.isLast();
    } catch (TeiidComponentException e) {
        LogManager.logWarning(org.teiid.logging.LogConstants.CTX_DQP, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30027));
        ex = e;
    } catch (IOException | SQLException e) {
        // treat this as a processing exception
        ex = new TeiidProcessingException(e);
    }
    synchronized (this) {
        if (ex != null) {
            resultsReceiver.exceptionOccurred(ex);
            shouldClose = true;
        } else {
            resultsReceiver.receiveResults(chunk);
        }
        resultsReceiver = null;
    }
    if (shouldClose) {
        close();
    }
}
Also used : SQLException(java.sql.SQLException) LobChunk(org.teiid.client.lob.LobChunk) TeiidComponentException(org.teiid.core.TeiidComponentException) IOException(java.io.IOException) TeiidComponentException(org.teiid.core.TeiidComponentException) IOException(java.io.IOException) SQLException(java.sql.SQLException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Aggregations

TeiidComponentException (org.teiid.core.TeiidComponentException)109 TeiidProcessingException (org.teiid.core.TeiidProcessingException)33 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)23 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)23 ArrayList (java.util.ArrayList)18 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)17 BlockedException (org.teiid.common.buffer.BlockedException)16 IOException (java.io.IOException)15 List (java.util.List)14 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)13 Test (org.junit.Test)12 LanguageObject (org.teiid.query.sql.LanguageObject)12 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)11 CommandContext (org.teiid.query.util.CommandContext)11 QueryValidatorException (org.teiid.api.exception.query.QueryValidatorException)10 ExpressionEvaluationException (org.teiid.api.exception.query.ExpressionEvaluationException)9 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)9 HashMap (java.util.HashMap)7 TeiidException (org.teiid.core.TeiidException)7 LogonException (org.teiid.client.security.LogonException)6