@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 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 ReturnState updateTableStats(RpcController controller, UpdateTableStatsProto proto) { wlock.lock(); try { store.updateTableStats(proto); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState updateTableStats(RpcController controller, UpdateTableStatsProto proto) { wlock.lock(); try { store.updateTableStats(proto); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } finally { wlock.unlock(); } }
@Override public ReturnState removeSession(RpcController controller, TajoIdProtos.SessionIdProto request) throws ServiceException { try { if (request != null) { context.getSessionManager().removeSession(request.getId()); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return ReturnStateUtil.returnError(t); } return OK; }
@Override public ReturnState removeSession(RpcController controller, TajoIdProtos.SessionIdProto request) throws ServiceException { try { if (request != null) { context.getSessionManager().removeSession(request.getId()); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return ReturnStateUtil.returnError(t); } return OK; }
@Override public ReturnState dropFunction(RpcController controller, UnregisterFunctionRequest request) { try { if (!containFunction(request.getSignature())) { return errUndefinedFunction(request.toString()); } functions.remove(request.getSignature()); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState dropFunction(RpcController controller, UnregisterFunctionRequest request) { try { if (!containFunction(request.getSignature())) { return errUndefinedFunction(request.toString()); } functions.remove(request.getSignature()); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public IndexListResponse getAllIndexes(RpcController controller, NullProto request) throws ServiceException { rlock.lock(); try { return IndexListResponse.newBuilder().setState(OK).addAllIndexDesc(store.getAllIndexes()).build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return IndexListResponse.newBuilder() .setState(returnError(t)) .build(); } finally { rlock.unlock(); } }
@Override public IndexListResponse getAllIndexes(RpcController controller, NullProto request) throws ServiceException { rlock.lock(); try { return IndexListResponse.newBuilder().setState(OK).addAllIndexDesc(store.getAllIndexes()).build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return IndexListResponse.newBuilder() .setState(returnError(t)) .build(); } finally { rlock.unlock(); } }
@Override public ReturnState existDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); if (catalog.existDatabase(request.getValue())) { return OK; } else { return errUndefinedDatabase(request.getValue()); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState existDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); if (catalog.existDatabase(request.getValue())) { return OK; } else { return errUndefinedDatabase(request.getValue()); } } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState createDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { final Session session = context.getSessionManager().getSession(request.getSessionId().getId()); final QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().createDatabase(queryContext, request.getValue(), null, false); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState createDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { final Session session = context.getSessionManager().getSession(request.getSessionId().getId()); final QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().createDatabase(queryContext, request.getValue(), null, false); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState dropDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { final Session session = context.getSessionManager().getSession(request.getSessionId().getId()); final QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().dropDatabase(queryContext, request.getValue(), false); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState dropDatabase(RpcController controller, SessionedStringProto request) throws ServiceException { try { final Session session = context.getSessionManager().getSession(request.getSessionId().getId()); final QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().dropDatabase(queryContext, request.getValue(), false); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState dropTable(RpcController controller, DropTableRequest dropTable) throws ServiceException { try { Session session = context.getSessionManager().getSession(dropTable.getSessionId().getId()); QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().dropTable(queryContext, dropTable.getName(), false, dropTable.getPurge()); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState dropTable(RpcController controller, DropTableRequest dropTable) throws ServiceException { try { Session session = context.getSessionManager().getSession(dropTable.getSessionId().getId()); QueryContext queryContext = new QueryContext(conf, session); context.getGlobalEngine().getDDLExecutor().dropTable(queryContext, dropTable.getName(), false, dropTable.getPurge()); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState closeNonForwardQuery(RpcController controller, QueryIdRequest request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); Session session = context.getSessionManager().getSession(request.getSessionId().getId()); QueryId queryId = new QueryId(request.getQueryId()); session.closeNonForwardQueryResultScanner(queryId); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }
@Override public ReturnState closeNonForwardQuery(RpcController controller, QueryIdRequest request) throws ServiceException { try { context.getSessionManager().touch(request.getSessionId().getId()); Session session = context.getSessionManager().getSession(request.getSessionId().getId()); QueryId queryId = new QueryId(request.getQueryId()); session.closeNonForwardQueryResultScanner(queryId); return OK; } catch (Throwable t) { printStackTraceIfError(LOG, t); return returnError(t); } }