@Test public void testGetPortRangesFromList() { Map<Integer, Integer> portRanges = Maps.newHashMap(); portRanges.put(5, 7); portRanges.put(10, 11); portRanges.put(20, 20); assertEquals(portRanges, ComputeServiceUtils.getPortRangesFromList(5, 6, 7, 10, 11, 20)); }
public static Map<Integer, Integer> getPortRangesFromList(int... ports) { Set<Integer> sortedPorts = ImmutableSortedSet.copyOf(Ints.asList(ports)); RangeSet<Integer> ranges = TreeRangeSet.create(); for (Integer port : sortedPorts) { ranges.add(Range.closedOpen(port, port + 1)); } Map<Integer, Integer> portRanges = Maps.newHashMap(); for (Range<Integer> r : ranges.asRanges()) { portRanges.put(r.lowerEndpoint(), r.upperEndpoint() - 1); } return portRanges; }
ComputeServiceUtils { public static Map<Integer, Integer> getPortRangesFromList(int... ports) { Set<Integer> sortedPorts = ImmutableSortedSet.copyOf(Ints.asList(ports)); RangeSet<Integer> ranges = TreeRangeSet.create(); for (Integer port : sortedPorts) { ranges.add(Range.closedOpen(port, port + 1)); } Map<Integer, Integer> portRanges = Maps.newHashMap(); for (Range<Integer> r : ranges.asRanges()) { portRanges.put(r.lowerEndpoint(), r.upperEndpoint() - 1); } return portRanges; } }
ComputeServiceUtils { public static Map<Integer, Integer> getPortRangesFromList(int... ports) { Set<Integer> sortedPorts = ImmutableSortedSet.copyOf(Ints.asList(ports)); RangeSet<Integer> ranges = TreeRangeSet.create(); for (Integer port : sortedPorts) { ranges.add(Range.closedOpen(port, port + 1)); } Map<Integer, Integer> portRanges = Maps.newHashMap(); for (Range<Integer> r : ranges.asRanges()) { portRanges.put(r.lowerEndpoint(), r.upperEndpoint() - 1); } return portRanges; }  }
ComputeServiceUtils { public static Map<Integer, Integer> getPortRangesFromList(int... ports) { Set<Integer> sortedPorts = ImmutableSortedSet.copyOf(Ints.asList(ports)); RangeSet<Integer> ranges = TreeRangeSet.create(); for (Integer port : sortedPorts) { ranges.add(Range.closedOpen(port, port + 1)); } Map<Integer, Integer> portRanges = Maps.newHashMap(); for (Range<Integer> r : ranges.asRanges()) { portRanges.put(r.lowerEndpoint(), r.upperEndpoint() - 1); } return portRanges; }  static String formatStatus(ComputeMetadataIncludingStatus<?> resource); static Statement execHttpResponse(HttpRequest request); static Statement execHttpResponse(URI location); static Statement extractTargzIntoDirectory(HttpRequest targz, String directory); static Statement extractTargzIntoDirectory(URI targz, String directory); static Statement extractZipIntoDirectory(HttpRequest zip, String directory); static Statement extractZipIntoDirectory(URI zip, String directory); static double getCores(Hardware input); static double getCoresAndSpeed(Hardware input); static double getSpace(Hardware input); static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String in); static String createExecutionErrorMessage(Map<?, Exception> executionExceptions); static String createNodeErrorMessage(Map<? extends NodeMetadata, ? extends Throwable> failedNodes); static Iterable<? extends ComputeMetadata> filterByName(Iterable<? extends ComputeMetadata> nodes,
            final String name); static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options); static NodeMetadataBuilder addMetadataAndParseTagsFromValuesOfEmptyString(NodeMetadataBuilder builder,
            Map<String, String> map); static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options); static NodeMetadataBuilder addMetadataAndParseTagsFromCommaDelimitedValue(NodeMetadataBuilder builder,
            Map<String, String> map); static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, String in,
            Map<OsFamily, Map<String, String>> osVersionMap); static Map<Integer, Integer> getPortRangesFromList(int... ports); static String groupFromMapOrName(Map<String, String> metadataMap, String nodeName, GroupNamingConvention namingConvention); }
ComputeServiceUtils { public static Map<Integer, Integer> getPortRangesFromList(int... ports) { Set<Integer> sortedPorts = ImmutableSortedSet.copyOf(Ints.asList(ports)); RangeSet<Integer> ranges = TreeRangeSet.create(); for (Integer port : sortedPorts) { ranges.add(Range.closedOpen(port, port + 1)); } Map<Integer, Integer> portRanges = Maps.newHashMap(); for (Range<Integer> r : ranges.asRanges()) { portRanges.put(r.lowerEndpoint(), r.upperEndpoint() - 1); } return portRanges; }  static String formatStatus(ComputeMetadataIncludingStatus<?> resource); static Statement execHttpResponse(HttpRequest request); static Statement execHttpResponse(URI location); static Statement extractTargzIntoDirectory(HttpRequest targz, String directory); static Statement extractTargzIntoDirectory(URI targz, String directory); static Statement extractZipIntoDirectory(HttpRequest zip, String directory); static Statement extractZipIntoDirectory(URI zip, String directory); static double getCores(Hardware input); static double getCoresAndSpeed(Hardware input); static double getSpace(Hardware input); static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String in); static String createExecutionErrorMessage(Map<?, Exception> executionExceptions); static String createNodeErrorMessage(Map<? extends NodeMetadata, ? extends Throwable> failedNodes); static Iterable<? extends ComputeMetadata> filterByName(Iterable<? extends ComputeMetadata> nodes,
            final String name); static Map<String, String> metadataAndTagsAsValuesOfEmptyString(TemplateOptions options); static NodeMetadataBuilder addMetadataAndParseTagsFromValuesOfEmptyString(NodeMetadataBuilder builder,
            Map<String, String> map); static Map<String, String> metadataAndTagsAsCommaDelimitedValue(TemplateOptions options); static NodeMetadataBuilder addMetadataAndParseTagsFromCommaDelimitedValue(NodeMetadataBuilder builder,
            Map<String, String> map); static String parseVersionOrReturnEmptyString(org.jclouds.compute.domain.OsFamily family, String in,
            Map<OsFamily, Map<String, String>> osVersionMap); static Map<Integer, Integer> getPortRangesFromList(int... ports); static String groupFromMapOrName(Map<String, String> metadataMap, String nodeName, GroupNamingConvention namingConvention); static final Pattern DELIMITED_BY_HYPHEN_ENDING_IN_HYPHEN_HEX; }