private CommandProcessorResponse llapCacheCommandHandler(final SessionState ss, final String[] params) throws ParseException { CommandLine args = parseCommandArgs(CACHE_OPTIONS, params); boolean purge = args.hasOption("purge"); String hs2Host = null; if (ss.isHiveServerQuery()) { hs2Host = ss.getHiveServer2Host(); } if (purge) { List<String> fullCommand = Lists.newArrayList("llap", "cache"); fullCommand.addAll(Arrays.asList(params)); CommandProcessorResponse authErrResp = CommandUtil.authorizeCommandAndServiceObject(ss, HiveOperationType.LLAP_CACHE_PURGE, fullCommand, hs2Host); if (authErrResp != null) { // there was an authorization issue return authErrResp; } try { LlapRegistryService llapRegistryService = LlapRegistryService.getClient(ss.getConf()); llapCachePurge(ss, llapRegistryService); return createProcessorSuccessResponse(); } catch (Exception e) { LOG.error("Error while purging LLAP IO Cache. err: ", e); return returnErrorResponse("Error while purging LLAP IO Cache. err: " + e.getMessage()); } } else { String usage = getUsageAsString(); return returnErrorResponse("Unsupported sub-command option. " + usage); } }
private CommandProcessorResponse createProcessorSuccessResponse() { return new CommandProcessorResponse(0, null, null, getSchema()); }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution(() -> SessionState.get().getHiveVariables()).substitute(ss.getConf(), command); String[] tokens = command.split("\\s+"); if (tokens.length < 1) { return returnErrorResponse("Command arguments are empty."); } String params[] = Arrays.copyOfRange(tokens, 1, tokens.length); try { return llapCacheCommandHandler(ss, params); } catch (Exception e) { return returnErrorResponse(e.getMessage()); } }
return new LlapClusterResourceProcessor(); case LLAP_CACHE: return new LlapCacheResourceProcessor(); case DELETE: return new DeleteResourceProcessor();