private Boolean hasUniqueNames(ConfTreeOperations resources, String group) { MapOperations component = resources.getComponent(group); if (component == null) { log.info("Component was null for {} when checking unique names", group); return Boolean.FALSE; } return component.getOptionBool(UNIQUE_NAMES, Boolean.FALSE); }
protected void validateComponentProperties(ConfTreeOperations props) throws BadConfigException { for (String compName : props.getComponentNames()) { MapOperations mo = props.getComponent(compName); if (mo == null) continue; for (String key : mo.keySet()) { validatePropertyNamePrefix(key); } } }
protected void validateComponentProperties(ConfTreeOperations props) throws BadConfigException { for (String compName : props.getComponentNames()) { MapOperations mo = props.getComponent(compName); if (mo == null) continue; for (String key : mo.keySet()) { validatePropertyNamePrefix(key); } } }
private Boolean hasUniqueNames(ConfTreeOperations resources, String group) { MapOperations component = resources.getComponent(group); if (component == null) { log.info("Component was null for {} when checking unique names", group); return Boolean.FALSE; } return component.getOptionBool(UNIQUE_NAMES, Boolean.FALSE); }
/** * Get a component whose presence is mandatory * @param name component name * @return the mapping * @throws BadConfigException if the name is not there */ public MapOperations getMandatoryComponent(String name) throws BadConfigException { MapOperations ops = getComponent(name); if (ops == null) { throw new BadConfigException("Missing component " + name); } return ops; }
/** * Get a component option * @param name component name * @param option option name * @param defVal default value * @return resolved value */ public String getComponentOpt(String name, String option, String defVal) { MapOperations roleopts = getComponent(name); if (roleopts == null) { return defVal; } return roleopts.getOption(option, defVal); }
/** * Get a component option * @param name component name * @param option option name * @param defVal default value * @return resolved value */ public String getComponentOpt(String name, String option, String defVal) { MapOperations roleopts = getComponent(name); if (roleopts == null) { return defVal; } return roleopts.getOption(option, defVal); }
/** * Get a component whose presence is mandatory * @param name component name * @return the mapping * @throws BadConfigException if the name is not there */ public MapOperations getMandatoryComponent(String name) throws BadConfigException { MapOperations ops = getComponent(name); if (ops == null) { throw new BadConfigException("Missing component " + name); } return ops; }
/** * Get a component -adding it to the components map if * none with that name exists * @param name role * @return role mapping */ public MapOperations getOrAddComponent(String name) { MapOperations operations = getComponent(name); if (operations != null) { return operations; } //create a new instances Map<String, String> map = new HashMap<>(); confTree.components.put(name, map); return new MapOperations(name, map); }
/** * Get a component -adding it to the components map if * none with that name exists * @param name role * @return role mapping */ public MapOperations getOrAddComponent(String name) { MapOperations operations = getComponent(name); if (operations != null) { return operations; } //create a new instances Map<String, String> map = new HashMap<>(); confTree.components.put(name, map); return new MapOperations(name, map); }
public boolean isKeytabProvided() { String keytabLocalPath = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM) .get(SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH); String keytabName = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM) .get(SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME); return StringUtils.isNotBlank(keytabLocalPath) || StringUtils.isNotBlank(keytabName); }
public boolean isKeytabProvided() { String keytabLocalPath = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM) .get(SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH); String keytabName = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM) .get(SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME); return StringUtils.isNotBlank(keytabLocalPath) || StringUtils.isNotBlank(keytabName); }
private ComponentCommand getComponentCommand(String compCmdStr, ConfTreeOperations resources) { if (compCmdStr == null || compCmdStr.trim().length() < 2) { throw new IllegalArgumentException("Input cannot be null and must contain component and command."); } compCmdStr = compCmdStr.trim(); int splitIndex = compCmdStr.lastIndexOf(SPLIT_CHAR); if (splitIndex == -1 || splitIndex == 0 || splitIndex == compCmdStr.length() - 1) { throw new IllegalArgumentException("Input does not appear to be well-formed."); } String compStr = compCmdStr.substring(0, splitIndex); String cmdStr = compCmdStr.substring(splitIndex + 1); if (resources.getComponent(compStr) == null && !prefixRoleMap.containsKey(compStr)) { throw new IllegalArgumentException("Component " + compStr + " specified" + " in command order does not exist"); } Command cmd = Command.valueOf(cmdStr); if (cmd != Command.START) { throw new IllegalArgumentException("Dependency order can only be specified for START."); } return new ComponentCommand(compStr, cmd); }
public String getPrincipal () throws IOException { String principal = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM).get(SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL); if (SliderUtils.isUnset(principal)) { principal = UserGroupInformation.getLoginUser().getShortUserName(); log.info("No principal set in the slider configuration. Will use AM login" + " identity {} to attempt keytab-based login", principal); } return principal; }
public String getPrincipal () throws IOException { String principal = instanceDefinition.getAppConfOperations() .getComponent(SliderKeys.COMPONENT_AM).get(SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL); if (SliderUtils.isUnset(principal)) { principal = UserGroupInformation.getLoginUser().getShortUserName(); log.info("No principal set in the slider configuration. Will use AM login" + " identity {} to attempt keytab-based login", principal); } return principal; }
public void validateNodeCount(AggregateConf instanceDescription, String name, int min, int max) throws BadCommandArgumentsException { MapOperations component = instanceDescription.getResourceOperations().getComponent(name); int count; if (component == null) { count = 0; } else { count = component.getOptionInt(ResourceKeys.COMPONENT_INSTANCES, 0); } validateNodeCount(name, count, min, max); }
public void validateNodeCount(AggregateConf instanceDescription, String name, int min, int max) throws BadCommandArgumentsException { MapOperations component = instanceDescription.getResourceOperations().getComponent(name); int count; if (component == null) { count = 0; } else { count = component.getOptionInt(ResourceKeys.COMPONENT_INSTANCES, 0); } validateNodeCount(name, count, min, max); }
/** * return the HDFS path where the application package has been uploaded * manually or by using slider client (install package command) * * @param conf configuration * @param roleGroup name of component * @return */ public static String getApplicationDefinitionPath(ConfTreeOperations conf, String roleGroup) throws BadConfigException { String appDefPath = conf.getGlobalOptions().getMandatoryOption( AgentKeys.APP_DEF); if (roleGroup != null) { MapOperations component = conf.getComponent(roleGroup); if (component != null) { appDefPath = component.getOption(AgentKeys.APP_DEF, appDefPath); } } return appDefPath; }
/** * return the HDFS path where the application package has been uploaded * manually or by using slider client (install package command) * * @param conf configuration * @param roleGroup name of component * @return */ public static String getApplicationDefinitionPath(ConfTreeOperations conf, String roleGroup) throws BadConfigException { String appDefPath = conf.getGlobalOptions().getMandatoryOption( AgentKeys.APP_DEF); if (roleGroup != null) { MapOperations component = conf.getComponent(roleGroup); if (component != null) { appDefPath = component.getOption(AgentKeys.APP_DEF, appDefPath); } } return appDefPath; }
/** * append to a component option * @param key key * @return value * */ public String appendComponentOpt(String role, String key, String value) { if (SliderUtils.isUnset(value)) { return null; } MapOperations roleopts = getComponent(role); if (roleopts == null) { return null; } if (roleopts.containsKey(key)) { roleopts.put(key, roleopts.get(key) + "," + value); } else { roleopts.put(key, value); } return roleopts.get(key); } }