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