@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel ch = ctx.channel(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } LOG.error(cause.getMessage()); ExceptionUtil.printStackTraceIfError(LOG, cause); if (ch.isActive()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
@Override public void dropDatabase(final String databaseName) throws UndefinedDatabaseException, InsufficientPrivilegeException, CannotDropCurrentDatabaseException { try { final BlockingInterface stub = conn.getTMStub(); final ReturnState state = stub.dropDatabase(null, conn.getSessionedString(databaseName)); throwsIfThisError(state, UndefinedDatabaseException.class); throwsIfThisError(state, InsufficientPrivilegeException.class); throwsIfThisError(state, CannotDropCurrentDatabaseException.class); ensureOk(state); } catch (ServiceException e) { throw new RuntimeException(e); } }
/** * It can throw any TajoException if any error occurs. * * @param state * @throws TajoException */ public static void throwIfError(ReturnState state) throws TajoException { if (isError(state)) { throw toTajoException(state); } }
public static void printStackTraceIfError(Log log, Throwable t) { // if this runs as an actual cluster instance or a debug mode, it will print all stacktraces. // In other cases (i.e., run as a test mode and not debug mode), it will print stacktraces // if the query is managed mode. if (!TajoConstants.IS_TEST_MODE || TajoConstants.IS_DEBUG_MODE || !ExceptionUtil.isManagedException(t)) { ExceptionUtil.printStackTrace(log, t); } }
public static TajoException toTajoException(ReturnState state) throws TajoRuntimeException, TajoError { DefaultTajoException e = toTajoExceptionCommon(state); if (e instanceof TajoException) { return (TajoException) e; } else if (e instanceof TajoRuntimeException) { throw ((TajoRuntimeException) e); } else { throw ((TajoError) e); } }
public static Errors.SerializedException convertException(Throwable t) { Errors.SerializedException.Builder builder = Errors.SerializedException.newBuilder(); if (ExceptionUtil.isExceptionWithResultCode(t)) { DefaultTajoException tajoException = (DefaultTajoException) t; builder.setReturnCode(tajoException.getErrorCode()); builder.setMessage(tajoException.getMessage()); } else { Throwable rootCause = ExceptionUtils.getRootCause(t); if(rootCause != null) t = rootCause; builder.setReturnCode(ResultCode.INTERNAL_ERROR); builder.setMessage(ErrorMessages.getInternalErrorMessage(t)); } builder.setStackTrace(ErrorUtil.convertStacktrace(t)); builder.setTimestamp(System.currentTimeMillis()); return builder.build(); } }
public UnsupportedException() { super(Errors.ResultCode.FEATURE_NOT_SUPPORTED, ExceptionUtil.getExceptionPoint()); }
@Override public Expr visitGroupBy(Context context, Stack<Expr> stack, Aggregation expr) throws TajoException { super.visitGroupBy(context, stack, expr); // Enforcer only ordinary grouping set. for (Aggregation.GroupElement groupingElement : expr.getGroupSet()) { if (groupingElement.getType() != Aggregation.GroupType.OrdinaryGroup) { context.state.addVerification(ExceptionUtil.makeNotSupported(groupingElement.getType().name())); } } Projection projection = null; for (Expr parent : stack) { if (parent.getType() == OpType.Projection) { projection = (Projection) parent; break; } } if (projection == null) { throw new TajoInternalError("No Projection"); } return expr; }
public static TajoException toTajoException(ReturnState state) throws TajoRuntimeException, TajoError { DefaultTajoException e = toTajoExceptionCommon(state); if (e instanceof TajoException) { return (TajoException) e; } else if (e instanceof TajoRuntimeException) { throw ((TajoRuntimeException) e); } else { throw ((TajoError) e); } }
public static void printStackTraceIfError(Log log, Throwable t) { // if this runs as an actual cluster instance or a debug mode, it will print all stacktraces. // In other cases (i.e., run as a test mode and not debug mode), it will print stacktraces // if the query is managed mode. if (!TajoConstants.IS_TEST_MODE || TajoConstants.IS_DEBUG_MODE || !ExceptionUtil.isManagedException(t)) { ExceptionUtil.printStackTrace(log, t); } }
public static Errors.SerializedException convertException(Throwable t) { Errors.SerializedException.Builder builder = Errors.SerializedException.newBuilder(); if (ExceptionUtil.isExceptionWithResultCode(t)) { DefaultTajoException tajoException = (DefaultTajoException) t; builder.setReturnCode(tajoException.getErrorCode()); builder.setMessage(tajoException.getMessage()); } else { Throwable rootCause = ExceptionUtils.getRootCause(t); if(rootCause != null) t = rootCause; builder.setReturnCode(ResultCode.INTERNAL_ERROR); builder.setMessage(ErrorMessages.getInternalErrorMessage(t)); } builder.setStackTrace(ErrorUtil.convertStacktrace(t)); builder.setTimestamp(System.currentTimeMillis()); return builder.build(); } }
public NotImplementedException() { super(Errors.ResultCode.NOT_IMPLEMENTED, ExceptionUtil.getExceptionPoint()); }
@Override public Expr visitGroupBy(Context context, Stack<Expr> stack, Aggregation expr) throws TajoException { super.visitGroupBy(context, stack, expr); // Enforcer only ordinary grouping set. for (Aggregation.GroupElement groupingElement : expr.getGroupSet()) { if (groupingElement.getType() != Aggregation.GroupType.OrdinaryGroup) { context.state.addVerification(ExceptionUtil.makeNotSupported(groupingElement.getType().name())); } } Projection projection = null; for (Expr parent : stack) { if (parent.getType() == OpType.Projection) { projection = (Projection) parent; break; } } if (projection == null) { throw new TajoInternalError("No Projection"); } return expr; }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel ch = ctx.channel(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } LOG.error(cause.getMessage()); ExceptionUtil.printStackTraceIfError(LOG, cause); if (ch.isActive()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
@Override public final void createIndex(final IndexDesc index) throws DuplicateIndexException, UndefinedDatabaseException, UndefinedTableException { try { final BlockingInterface stub = getStub(); final ReturnState state = stub.createIndex(null, index.getProto()); throwsIfThisError(state, DuplicateIndexException.class); throwsIfThisError(state, UndefinedTableException.class); throwsIfThisError(state, UndefinedDatabaseException.class); ensureOk(state); } catch (ServiceException e) { throw new RuntimeException(e); } }
/** * It can throw any TajoException if any error occurs. * * @param state * @throws TajoException */ public static void throwIfError(ReturnState state) throws TajoException { if (isError(state)) { throw toTajoException(state); } }
private void executeJsonQuery(String json) throws TajoException { long startTime = System.currentTimeMillis(); ClientProtos.SubmitQueryResponse response = client.executeQueryWithJson(json); if (ReturnStateUtil.isSuccess(response.getState())) { switch (response.getResultType()) { case FETCH: QueryId queryId = new QueryId(response.getQueryId()); waitForQueryCompleted(queryId); break; case ENCLOSED: localQueryCompleted(response, startTime); break; default: displayFormatter.printMessage(sout, "OK"); } } else { onError((Throwable) ExceptionUtil.toTajoExceptionCommon(response.getState())); } }
public static ReturnState returnError(Throwable t) { ReturnState.Builder builder = ReturnState.newBuilder(); if (ExceptionUtil.isExceptionWithResultCode(t)) { DefaultTajoException tajoException = (DefaultTajoException) t; builder.setReturnCode(tajoException.getErrorCode()); builder.setMessage(tajoException.getMessage()); } else { builder.setReturnCode(ResultCode.INTERNAL_ERROR); builder.setMessage(ErrorMessages.getInternalErrorMessage(t)); } builder.setStackTrace(ErrorUtil.convertStacktrace(t)); return builder.build(); }
public NotImplementedException() { super(Errors.ResultCode.NOT_IMPLEMENTED, ExceptionUtil.getExceptionPoint()); }
createTableNode.setPartitionMethod(getPartitionMethod(context, expr.getTableName(), expr.getPartitionMethod())); } else { throw ExceptionUtil.makeNotSupported( String.format("PartitonType " + expr.getPartitionMethod().getPartitionType()));