public static ResourceType find_resource_type(String s) { s = s.trim().toUpperCase(); try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } // try singular if (s.endsWith("S")) { s = s.substring(0, s.length() - 1); } else { return null; } try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } return null; }
|| (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: delete [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1);
t.postHook(resources, deleteList); resources.removeAll(deleteList);
if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[1])) == null) { console.printError("Usage: list [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] [<value> [<value>]*]"); ret = 1; } else {
t.preHook(resourceSet, localized);
t.postHook(resources, deleteList); resources.removeAll(deleteList);
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: add [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } CommandProcessorResponse authErrResp = CommandUtil.authorizeCommand(ss, HiveOperationType.ADD, Arrays.asList(tokens)); if(authErrResp != null){ // there was an authorization issue return authErrResp; } try { ss.add_resources(t, Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length))); } catch (Exception e) { return CommandProcessorResponse.create(e); } return new CommandProcessorResponse(0); }
public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: delete [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } if (tokens.length >= 2) { for (int i = 1; i < tokens.length; i++) { ss.delete_resource(t, tokens[i]); } } else { ss.delete_resource(t); } return new CommandProcessorResponse(0); } }
@Override public CommandProcessorResponse run(String command) throws CommandNeedRetryException { SessionState ss = SessionState.get(); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { String message = "Usage: list [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] [<value> [<value>]*]"; return new CommandProcessorResponse(1, message, null); } List<String> filter = null; if (tokens.length > 1) { filter = Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length)); } Set<String> s = ss.list_resource(t, filter); if (s != null && !s.isEmpty()) { ss.out.println(StringUtils.join(s, "\n")); } return new CommandProcessorResponse(0, null, null, SCHEMA); } }
/** * {@inheritDoc} */ @Override public void addResource(LensSessionHandle sessionid, String type, String path) { try { resotreSessionIfRequired(sessionid); acquire(sessionid); SessionState ss = getSession(sessionid).getSessionState(); String finalLocation = ss.add_resource(SessionState.ResourceType.valueOf(type.toUpperCase()), path); getSession(sessionid).addResource(type, path, finalLocation); try { LENS_SERVER_DAO.updateActiveSession(getSession(sessionid).getLensSessionPersistInfo()); } catch (LensException e) { log.warn("Failed to update active session table with error," + e.toString()); } } catch (RuntimeException e) { log.error("Failed to add resource type:" + type + " path:" + path + " in session", e); throw new WebApplicationException(e); } finally { release(sessionid); } }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: delete [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } CommandProcessorResponse authErrResp = CommandUtil.authorizeCommand(ss, HiveOperationType.DELETE, Arrays.asList(tokens)); if(authErrResp != null){ // there was an authorization issue return authErrResp; } if (tokens.length >= 2) { ss.delete_resources(t, Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length))); } else { ss.delete_resources(t); } return new CommandProcessorResponse(0); } }
public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: add [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } for (int i = 1; i < tokens.length; i++) { ss.add_resource(t, tokens[i]); } return new CommandProcessorResponse(0); }
public static ResourceType find_resource_type(String s) { s = s.trim().toUpperCase(); try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } // try singular if (s.endsWith("S")) { s = s.substring(0, s.length() - 1); } else { return null; } try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } return null; }
public static ResourceType find_resource_type(String s) { s = s.trim().toUpperCase(); try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } // try singular if (s.endsWith("S")) { s = s.substring(0, s.length() - 1); } else { return null; } try { return ResourceType.valueOf(s); } catch (IllegalArgumentException e) { } return null; }
private void addResourceUponRestart(LensSessionHandle sessionid, ResourceEntry resourceEntry) { try { acquire(sessionid); SessionState ss = getSession(sessionid).getSessionState(); resourceEntry.location = ss.add_resource(SessionState.ResourceType.valueOf(resourceEntry.getType()), resourceEntry.getUri()); if (resourceEntry.location == null) { throw new NullPointerException("Resource's final location cannot be null"); } } finally { release(sessionid); } } /**
@Override public void preHook(Set<String> cur, List<String> s) throws IllegalArgumentException { super.preHook(cur, s); registerJars(s); } @Override
t.preHook(resourceSet, localized);
t.preHook(resourceSet, localized);
|| (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: add [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1);
t.postHook(resources, deleteList); resources.removeAll(deleteList);