@Test public void testProcessMessageAddition() 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.processMessageAddition(getMessage(getAddition()), null); assertDatabase(bindings, ipPrefixes); }
public static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter, NodeId nodeIdRemote) throws TlvNotFoundException { List<SxpDatabaseBinding> bindings = new ArrayList<>(); List<Peer> peers = new ArrayList<>(); peers.add(new PeerBuilder().setSeq(0).setNodeId(Preconditions.checkNotNull(nodeIdRemote)).build()); SxpDatabaseBindingBuilder bindingBuilder = new SxpDatabaseBindingBuilder().setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setPeerSequence(new PeerSequenceBuilder().setPeer(peers).build()) .setOrigin(NETWORK_ORIGIN); for (org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.protocol.rev141002.mapping.records.fields.MappingRecord mappingRecord : message .getMappingRecord()) { switch (mappingRecord.getOperationCode()) { case AddIpv4: case AddIpv6: bindingBuilder.setSecurityGroupTag( new Sgt(((SourceGroupTagTlvAttribute) MappingRecord.create(mappingRecord.getTlv()) .get(TlvType.Sgt)).getSourceGroupTagTlvAttributes().getSgt())); SxpDatabaseBinding binding = bindingBuilder.setIpPrefix(mappingRecord.getAddress()).build(); if (filter == null || !filter.apply(binding)) { bindings.add(binding); } break; } } return bindings; }
BindingHandler { public static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter, NodeId nodeIdRemote) throws TlvNotFoundException { List<SxpDatabaseBinding> bindings = new ArrayList<>(); List<Peer> peers = new ArrayList<>(); peers.add(new PeerBuilder().setSeq(0).setNodeId(Preconditions.checkNotNull(nodeIdRemote)).build()); SxpDatabaseBindingBuilder bindingBuilder = new SxpDatabaseBindingBuilder().setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setPeerSequence(new PeerSequenceBuilder().setPeer(peers).build()) .setOrigin(NETWORK_ORIGIN); for (org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.protocol.rev141002.mapping.records.fields.MappingRecord mappingRecord : message .getMappingRecord()) { switch (mappingRecord.getOperationCode()) { case AddIpv4: case AddIpv6: bindingBuilder.setSecurityGroupTag( new Sgt(((SourceGroupTagTlvAttribute) MappingRecord.create(mappingRecord.getTlv()) .get(TlvType.Sgt)).getSourceGroupTagTlvAttributes().getSgt())); SxpDatabaseBinding binding = bindingBuilder.setIpPrefix(mappingRecord.getAddress()).build(); if (filter == null || !filter.apply(binding)) { bindings.add(binding); } break; } } return bindings; } }
BindingHandler { public static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter, NodeId nodeIdRemote) throws TlvNotFoundException { List<SxpDatabaseBinding> bindings = new ArrayList<>(); List<Peer> peers = new ArrayList<>(); peers.add(new PeerBuilder().setSeq(0).setNodeId(Preconditions.checkNotNull(nodeIdRemote)).build()); SxpDatabaseBindingBuilder bindingBuilder = new SxpDatabaseBindingBuilder().setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setPeerSequence(new PeerSequenceBuilder().setPeer(peers).build()) .setOrigin(NETWORK_ORIGIN); for (org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.protocol.rev141002.mapping.records.fields.MappingRecord mappingRecord : message .getMappingRecord()) { switch (mappingRecord.getOperationCode()) { case AddIpv4: case AddIpv6: bindingBuilder.setSecurityGroupTag( new Sgt(((SourceGroupTagTlvAttribute) MappingRecord.create(mappingRecord.getTlv()) .get(TlvType.Sgt)).getSourceGroupTagTlvAttributes().getSgt())); SxpDatabaseBinding binding = bindingBuilder.setIpPrefix(mappingRecord.getAddress()).build(); if (filter == null || !filter.apply(binding)) { bindings.add(binding); } break; } } return bindings; } BindingHandler(SxpNode node, BindingDispatcher dispatcher);  BindingHandler(SxpNode node, BindingDispatcher dispatcher, int bufferSize); }
BindingHandler { public static List<SxpDatabaseBinding> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter, NodeId nodeIdRemote) throws TlvNotFoundException { List<SxpDatabaseBinding> bindings = new ArrayList<>(); List<Peer> peers = new ArrayList<>(); peers.add(new PeerBuilder().setSeq(0).setNodeId(Preconditions.checkNotNull(nodeIdRemote)).build()); SxpDatabaseBindingBuilder bindingBuilder = new SxpDatabaseBindingBuilder().setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setPeerSequence(new PeerSequenceBuilder().setPeer(peers).build()) .setOrigin(NETWORK_ORIGIN); for (org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.protocol.rev141002.mapping.records.fields.MappingRecord mappingRecord : message .getMappingRecord()) { switch (mappingRecord.getOperationCode()) { case AddIpv4: case AddIpv6: bindingBuilder.setSecurityGroupTag( new Sgt(((SourceGroupTagTlvAttribute) MappingRecord.create(mappingRecord.getTlv()) .get(TlvType.Sgt)).getSourceGroupTagTlvAttributes().getSgt())); SxpDatabaseBinding binding = bindingBuilder.setIpPrefix(mappingRecord.getAddress()).build(); if (filter == null || !filter.apply(binding)) { bindings.add(binding); } break; } } return bindings; } 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> processMessageAddition(UpdateMessageLegacy message, SxpBindingFilter filter, NodeId nodeIdRemote) throws TlvNotFoundException { List<SxpDatabaseBinding> bindings = new ArrayList<>(); List<Peer> peers = new ArrayList<>(); peers.add(new PeerBuilder().setSeq(0).setNodeId(Preconditions.checkNotNull(nodeIdRemote)).build()); SxpDatabaseBindingBuilder bindingBuilder = new SxpDatabaseBindingBuilder().setTimestamp(TimeConv.toDt(System.currentTimeMillis())) .setPeerSequence(new PeerSequenceBuilder().setPeer(peers).build()) .setOrigin(NETWORK_ORIGIN); for (org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.protocol.rev141002.mapping.records.fields.MappingRecord mappingRecord : message .getMappingRecord()) { switch (mappingRecord.getOperationCode()) { case AddIpv4: case AddIpv6: bindingBuilder.setSecurityGroupTag( new Sgt(((SourceGroupTagTlvAttribute) MappingRecord.create(mappingRecord.getTlv()) .get(TlvType.Sgt)).getSourceGroupTagTlvAttributes().getSgt())); SxpDatabaseBinding binding = bindingBuilder.setIpPrefix(mappingRecord.getAddress()).build(); if (filter == null || !filter.apply(binding)) { bindings.add(binding); } break; } } return bindings; } 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);  }