/** * Used to wrap warnings/exceptions into SQLWarning. * The chain of warnings is translated into a chain of SQLWarnings. * @param reason String object which is the description of the warning. * @param ex Throwable object which needs to be wrapped. */ static SQLWarning createWarning(Throwable ex) { String sourceName = null; String modelName = null; if(ex instanceof SourceWarning) { SourceWarning exception = (SourceWarning)ex; if (exception.isPartialResultsError()) { PartialResultsWarning warning = new PartialResultsWarning(JDBCPlugin.Util.getString("WarningUtil.Failures_occurred")); //$NON-NLS-1$ warning.addConnectorFailure(exception.getConnectorBindingName(), TeiidSQLException.create(exception)); return warning; } ex = exception.getCause(); sourceName = exception.getConnectorBindingName(); modelName = exception.getModelName(); } String code = null; if (ex instanceof TeiidException) { code = ((TeiidException)ex).getCode(); } return new TeiidSQLWarning(ex.getMessage(), code, ex, sourceName, modelName); }
/** * <p>Constructor that stores atomic query failure details.</p> * @param model Name of the model for the atomic query * @param connectorBinding Name of the connector binding name for the atomic query * @param ex Exception thrown when atomic query fails */ public SourceWarning(String model, String connectorBinding, Throwable ex, boolean partialResults) { super(ex); if(model != null) { this.modelName = model; } if(connectorBinding != null) { this.connectorBindingName = connectorBinding; } this.partialResults = partialResults; setStackTrace(EMPTY_STACK_TRACE); }
@Test public void testSourceWarning() throws Exception { ClassLoader cl = new URLClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$ ArrayList<String> args = new ArrayList<String>(); args.add("Unknown Exception"); //$NON-NLS-1$ Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", args, cl); //$NON-NLS-1$ ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(new ExceptionHolder(new SourceWarning("x", "y", obj, true))); oos.flush(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); ExceptionHolder holder = (ExceptionHolder)ois.readObject(); SourceWarning sw = (SourceWarning)holder.getException(); assertEquals(sw.getConnectorBindingName(), "y"); assertEquals(sw.getModelName(), "x"); assertTrue(sw.isPartialResultsError()); try { ois = new ObjectInputStream(new FileInputStream(UnitTestUtil.getTestDataFile("old-exceptionholder.ser"))); holder = (ExceptionHolder)ois.readObject(); assertTrue(holder.getException() instanceof TeiidException); } finally { ois.close(); } } }
String modelName = in.readUTF(); boolean partial = in.readBoolean(); this.exception = new SourceWarning(modelName, connectorBindingName, this.exception.getCause(), partial); } catch (EOFException e) {
out.writeUTF(sw.getConnectorBindingName()); out.writeUTF(sw.getModelName()); out.writeBoolean(sw.isPartialResultsError());
@Test public void testPartialResults() throws Exception { DataTierTupleSource info = helpSetup(1); connectorManager.throwExceptionOnExecute = true; for (int i = 0; i < 10; i++) { try { assertNull(info.nextTuple()); SourceWarning warning = (SourceWarning) context.getAndClearWarnings().get(0); assertTrue(warning.isPartialResultsError()); return; } catch (BlockedException e) { Thread.sleep(50); } } fail(); }
/** * <p>Gets a message detailing the source against which the atomic query failed.</p> * @return Message containing details of the source for which there is a failure. */ public String toString() { StringBuffer warningBuf = new StringBuffer(); if (partialResults) { warningBuf.append("Error "); //$NON-NLS-1$ } else { warningBuf.append("Warning "); //$NON-NLS-1$ } warningBuf.append("querying the connector with binding name "); //$NON-NLS-1$ warningBuf.append(connectorBindingName); warningBuf.append(" for the model "); //$NON-NLS-1$ warningBuf.append(modelName); warningBuf.append(" : "); //$NON-NLS-1$ warningBuf.append(this.getCause()); return warningBuf.toString(); }
String modelName = in.readUTF(); boolean partial = in.readBoolean(); this.exception = new SourceWarning(modelName, connectorBindingName, this.exception.getCause(), partial); } catch (EOFException e) {
out.writeUTF(sw.getConnectorBindingName()); out.writeUTF(sw.getModelName()); out.writeBoolean(sw.isPartialResultsError());
@Test public void testDataTierTupleSourceWarnings() throws Exception { DataTierTupleSource info = helpSetup(1); connectorManager.addWarning = true; assertEquals(10, pullTuples(info, 10)); assertNotNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); assertNull(info.nextTuple()); List<Exception> warnings = context.getAndClearWarnings(); assertEquals(1, warnings.size()); SourceWarning warning = (SourceWarning) warnings.get(0); assertFalse(warning.isPartialResultsError()); info.closeSource(); assertNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); }
/** * <p>Gets a message detailing the source against which the atomic query failed.</p> * @return Message containing details of the source for which there is a failure. */ public String toString() { StringBuffer warningBuf = new StringBuffer(); if (partialResults) { warningBuf.append("Error "); //$NON-NLS-1$ } else { warningBuf.append("Warning "); //$NON-NLS-1$ } warningBuf.append("querying the connector with binding name "); //$NON-NLS-1$ warningBuf.append(connectorBindingName); warningBuf.append(" for the model "); //$NON-NLS-1$ warningBuf.append(modelName); warningBuf.append(" : "); //$NON-NLS-1$ warningBuf.append(this.getCause()); return warningBuf.toString(); }
private SourceWarning getSourceFailures(String model, String binding, String message) { return new SourceWarning(model, binding, new TeiidException(message), true); }
/** * Used to wrap warnings/exceptions into SQLWarning. * The chain of warnings is translated into a chain of SQLWarnings. * @param reason String object which is the description of the warning. * @param ex Throwable object which needs to be wrapped. */ static SQLWarning createWarning(Throwable ex) { String sourceName = null; String modelName = null; if(ex instanceof SourceWarning) { SourceWarning exception = (SourceWarning)ex; if (exception.isPartialResultsError()) { PartialResultsWarning warning = new PartialResultsWarning(JDBCPlugin.Util.getString("WarningUtil.Failures_occurred")); //$NON-NLS-1$ warning.addConnectorFailure(exception.getConnectorBindingName(), TeiidSQLException.create(exception)); return warning; } ex = exception.getCause(); sourceName = exception.getConnectorBindingName(); modelName = exception.getModelName(); } String code = null; if (ex instanceof TeiidException) { code = ((TeiidException)ex).getCode(); } return new TeiidSQLWarning(ex.getMessage(), code, ex, sourceName, modelName); }
/** * <p>Constructor that stores atomic query failure details.</p> * @param model Name of the model for the atomic query * @param connectorBinding Name of the connector binding name for the atomic query * @param ex Exception thrown when atomic query fails */ public SourceWarning(String model, String connectorBinding, Throwable ex, boolean partialResults) { super(ex); if(model != null) { this.modelName = model; } if(connectorBinding != null) { this.connectorBindingName = connectorBinding; } this.partialResults = partialResults; setStackTrace(EMPTY_STACK_TRACE); }
void receiveResults(AtomicResultsMessage response, boolean partial) { this.arm = response; this.scope = response.getScope(); if (this.scope != null) { this.aqr.getCommandContext().setDeterminismLevel(CachingTupleSource.getDeterminismLevel(this.scope)); } explicitClose |= !arm.supportsImplicitClose(); rowsProcessed += response.getResults().length; index = 0; if (response.getWarnings() != null) { for (Exception warning : response.getWarnings()) { SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, partial); this.aqr.getCommandContext().addWarning(sourceFailure); } } if (response.getFinalRow() >= 0) { done = true; } }
void receiveResults(AtomicResultsMessage response, boolean partial) { this.arm = response; this.scope = response.getScope(); if (this.scope != null) { this.aqr.getCommandContext().setDeterminismLevel(CachingTupleSource.getDeterminismLevel(this.scope)); } explicitClose |= !arm.supportsImplicitClose(); rowsProcessed += response.getResults().length; index = 0; if (response.getWarnings() != null) { for (Exception warning : response.getWarnings()) { SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, partial); this.aqr.getCommandContext().addWarning(sourceFailure); } } if (response.getFinalRow() >= 0) { done = true; } }
void receiveResults(AtomicResultsMessage response, boolean partial) { this.arm = response; this.scope = response.getScope(); if (this.scope != null) { this.aqr.getCommandContext().setDeterminismLevel(CachingTupleSource.getDeterminismLevel(this.scope)); } explicitClose |= !arm.supportsImplicitClose(); rowsProcessed += response.getResults().length; index = 0; if (response.getWarnings() != null) { for (Exception warning : response.getWarnings()) { SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, partial); this.aqr.getCommandContext().addWarning(sourceFailure); } } if (response.getFinalRow() >= 0) { done = true; } }