@Override public void submissionFailed(final UserException ex) { exception = ex; synchronized(errorList) { errorList.add(ex.getOrCreatePBError(false)); } latch.countDown(); }
private void sendOutOfMemory(OutOfMemoryException e, final ChannelHandlerContext ctx, int coordinationId){ final UserException uex = UserException.memoryError(e) .message("Out of memory while receiving data.") .build(logger); final OutboundRpcMessage outMessage = new OutboundRpcMessage( RpcMode.RESPONSE_FAILURE, 0, coordinationId, uex.getOrCreatePBError(false) ); if (RpcConstants.EXTRA_DEBUGGING) { logger.debug("Adding message to outbound buffer. {}", outMessage); } ChannelFuture future = ctx.writeAndFlush(outMessage); // if we were unable to report back the failure make sure we close the channel otherwise we may cause the sender // to block undefinitely waiting for an ACK on this message future.addListener(ChannelFutureListener.CLOSE_ON_FAILURE); }
@Override protected CreatePreparedStatementResp getException(UserException ex) { final CreatePreparedStatementResp.Builder respBuilder = CreatePreparedStatementResp.newBuilder(); respBuilder.setStatus(RequestStatus.FAILED); respBuilder.setError(ex.getOrCreatePBError(false)); return respBuilder.build(); }
public QueryResult toQueryResult() { if (result == null) { QueryResult.Builder resultBuilder = QueryResult.newBuilder() .setQueryId(queryId) .setQueryState(state); if (exception != null) { resultBuilder.addError(exception.getOrCreatePBError(true)); } if (state == QueryState.CANCELED && !clientCancelled) { // from client POV, CANCELED becomes FAILED only if server caused the cancellation resultBuilder.setQueryState(QueryState.FAILED); resultBuilder.addError(UserException.resourceError() .message(cancelReason) .build(logger) .getOrCreatePBError(true)); } result = resultBuilder.build(); } return result; }
private static void throwAsUnsupportedException(UserException ex) throws Exception { SqlUnsupportedException.errorClassNameToException(ex.getOrCreatePBError(false).getException().getExceptionClass()); throw ex; }
private static void throwAsUnsupportedException(UserException ex) throws Exception { SqlUnsupportedException.errorClassNameToException(ex.getOrCreatePBError(false).getException().getExceptionClass()); throw ex; }
@Test public void testBuildSystemException() { String message = "This is an exception"; UserException uex = UserException.systemError(new Exception(new RuntimeException(message))).build(logger); Assert.assertTrue(uex.getOriginalMessage().contains(message)); Assert.assertTrue(uex.getOriginalMessage().contains("RuntimeException")); DremioPBError error = uex.getOrCreatePBError(true); Assert.assertEquals(ErrorType.SYSTEM, error.getErrorType()); }
private static final RpcException newRPCException(NodeEndpoint endpoint, IOException ioe) { UserRemoteException ure = UserRemoteException.create(UserException .ioExceptionError(ioe) .addIdentity(endpoint) .build(logger).getOrCreatePBError(false)); return new RpcException(ure); } @Test
@Test @Ignore public void testExceptionHandling() throws Exception { try { test("select * from cp.\"jsoninput/DRILL-2350.json\""); } catch(UserException e) { Assert.assertEquals(UserBitShared.DremioPBError.ErrorType.UNSUPPORTED_OPERATION, e.getOrCreatePBError(false).getErrorType()); String s = e.getMessage(); assertEquals("Expected Unsupported Operation Exception.", true, s.contains("Dremio does not support lists of different types.")); } }
@Test public void testBuildUserExceptionWithCause() { String message = "Test message"; UserException uex = UserException.dataWriteError(new RuntimeException(message)).build(logger); DremioPBError error = uex.getOrCreatePBError(false); // cause message should be used Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType()); Assert.assertEquals(message, uex.getOriginalMessage()); }
@Test public void testRemoteRuntimeException() throws Exception { UserRemoteException ure = UserRemoteException.create(UserException .unsupportedError(new UserRpcException(null, "user rpc exception", new RuntimeException("test message"))) .build(logger).getOrCreatePBError(false)); exception.expect(RuntimeException.class); exception.expectMessage("test message"); RpcException.propagateIfPossible(new RpcException(ure), TestException.class); } }
@Test public void testBuildUserExceptionWithFormattedMessage() { String format = "This is test #%d"; UserException uex = UserException.connectionError().message(format, 5).build(logger); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType()); Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage()); }
private FragmentStatus getStatus(final FragmentState state, final UserException ex) { final FragmentStatus.Builder status = FragmentStatus.newBuilder(); final MinorFragmentProfile.Builder b = MinorFragmentProfile.newBuilder(); stats.addMetricsToStatus(b); b.setState(state); if (ex != null) { b.setError(ex.getOrCreatePBError(true)); } status.setHandle(handle); b.setMemoryUsed(fragmentAllocator.getAllocatedMemory()); b.setMinorFragmentId(handle.getMinorFragmentId()); status.setProfile(b); return status.build(); }
@Test public void testBuildUserExceptionWithCauseAndMessage() { String messageA = "Test message A"; String messageB = "Test message B"; UserException uex = UserException.dataWriteError(new RuntimeException(messageA)).message(messageB).build(logger); DremioPBError error = uex.getOrCreatePBError(false); // passed message should override the cause message Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType()); Assert.assertEquals(messageB, uex.getOriginalMessage()); }
@Test public void testBuildUserExceptionWithMessage() { String message = "Test message"; UserException uex = UserException.dataWriteError().message(message).build(logger); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType()); Assert.assertEquals(message, uex.getOriginalMessage()); }
private void testSingleMode(String fileName) throws Exception{ test(SINGLE_MODE); CoordinationProtos.NodeEndpoint endpoint = nodes[0].getContext().getEndpoint(); String controlsString = "{\"injections\":[{" + "\"address\":\"" + endpoint.getAddress() + "\"," + "\"port\":\"" + endpoint.getUserPort() + "\"," + "\"type\":\"exception\"," + "\"siteClass\":\"" + "com.dremio.exec.physical.impl.ScanBatch" + "\"," + "\"desc\":\"" + "next-allocate" + "\"," + "\"nSkip\":0," + "\"nFire\":1," + "\"exceptionClass\":\"" + OutOfMemoryException.class.getName() + "\"" + "}]}"; ControlsInjectionUtil.setControls(client, controlsString); String query = getFile(fileName); try { test(query); } catch(UserException uex) { DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(DremioPBError.ErrorType.RESOURCE, error.getErrorType()); Assert.assertTrue("Error message isn't related to memory error", uex.getMessage().contains(UserException.MEMORY_ERROR_MSG)); } }
@Test public void testBuildUserExceptionWithUserExceptionCauseAndMessage() { String messageA = "Test message A"; String messageB = "Test message B"; UserException original = UserException.connectionError().message(messageA).build(logger); UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger); //builder should return the unwrapped original user exception and not build a new one Assert.assertEquals(original, uex); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(messageA, uex.getOriginalMessage()); Assert.assertFalse(error.getMessage().contains(messageB)); // messageB should not be part of the context }
} catch (UserException uex) { DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(DremioPBError.ErrorType.RESOURCE, error.getErrorType()); Assert.assertTrue("Error message isn't related to memory error",
@Test(expected = UnsupportedRelOperatorException.class) @Ignore public void testUnionDistinctViewUnExpandableStar() throws Exception { test("use dfs_test.tmp"); test("create view nation_view_testunion as select * from cp.\"tpch/nation.parquet\";"); try { String query = "(select * from dfs_test.tmp.\"nation_view_testunion\") \n" + "union (select * from cp.\"tpch/region.parquet\")"; test(query); } catch(UserException ex) { SqlUnsupportedException.errorClassNameToException(ex.getOrCreatePBError(false).getException().getExceptionClass()); throw ex; } finally { test("drop view nation_view_testunion"); } }
@Test public void testRemoteTestException() throws Exception { UserRemoteException ure = UserRemoteException.create(UserException .unsupportedError(new UserRpcException(null, "user rpc exception", new TestException("test message"))) .build(logger).getOrCreatePBError(false)); exception.expect(TestException.class); exception.expectMessage("test message"); RpcException.propagateIfPossible(new RpcException(ure), TestException.class); }