congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
AbstractRoute.getNetwork
Code IndexAdd Tabnine to your IDE (free)

How to use
getNetwork
method
in
org.batfish.datamodel.AbstractRoute

Best Java code snippets using org.batfish.datamodel.AbstractRoute.getNetwork (Showing top 20 results out of 315)

origin: batfish/batfish

/**
 * Remove a route from backup route map if it was present and backup route map exists
 *
 * @param route Route to remove
 */
public final void removeBackupRoute(R route) {
 if (_backupRoutes != null) {
  SortedSet<R> routes = _backupRoutes.get(route.getNetwork());
  if (routes != null) {
   routes.remove(route);
  }
 }
}
origin: batfish/batfish

/**
 * Add route to backup route map if the route map is not null
 *
 * @param route Route to add
 */
public final void addBackupRoute(R route) {
 if (_backupRoutes != null) {
  _backupRoutes.computeIfAbsent(route.getNetwork(), k -> new TreeSet<>()).add(route);
 }
}
origin: batfish/batfish

 @Override
 protected Prefix featureValueOf(AbstractRoute actual) {
  return actual.getNetwork();
 }
}
origin: batfish/batfish

/**
 * Indicate that a route was added to the RIB
 *
 * @param route that was added
 */
public Builder<R> add(R route) {
 LinkedHashMap<R, RouteAdvertisement<R>> l =
   _actions.computeIfAbsent(route.getNetwork(), p -> new LinkedHashMap<>(10, 1, true));
 l.put(route, new RouteAdvertisement<>(route));
 return this;
}
origin: batfish/batfish

@Override
public final SortedSet<Prefix> getPrefixes() {
 SortedSet<Prefix> prefixes = new TreeSet<>();
 Set<R> routes = getRoutes();
 for (R route : routes) {
  prefixes.add(route.getNetwork());
 }
 return prefixes;
}
origin: batfish/batfish

@Override
public Prefix evaluate(Environment env) {
 return env.getOriginalRoute().getNetwork();
}
origin: batfish/batfish

/**
 * Indicate that multiple routes have been added to the RIB
 *
 * @param routes a collection of routes
 */
public Builder<R> add(Collection<? extends R> routes) {
 for (R route : routes) {
  LinkedHashMap<R, RouteAdvertisement<R>> l =
    _actions.computeIfAbsent(route.getNetwork(), p -> new LinkedHashMap<>(10, 1, true));
  l.put(route, new RouteAdvertisement<>(route));
 }
 return this;
}
origin: batfish/batfish

public final Set<R> getRoutes(Prefix p) {
 // Collect routes that match the prefix
 return getRoutes().stream()
   .filter(r -> r.getNetwork().equals(p))
   .collect(ImmutableSet.toImmutableSet());
}
origin: batfish/batfish

/**
 * Indicate that a route was removed from the RIB
 *
 * @param route that was removed
 */
public Builder<R> remove(R route, Reason reason) {
 LinkedHashMap<R, RouteAdvertisement<R>> l =
   _actions.computeIfAbsent(route.getNetwork(), p -> new LinkedHashMap<>(10, 1, true));
 l.put(
   route,
   RouteAdvertisement.<R>builder()
     .setRoute(route)
     .setWithdraw(true)
     .setReason(reason)
     .build());
 return this;
}
origin: batfish/batfish

/**
 * Remove a single route from the RIB, if it exists
 *
 * @param route route to remove
 * @return {@link RibDelta} if the route was removed, otherwise {@code null};
 */
@Nonnull
RibDelta<R> removeRouteGetDelta(R route, Reason reason) {
 Prefix prefix = route.getNetwork();
 int prefixLength = prefix.getPrefixLength();
 long bits = prefix.getStartIp().asLong();
 return _root.removeRoute(route, bits, prefixLength, 0, reason);
}
origin: batfish/batfish

@Nonnull
RibDelta<R> removeRoute(
  R route, long bits, int prefixLength, int firstUnmatchedBitIndex, Reason reason) {
 RibTreeNode<R> node = findRouteNode(bits, prefixLength, firstUnmatchedBitIndex);
 if (node == null) {
  // No effect, return empty
  return RibDelta.empty();
 }
 Builder<R> b = RibDelta.builder();
 if (node._routes.remove(route)) {
  b.remove(route, reason);
  if (node._routes.isEmpty() && _owner._backupRoutes != null) {
   SortedSet<? extends R> backups =
     _owner._backupRoutes.getOrDefault(route.getNetwork(), ImmutableSortedSet.of());
   if (!backups.isEmpty()) {
    node._routes.add(backups.first());
    b.add(backups.first());
   }
  }
 }
 // Return new delta
 return b.build();
}
origin: batfish/batfish

/**
 * Add a new route into the RIB, potentially replacing other routes
 *
 * @param route route to add
 * @return a {@link RibDelta} objects indicating which routes where added and evicted from this
 *     RIB
 */
@Nonnull
RibDelta<R> mergeRoute(R route) {
 Prefix prefix = route.getNetwork();
 int prefixLength = prefix.getPrefixLength();
 long bits = prefix.getStartIp().asLong();
 return _root.mergeRoute(route, bits, prefixLength, 0);
}
origin: batfish/batfish

/**
 * Indicate that multiple routes were removed from the RIB
 *
 * @param routes that were removed
 */
