@Test public void testProcessMessageDeletion() throws Exception { List<IpPrefix> ipPrefixes = getIpPrefixes("127.0.0.0/32", "127.0.10.2/32"); ipPrefixes.addAll(getIpPrefixes("2001:0:0:0:0:0:0:1/128", "2001:0:0:0:0:0:0:0/64")); ipPrefixes.add(IpPrefixBuilder.getDefaultInstance("128.0.0.0/32")); ipPrefixes.add(IpPrefixBuilder.getDefaultInstance("128.50.0.0/24")); ipPrefixes.add(IpPrefixBuilder.getDefaultInstance("2001:0:0:0:0:0:0:8/32")); ipPrefixes.add(IpPrefixBuilder.getDefaultInstance("2001:0:0:0:0:C:0:8/128")); List<SxpDatabaseBinding> bindings = BindingHandler.processMessageDeletion(getMessage(getDeletion())); assertDatabase(bindings, ipPrefixes); }
public static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message) { List<IpPrefix> prefixes = new ArrayList<>(); SxpDatabaseBindingBuilder bindingsBuilder = new SxpDatabaseBindingBuilder().setSecurityGroupTag(new Sgt(Configuration.DEFAULT_PREFIX_GROUP)) .setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setOrigin(NETWORK_ORIGIN) .setPeerSequence(new PeerSequenceBuilder().setPeer(new ArrayList<>()).build()); for (Attribute attribute : message.getAttribute()) { if (attribute.getFlags().isOptional() && (attribute.getFlags().isPartial() || !attribute.getFlags() .isNonTransitive())) { continue; } switch (attribute.getType()) { case DelIpv4: prefixes.add( ((DeleteIpv4Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv4Attributes() .getIpPrefix()); break; case DelIpv6: prefixes.add( ((DeleteIpv6Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv6Attributes() .getIpPrefix()); break; case Ipv4DeletePrefix: prefixes.addAll( ((Ipv4DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv4DeletePrefixAttributes() .getIpPrefix()); break; case Ipv6DeletePrefix: prefixes.addAll( ((Ipv6DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv6DeletePrefixAttributes() .getIpPrefix()); break; } } return prefixes.stream().map(p -> bindingsBuilder.setIpPrefix(p).build()).collect(Collectors.toList()); }
BindingHandler { public static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message) { List<IpPrefix> prefixes = new ArrayList<>(); SxpDatabaseBindingBuilder bindingsBuilder = new SxpDatabaseBindingBuilder().setSecurityGroupTag(new Sgt(Configuration.DEFAULT_PREFIX_GROUP)) .setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setOrigin(NETWORK_ORIGIN) .setPeerSequence(new PeerSequenceBuilder().setPeer(new ArrayList<>()).build()); for (Attribute attribute : message.getAttribute()) { if (attribute.getFlags().isOptional() && (attribute.getFlags().isPartial() || !attribute.getFlags() .isNonTransitive())) { continue; } switch (attribute.getType()) { case DelIpv4: prefixes.add( ((DeleteIpv4Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv4Attributes() .getIpPrefix()); break; case DelIpv6: prefixes.add( ((DeleteIpv6Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv6Attributes() .getIpPrefix()); break; case Ipv4DeletePrefix: prefixes.addAll( ((Ipv4DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv4DeletePrefixAttributes() .getIpPrefix()); break; case Ipv6DeletePrefix: prefixes.addAll( ((Ipv6DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv6DeletePrefixAttributes() .getIpPrefix()); break; } } return prefixes.stream().map(p -> bindingsBuilder.setIpPrefix(p).build()).collect(Collectors.toList()); } }
BindingHandler { public static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message) { List<IpPrefix> prefixes = new ArrayList<>(); SxpDatabaseBindingBuilder bindingsBuilder = new SxpDatabaseBindingBuilder().setSecurityGroupTag(new Sgt(Configuration.DEFAULT_PREFIX_GROUP)) .setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setOrigin(NETWORK_ORIGIN) .setPeerSequence(new PeerSequenceBuilder().setPeer(new ArrayList<>()).build()); for (Attribute attribute : message.getAttribute()) { if (attribute.getFlags().isOptional() && (attribute.getFlags().isPartial() || !attribute.getFlags() .isNonTransitive())) { continue; } switch (attribute.getType()) { case DelIpv4: prefixes.add( ((DeleteIpv4Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv4Attributes() .getIpPrefix()); break; case DelIpv6: prefixes.add( ((DeleteIpv6Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv6Attributes() .getIpPrefix()); break; case Ipv4DeletePrefix: prefixes.addAll( ((Ipv4DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv4DeletePrefixAttributes() .getIpPrefix()); break; case Ipv6DeletePrefix: prefixes.addAll( ((Ipv6DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv6DeletePrefixAttributes() .getIpPrefix()); break; } } return prefixes.stream().map(p -> bindingsBuilder.setIpPrefix(p).build()).collect(Collectors.toList()); } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); }
BindingHandler { public static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message) { List<IpPrefix> prefixes = new ArrayList<>(); SxpDatabaseBindingBuilder bindingsBuilder = new SxpDatabaseBindingBuilder().setSecurityGroupTag(new Sgt(Configuration.DEFAULT_PREFIX_GROUP)) .setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setOrigin(NETWORK_ORIGIN) .setPeerSequence(new PeerSequenceBuilder().setPeer(new ArrayList<>()).build()); for (Attribute attribute : message.getAttribute()) { if (attribute.getFlags().isOptional() && (attribute.getFlags().isPartial() || !attribute.getFlags() .isNonTransitive())) { continue; } switch (attribute.getType()) { case DelIpv4: prefixes.add( ((DeleteIpv4Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv4Attributes() .getIpPrefix()); break; case DelIpv6: prefixes.add( ((DeleteIpv6Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv6Attributes() .getIpPrefix()); break; case Ipv4DeletePrefix: prefixes.addAll( ((Ipv4DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv4DeletePrefixAttributes() .getIpPrefix()); break; case Ipv6DeletePrefix: prefixes.addAll( ((Ipv6DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv6DeletePrefixAttributes() .getIpPrefix()); break; } } return prefixes.stream().map(p -> bindingsBuilder.setIpPrefix(p).build()).collect(Collectors.toList()); } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); void setBufferLimit(int limit); static Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter,
            NodeId nodeIdRemote); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessage message, SxpBindingFilter filter); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessageLegacy message); ListenableFuture<Void> processPurgeAllMessage(final SxpConnection connection); void processUpdate(final List<T> databaseDelete, final List<T> databaseAdd,
            final SxpConnection connection); }
BindingHandler { public static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message) { List<IpPrefix> prefixes = new ArrayList<>(); SxpDatabaseBindingBuilder bindingsBuilder = new SxpDatabaseBindingBuilder().setSecurityGroupTag(new Sgt(Configuration.DEFAULT_PREFIX_GROUP)) .setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setOrigin(NETWORK_ORIGIN) .setPeerSequence(new PeerSequenceBuilder().setPeer(new ArrayList<>()).build()); for (Attribute attribute : message.getAttribute()) { if (attribute.getFlags().isOptional() && (attribute.getFlags().isPartial() || !attribute.getFlags() .isNonTransitive())) { continue; } switch (attribute.getType()) { case DelIpv4: prefixes.add( ((DeleteIpv4Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv4Attributes() .getIpPrefix()); break; case DelIpv6: prefixes.add( ((DeleteIpv6Attribute) attribute.getAttributeOptionalFields()).getDeleteIpv6Attributes() .getIpPrefix()); break; case Ipv4DeletePrefix: prefixes.addAll( ((Ipv4DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv4DeletePrefixAttributes() .getIpPrefix()); break; case Ipv6DeletePrefix: prefixes.addAll( ((Ipv6DeletePrefixAttribute) attribute.getAttributeOptionalFields()).getIpv6DeletePrefixAttributes() .getIpPrefix()); break; } } return prefixes.stream().map(p -> bindingsBuilder.setIpPrefix(p).build()).collect(Collectors.toList()); } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); void setBufferLimit(int limit); static Stream<T> loopDetection(NodeId nodeId, Stream<T> bindings); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter,
            NodeId nodeIdRemote); static List<SxpDatabaseBinding> processMessageAddition(UpdateMessage message, SxpBindingFilter filter); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessage message); static List<SxpDatabaseBinding> processMessageDeletion(UpdateMessageLegacy message); ListenableFuture<Void> processPurgeAllMessage(final SxpConnection connection); void processUpdate(final List<T> databaseDelete, final List<T> databaseAdd,
            final SxpConnection connection);  }