@Override protected Long featureValueOf(AbstractRoute actual) { return actual.getMetric(); } }
@Override public long evaluate(Environment environment) { long oldMetric = environment.getOriginalRoute().getMetric(); long newVal = oldMetric - _subtrahend; return newVal; }
@Override public long evaluate(Environment environment) { long oldMetric = environment.getOriginalRoute().getMetric(); long newVal = oldMetric + _addend; return newVal; }
@Override public long evaluate(Environment environment) { return environment.getOriginalRoute().getMetric(); }
/** * Attempt to calculate the cost to reach given routes next hop IP. * * @param route bgp route * @return if next hop IP matches a route we have, returns the metric for that route; otherwise * {@link Long#MAX_VALUE} */ private long getIgpCostToNextHopIp(BgpRoute route) { if (_mainRib == null) { return Long.MAX_VALUE; } Set<AbstractRoute> s = _mainRib.longestPrefixMatch(route.getNextHopIp()); return s == null || s.isEmpty() ? Long.MAX_VALUE : s.iterator().next().getMetric(); } }
computeNextHopNode(route.getNextHopIp(), ipOwners)) .setAdminDistance(route.getAdministrativeCost()) .setMetric(route.getMetric()) .setTag(route.getTag()) .build()));
/** * 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(); }
transformedOutgoingRouteBuilder.setMetric(route.getMetric());
environment.setIntermediateBgpAttributes(ir); AbstractRoute or = environment.getOriginalRoute(); ir.setMetric(or.getMetric()); ir.setTag(or.getTag());