public Builder<R> remove(Collection<R> routes, Reason reason) {
 for (R route : routes) {
  LinkedHashMap<R, RouteAdvertisement<R>> l =
    _actions.computeIfAbsent(route.getNetwork(), p -> new LinkedHashMap<>(10, 1, true));
  l.put(
    route,
    RouteAdvertisement.<R>builder()
      .setRoute(route)
      .setWithdraw(true)
      .setReason(reason)
      .build());
 }
 return this;
}
origin: batfish/batfish

 /**
  * Check if a static route with next hop IP can be activated. If this method returns True, an
  * attempt should be made to merge it into the RIB. If it returns false, an attempt should be made
  * to remove it from the RIB.
  *
  * @param route a {@link StaticRoute} to check
  * @param rib the RIB to use for establishing routabilitity to next hop IP
  */
 public static boolean shouldActivateNextHopIpRoute(
   @Nonnull StaticRoute route, @Nonnull GenericRib<AbstractRoute> rib) {
  Set<AbstractRoute> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp());

  if (matchingRoutes.isEmpty()) {
   // Cannot activate, next hop ip is unreachable
   return false;
  }

  boolean shouldActivate = false;
  for (AbstractRoute routeToNextHop : matchingRoutes) {
   if (!routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)) {
    // Next hop has to be reachable through a route with a different prefix
    shouldActivate = true;
    break;
   }
  }
  return shouldActivate;
 }
}
origin: batfish/batfish

/**
 * Check if the route is present in the RIB
 *
 * @param route route to find
 * @return true if the route exists in the RIB
 */
boolean containsRoute(R route) {
 Prefix prefix = route.getNetwork();
 int prefixLength = prefix.getPrefixLength();
 long bits = prefix.getStartIp().asLong();
 return _root.containsRoute(route, bits, prefixLength);
}
origin: batfish/batfish

 /** Process all added and removed routes from a given delta */
 @Nonnull
 public <T extends R> Builder<R> from(@Nonnull RibDelta<T> delta) {
  for (RouteAdvertisement<T> a : delta.getActions()) {
   LinkedHashMap<R, RouteAdvertisement<R>> l =
     _actions.computeIfAbsent(
       a.getRoute().getNetwork(), p -> new LinkedHashMap<>(10, 1, true));
   l.put(
     a.getRoute(),
     RouteAdvertisement.<R>builder()
       .setRoute(a.getRoute())
       .setWithdraw(a.isWithdrawn())
       .setReason(a.getReason())
       .build());
  }
  return this;
 }
}
origin: batfish/batfish

@Override
public Result evaluate(Environment environment) {
 AbstractRoute route = environment.getOriginalRoute();
 Prefix network = route.getNetwork();
 int classSize = network.getStartIp().getClassNetworkSize();
 Result ret = new Result();
 ret.setBooleanValue(classSize == network.getPrefixLength());
 return ret;
}
origin: batfish/batfish

 outputRouteBuilder.setDestinationAsn(_asn);
outputRouteBuilder.setNetwork(potentialExportRoute.getNetwork());
outputRouteBuilder.setProcessAsn(_asn);
outputRouteBuilder.setNonRouting(true);
origin: batfish/batfish

    .toRoutingProtocol()
    .getDefaultAdministrativeCost(_c.getConfigurationFormat()));
outputRouteBuilder.setNetwork(potentialExportRoute.getNetwork());
Long maxMetricExternalNetworks = proc.getMaxMetricExternalNetworks();
long costToAdvertiser;
origin: batfish/batfish

/**
 * Converts a {@link AbstractRoute} to a {@link Row}
 *
 * @param hostName {@link String} host-name of the node containing the route
 * @param vrfName {@link String} name of the VRF containing the route
 * @param abstractRoute {@link AbstractRoute} to convert
 * @param columnMetadataMap Column metadata of the columns for this {@link Row} c
 * @return {@link Row} representing the {@link AbstractRoute}
 */
private static Row abstractRouteToRow(
  String hostName,
  String vrfName,
  AbstractRoute abstractRoute,
  Map<String, ColumnMetadata> columnMetadataMap,
  @Nullable Map<Ip, Set<String>> ipOwners) {
 return Row.builder(columnMetadataMap)
   .put(COL_NODE, new Node(hostName))
   .put(COL_VRF_NAME, vrfName)
   .put(COL_NETWORK, abstractRoute.getNetwork())
   .put(COL_NEXT_HOP_IP, abstractRoute.getNextHopIp())
   .put(COL_NEXT_HOP, computeNextHopNode(abstractRoute.getNextHopIp(), ipOwners))
   .put(COL_PROTOCOL, abstractRoute.getProtocol())
   .put(
     COL_TAG, abstractRoute.getTag() == AbstractRoute.NO_TAG ? null : abstractRoute.getTag())
   .put(COL_ADMIN_DISTANCE, abstractRoute.getAdministrativeCost())
   .put(COL_METRIC, abstractRoute.getMetric())
   .build();
}
org.batfish.datamodelAbstractRoutegetNetwork

Javadoc

IPV4 network of this route

Popular methods of AbstractRoute

  • getMetric
  • getNextHopIp
    Next hop IP for this route. If not known, Route#UNSET_ROUTE_NEXT_HOP_IP must be returned.
  • getProtocol
  • getNextHopInterface
    Name of the next-hop interface for this route. If not known, Route#UNSET_NEXT_HOP_INTERFACE must be
  • getNonForwarding
    Returns true if this route is non-forwarding, i.e., it can be installed in the main RIB but not the
  • getTag
    Return the route's tag or #NO_TAG if no tag is present
  • getAdministrativeCost
  • getNonRouting
    Check if this route is "non-routing", i.e., should not be installed in the main RIB.
  • toBuilder
    Return a AbstractRouteBuilder pre-populated with the values for this route.

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JButton (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now