@Nonnull @JsonIgnore public LocationSpecifier getStartLocationSpecifier() { return LocationSpecifierFactory.load(LOCATION_SPECIFIER_FACTORY) .buildLocationSpecifier(_startLocation); } }
@JsonIgnore public LocationSpecifier getLocationSpecifier() { checkNotNull(_locationSpecifierFactory, PROP_LOCATION_SPECIFIER_FACTORY + " is null"); return LocationSpecifierFactory.load(_locationSpecifierFactory) .buildLocationSpecifier(_locationSpecifierInput); }
/** Generate a set of flows to do traceroute */ @VisibleForTesting Set<Flow> getFlows(String tag) { Set<Location> srcLocations = LocationSpecifierFactory.load(SRC_LOCATION_SPECIFIER_FACTORY) .buildLocationSpecifier(_sourceLocationStr) .resolve(_specifierContext); ImmutableSet.Builder<Flow> setBuilder = ImmutableSet.builder(); ImmutableSet.Builder<String> allProblems = ImmutableSet.builder(); // Perform cross-product of all locations to flows for (Location srcLocation : srcLocations) { try { Flow.Builder flowBuilder = headerConstraintsToFlow(_packetHeaderConstraints, srcLocation); setSourceLocation(flowBuilder, srcLocation); flowBuilder.setTag(tag); setBuilder.add(flowBuilder.build()); } catch (IllegalArgumentException e) { // Try to ignore silently if possible allProblems.add(e.getMessage()); } } Set<Flow> flows = setBuilder.build(); checkArgument( !flows.isEmpty(), "Could not construct a flow for traceroute. Found issues: %s", String.join(",", allProblems.build())); return flows; }
@VisibleForTesting static IpSpaceAssignment initSourceIpAssignment( String sourceLocation, String sourceIps, SpecifierContext specifierContext) { /* construct specifiers */ LocationSpecifier sourceLocationSpecifier = LocationSpecifierFactory.load(SRC_LOCATION_SPECIFIER_FACTORY) .buildLocationSpecifier(sourceLocation); IpSpaceSpecifier sourceIpSpaceSpecifier = IpSpaceSpecifierFactory.load(IP_SPECIFIER_FACTORY).buildIpSpaceSpecifier(sourceIps); /* resolve specifiers */ Set<Location> sourceLocations = sourceLocationSpecifier.resolve(specifierContext); return sourceIpSpaceSpecifier.resolve(sourceLocations, specifierContext); }