Search in sources :

Example 96 with TeiidComponentException

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

the class DeferredMetadataProvider method loadFullMetadata.

private void loadFullMetadata() throws SQLException {
    MetadataResult results;
    try {
        results = this.statement.getDQP().getMetadata(this.requestID);
    } catch (TeiidComponentException e) {
        throw TeiidSQLException.create(e);
    } catch (TeiidProcessingException e) {
        throw TeiidSQLException.create(e);
    }
    this.metadata = results.getColumnMetadata();
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) MetadataResult(org.teiid.client.metadata.MetadataResult) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Example 97 with TeiidComponentException

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

the class TestSocketServiceRegistry method testComponentExceptionConversion.

public void testComponentExceptionConversion() throws Exception {
    Method m = DQP.class.getMethod("getMetadata", new Class[] { Long.TYPE });
    Throwable t = ExceptionUtil.convertException(m, new NullPointerException());
    assertTrue(t instanceof TeiidComponentException);
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) Method(java.lang.reflect.Method)

Example 98 with TeiidComponentException

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

the class SocketServerConnection method selectServerInstance.

/**
 * Implements a sticky random selection policy
 * TODO: make this customizable
 * TODO: put more information on hostinfo as to process response time, last successful connect, etc.
 * @throws ConnectionException
 */
