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