/** * Join an array of strings with a separator that appears after every * instance in the list -including at the end * @param collection strings * @param separator separator string * @return the joined entries */ public static String join(String[] collection, String separator) { return join(collection, separator, true); }
public String buildClasspath() { return SliderUtils.join(pathElements, CLASS_PATH_SEPARATOR, false); }
/** * Build the command line * @return the command line */ public String build() { return SliderUtils.join(argumentList, " "); }
/** * Build the command line * @return the command line */ public String build() { return SliderUtils.join(argumentList, " "); }
public String buildClasspath() { return SliderUtils.join(pathElements, CLASS_PATH_SEPARATOR, false); }
/** * Join an collection of objects with a separator that appears after every * instance in the list -including at the end * @param collection collection to call toString() on each element * @param separator separator string * @return the joined entries */ public static String join(Collection collection, String separator) { return join(collection, separator, true); }
/** * Join an collection of objects with a separator that appears after every * instance in the list -including at the end * @param collection collection to call toString() on each element * @param separator separator string * @return the joined entries */ public static String join(Collection collection, String separator) { return join(collection, separator, true); }
/** * Join an array of strings with a separator that appears after every * instance in the list -including at the end * @param collection strings * @param separator separator string * @return the joined entries */ public static String join(String[] collection, String separator) { return join(collection, separator, true); }
/** * Join an array of strings with a separator that appears after every * instance in the list -optionally at the end * @param collection strings * @param separator separator string * @param trailing add a trailing entry or not * @return the joined entries */ public static String join(String[] collection, String separator, boolean trailing) { return join(Arrays.asList(collection), separator, trailing); }
/** * Join an array of strings with a separator that appears after every * instance in the list -optionally at the end * @param collection strings * @param separator separator string * @param trailing add a trailing entry or not * @return the joined entries */ public static String join(String[] collection, String separator, boolean trailing) { return join(Arrays.asList(collection), separator, trailing); }
public static String buildConnectionString(String zkHosts, int port) { String zkPort = Integer.toString(port); //parse the hosts String[] hostlist = zkHosts.split(",", 0); String quorum = SliderUtils.join(hostlist, ":" + zkPort + ",", false); return quorum; }
public static String buildConnectionString(String zkHosts, int port) { String zkPort = Integer.toString(port); //parse the hosts String[] hostlist = zkHosts.split(",", 0); String quorum = SliderUtils.join(hostlist, ":" + zkPort + ",", false); return quorum; }
/** * Get all commands as a string, separated by ";". This is for diagnostics * @return a string description of the commands */ public String getCommandsAsString() { return SliderUtils.join(getCommands(), "; "); }
/** * Get all commands as a string, separated by ";". This is for diagnostics * @return a string description of the commands */ public String getCommandsAsString() { return SliderUtils.join(getCommands(), "; "); }
/** * Build a quorum list, injecting a ":defaultPort" ref if needed on * any entry without one * @param hostAndPorts * @param defaultPort * @return */ public static String buildQuorum(List<HostAndPort> hostAndPorts, int defaultPort) { List<String> entries = new ArrayList<String>(hostAndPorts.size()); for (HostAndPort hostAndPort : hostAndPorts) { entries.add(buildQuorumEntry(hostAndPort, defaultPort)); } return SliderUtils.join(entries, ",", false); }
/** * Build a quorum list, injecting a ":defaultPort" ref if needed on * any entry without one * @param hostAndPorts * @param defaultPort * @return */ public static String buildQuorum(List<HostAndPort> hostAndPorts, int defaultPort) { List<String> entries = new ArrayList<String>(hostAndPorts.size()); for (HostAndPort hostAndPort : hostAndPorts) { entries.add(buildQuorumEntry(hostAndPort, defaultPort)); } return SliderUtils.join(entries, ",", false); }
public static String requestToString(AMRMClient.ContainerRequest request) { Preconditions.checkArgument(request != null, "Null request"); StringBuilder buffer = new StringBuilder(request.toString()); buffer.append("; "); buffer.append("relaxLocality=").append(request.getRelaxLocality()).append("; "); String labels = request.getNodeLabelExpression(); if (labels != null) { buffer.append("nodeLabels=").append(labels).append("; "); } List<String> nodes = request.getNodes(); if (nodes != null) { buffer.append("Nodes = [ "); int size = nodes.size(); for (int i = 0; i < Math.min(NODE_LIST_LIMIT, size); i++) { buffer.append(nodes.get(i)).append(' '); } if (size > NODE_LIST_LIMIT) { buffer.append(String.format("...(total %d entries)", size)); } buffer.append("]; "); } List<String> racks = request.getRacks(); if (racks != null) { buffer.append("racks = [") .append(join(racks, ", ", false)) .append("]; "); } return buffer.toString(); }
protected static String getPackageListFromApplication(Application application) { String pkgFormatString = "{\"type\":\"%s\",\"name\":\"%s\"}"; String pkgListFormatString = "[%s]"; List<String> packages = new ArrayList<>(); if (application != null) { if (application.getPackages().size() > 0) { // no-op if there are packages that are not OS-specific, as these // will be localized by AM rather than the Agent // this should be backwards compatible, as there was previously an // XML parsing bug that ensured non-OS-specific packages did not exist } else { List<OSSpecific> osSpecifics = application.getOSSpecifics(); if (osSpecifics != null && osSpecifics.size() > 0) { for (OSSpecific osSpecific : osSpecifics) { if (osSpecific.getOsType().equals("any")) { for (OSPackage osPackage : osSpecific.getPackages()) { packages.add(String.format(pkgFormatString, osPackage.getType(), osPackage.getName())); } } } } } } if (!packages.isEmpty()) { return "[" + SliderUtils.join(packages, ",", false) + "]"; } else { return "[]"; } }
/** * Parse routine -includes registering the action-specific argument classes * and postprocess it * @throws SliderException on any problem */ public void parse() throws SliderException { addActionArguments(); try { commander.parse(getArgs()); } catch (ParameterException e) { throw new BadCommandArgumentsException(e, "%s in %s", e.toString(), (getArgs() != null ? (SliderUtils.join(getArgs(), " ", false)) : "[]")); } //now copy back to this class some of the attributes that are common to all //actions postProcess(); }
/** * Parse routine -includes registering the action-specific argument classes * and postprocess it * @throws SliderException on any problem */ public void parse() throws SliderException { addActionArguments(); try { commander.parse(getArgs()); } catch (ParameterException e) { throw new BadCommandArgumentsException(e, "%s in %s", e.toString(), (getArgs() != null ? (SliderUtils.join(getArgs(), " ", false)) : "[]")); } //now copy back to this class some of the attributes that are common to all //actions postProcess(); }