public synchronized SocketServerInstance selectServerInstance(boolean logoff) throws CommunicationException, ConnectionException {
    if (closed) {
        throw new CommunicationException(JDBCPlugin.Event.TEIID20016, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20016));
    }
    if (this.serverInstance != null && (!failOver || this.serverInstance.isOpen())) {
        return this.serverInstance;
    }
    List<HostInfo> hostKeys = new ArrayList<HostInfo>(this.serverDiscovery.getKnownHosts(logonResult, null));
    boolean discoverHosts = true;
    closeServerInstance();
    List<HostInfo> hostCopy = new ArrayList<HostInfo>(hostKeys);
    int knownHosts = hostKeys.size();
    while (hostKeys.size() > 0) {
        HostInfo hostInfo = this.serverDiscovery.selectNextInstance(hostKeys);
        Exception ex = null;
        try {
            if (!hostInfo.isResolved()) {
                InetAddress inetAddress = hostInfo.getInetAddress();
                if (!hostInfo.isResolved()) {
                    // create a resolved version
                    hostInfo = new HostInfo(hostInfo.getHostName(), new InetSocketAddress(inetAddress, hostInfo.getPortNumber()));
                }
            }
            ILogon newLogon = connect(hostInfo);
            if (this.logonResult == null) {
                try {
                    logon(newLogon, logoff);
                    this.serverDiscovery.connectionSuccessful(hostInfo);
                    if (discoverHosts) {
                        List<HostInfo> updatedHosts = this.serverDiscovery.getKnownHosts(logonResult, this.serverInstance);
                        if (updatedHosts.size() > 1 && new HashSet<HostInfo>(updatedHosts).size() > new HashSet<HostInfo>(hostCopy).size()) {
                            hostKeys = updatedHosts;
                            closeServerInstance();
                            discoverHosts = false;
                            continue;
                        }
                    }
                } catch (LogonException e) {
                    // to give to the user
                    throw new ConnectionException(e);
                } catch (TeiidComponentException e) {
                    if (e.getCause() instanceof CommunicationException) {
                        throw (CommunicationException) e.getCause();
                    }
                    throw new CommunicationException(JDBCPlugin.Event.TEIID20018, e, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20018));
                }
            }
            return this.serverInstance;
        } catch (IOException e) {
            ex = e;
        } catch (SingleInstanceCommunicationException e) {
            ex = e;
        }
        this.serverDiscovery.markInstanceAsBad(hostInfo);
        if (knownHosts == 1) {
            // just a single host, use the exception
            if (ex instanceof UnknownHostException) {
                throw new SingleInstanceCommunicationException(JDBCPlugin.Event.TEIID20019, ex, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20019, hostInfo.getHostName()));
            }
            throw new SingleInstanceCommunicationException(JDBCPlugin.Event.TEIID20020, ex, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20020, hostInfo.getHostName(), String.valueOf(hostInfo.getPortNumber()), ex.getMessage()));
        }
        // $NON-NLS-1$
        log.log(Level.FINE, "Unable to connect to host", ex);
    }
    throw new CommunicationException(JDBCPlugin.Event.TEIID20021, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20021, hostCopy.toString()));
}
Also used : CommunicationException(org.teiid.net.CommunicationException) UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) IOException(java.io.IOException) InvalidSessionException(org.teiid.client.security.InvalidSessionException) TeiidComponentException(org.teiid.core.TeiidComponentException) LogonException(org.teiid.client.security.LogonException) SocketException(java.net.SocketException) CommunicationException(org.teiid.net.CommunicationException) TeiidException(org.teiid.core.TeiidException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ConnectionException(org.teiid.net.ConnectionException) ILogon(org.teiid.client.security.ILogon) LogonException(org.teiid.client.security.LogonException) TeiidComponentException(org.teiid.core.TeiidComponentException) HostInfo(org.teiid.net.HostInfo) InetAddress(java.net.InetAddress) ConnectionException(org.teiid.net.ConnectionException)

Example 99 with TeiidComponentException

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

the class TestFunctionPushdown method testMustPushdownOverGrouping.

@Test
public void testMustPushdownOverGrouping() throws Exception {
    TransformationMetadata tm = RealMetadataFactory.fromDDL("create foreign function func (param integer) returns integer; create foreign table g1 (e1 integer)", "x", "y");
    BasicSourceCapabilities bsc = new BasicSourceCapabilities();
    bsc.setCapabilitySupport(Capability.SELECT_WITHOUT_FROM, true);
    bsc.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
    final DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(bsc);
    CommandContext cc = TestProcessor.createCommandContext();
    cc.setQueryProcessorFactory(new QueryProcessor.ProcessorFactory() {

        @Override
        public PreparedPlan getPreparedPlan(String query, String recursionGroup, CommandContext commandContext, QueryMetadataInterface metadata) throws TeiidProcessingException, TeiidComponentException {
            return null;
        }

        @Override
        public CapabilitiesFinder getCapabiltiesFinder() {
            return capFinder;
        }

        @Override
        public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException {
            // TODO Auto-generated method stub
            return null;
        }
    });
    cc.setMetadata(tm);
    // $NON-NLS-1$
    String sql = "select func(e1) from g1 group by e1";
    ProcessorPlan plan = helpPlan(sql, tm, null, capFinder, new String[] { "SELECT y.g1.e1 FROM y.g1" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    HardcodedDataManager dataManager = new HardcodedDataManager();
    dataManager.addData("SELECT y.g1.e1 FROM y.g1", new List[] { Arrays.asList(1), Arrays.asList(2) });
    dataManager.addData("SELECT func(1)", new List[] { Arrays.asList(2) });
    dataManager.addData("SELECT func(2)", new List[] { Arrays.asList(3) });
    TestProcessor.helpProcess(plan, cc, dataManager, new List[] { Arrays.asList(2), Arrays.asList(3) });
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CommandContext(org.teiid.query.util.CommandContext) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) TeiidProcessingException(org.teiid.core.TeiidProcessingException) FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) CapabilitiesFinder(org.teiid.query.optimizer.capabilities.CapabilitiesFinder) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) PreparedPlan(org.teiid.dqp.internal.process.PreparedPlan) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 100 with TeiidComponentException

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

the class FakeDataManager method getQueryGroup.

private GroupSymbol getQueryGroup(Query query) throws TeiidComponentException {
    GroupSymbol group;
    From from = query.getFrom();
    List groups = from.getGroups();
    if (groups.size() != 1) {
        // $NON-NLS-1$
        throw new TeiidComponentException("Cannot build fake tuple source for command: " + query);
    }
    group = (GroupSymbol) groups.get(0);
    Iterator projSymbols = query.getSelect().getProjectedSymbols().iterator();
    while (projSymbols.hasNext()) {
        Object symbol = projSymbols.next();
        if (symbol instanceof ElementSymbol) {
            ElementSymbol elementSymbol = (ElementSymbol) symbol;
            GroupSymbol g = elementSymbol.getGroupSymbol();
            if (!g.equals(group)) {
                // $NON-NLS-1$ //$NON-NLS-2$
                throw new TeiidComponentException("Illegal symbol " + elementSymbol + " in SELECT of command: " + query);
            }
            if (elementSymbol.getMetadataID() == null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                throw new TeiidComponentException("Illegal null metadata ID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query);
            } else if (elementSymbol.getMetadataID() instanceof TempMetadataID) {
                // $NON-NLS-1$ //$NON-NLS-2$
                throw new TeiidComponentException("Illegal TempMetadataID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query);
            }
        }
    }
    return group;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Iterator(java.util.Iterator) TempMetadataID(org.teiid.query.metadata.TempMetadataID) ArrayList(java.util.ArrayList) List(java.util.List) TeiidComponentException(org.teiid.core.TeiidComponentException)

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