@Test public void testAddFilter() throws Exception { when(sxpNode.getDomains()).thenReturn(domains); domain.putConnection(getSxpConnection("127.0.0.1")); assertTrue(domain.addFilter(getFilter(FilterSpecific.AccessOrPrefixList, "domain8"))); assertTrue(domain.addFilter(getFilter(FilterSpecific.AccessOrPrefixList, "domain1"))); assertTrue(domain.addFilter(getFilter(FilterSpecific.PeerSequence, "domain1"))); assertFalse(domain.addFilter(getFilter(FilterSpecific.AccessOrPrefixList, "domain1"))); assertFalse(domain.addFilter(getFilter(FilterSpecific.AccessOrPrefixList, "domain5", "domain1"))); MasterDatabaseInf masterDB = domain.getMasterDatabase(); verify(masterDB, times(2)).addBindings(anyList()); }
public boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter) { checkFilter(filter); if (filter.getSxpFilter().getDomains().getDomain().isEmpty() || filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(d -> d.getName().equals(getName())) || checkDomainOverlap( filter.getSxpFilter().getFilterSpecific(), filter.getSxpFilter().getDomains())) { return false; } synchronized (filters) { if (filters.get(filter.getSxpFilter().getFilterSpecific()) .containsKey(filter.getSxpFilter().getFilterName())) { return false; } filters.get(filter.getSxpFilter().getFilterSpecific()).put(filter.getSxpFilter().getFilterName(), filter); } for (SxpDomain domain : node.getDomains()) { if (!domain.getName().equals(getName()) && filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(f -> f.getName().equals(domain.getName()))) { propagateToSharedMasterDatabases(Collections.emptyList(), getMasterDatabase().getBindings(BindingOriginsConfig.LOCAL_ORIGIN).stream().filter(filter).collect(Collectors.toList()), domain); getConnections().stream().filter(SxpConnection::isModeListener).forEach(c -> { propagateToSharedSxpDatabases(Collections.emptyList(), getSxpDatabase().getBindings(c.getId()) .stream() .filter(filter) .collect(Collectors.toList()), domain, c.getId(), c.getFilter(FilterType.Inbound)); }); } } return true; }
SxpDomain implements AutoCloseable { public boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter) { checkFilter(filter); if (filter.getSxpFilter().getDomains().getDomain().isEmpty() || filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(d -> d.getName().equals(getName())) || checkDomainOverlap( filter.getSxpFilter().getFilterSpecific(), filter.getSxpFilter().getDomains())) { return false; } synchronized (filters) { if (filters.get(filter.getSxpFilter().getFilterSpecific()) .containsKey(filter.getSxpFilter().getFilterName())) { return false; } filters.get(filter.getSxpFilter().getFilterSpecific()).put(filter.getSxpFilter().getFilterName(), filter); } for (SxpDomain domain : node.getDomains()) { if (!domain.getName().equals(getName()) && filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(f -> f.getName().equals(domain.getName()))) { propagateToSharedMasterDatabases(Collections.emptyList(), getMasterDatabase().getBindings(BindingOriginsConfig.LOCAL_ORIGIN).stream().filter(filter).collect(Collectors.toList()), domain); getConnections().stream().filter(SxpConnection::isModeListener).forEach(c -> { propagateToSharedSxpDatabases(Collections.emptyList(), getSxpDatabase().getBindings(c.getId()) .stream() .filter(filter) .collect(Collectors.toList()), domain, c.getId(), c.getFilter(FilterType.Inbound)); }); } } return true; } }
SxpDomain implements AutoCloseable { public boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter) { checkFilter(filter); if (filter.getSxpFilter().getDomains().getDomain().isEmpty() || filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(d -> d.getName().equals(getName())) || checkDomainOverlap( filter.getSxpFilter().getFilterSpecific(), filter.getSxpFilter().getDomains())) { return false; } synchronized (filters) { if (filters.get(filter.getSxpFilter().getFilterSpecific()) .containsKey(filter.getSxpFilter().getFilterName())) { return false; } filters.get(filter.getSxpFilter().getFilterSpecific()).put(filter.getSxpFilter().getFilterName(), filter); } for (SxpDomain domain : node.getDomains()) { if (!domain.getName().equals(getName()) && filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(f -> f.getName().equals(domain.getName()))) { propagateToSharedMasterDatabases(Collections.emptyList(), getMasterDatabase().getBindings(BindingOriginsConfig.LOCAL_ORIGIN).stream().filter(filter).collect(Collectors.toList()), domain); getConnections().stream().filter(SxpConnection::isModeListener).forEach(c -> { propagateToSharedSxpDatabases(Collections.emptyList(), getSxpDatabase().getBindings(c.getId()) .stream() .filter(filter) .collect(Collectors.toList()), domain, c.getId(), c.getFilter(FilterType.Inbound)); }); } } return true; } private  SxpDomain(SxpNode owner, String name, SxpDatabaseInf sxpDatabase, MasterDatabaseInf masterDatabase); }
SxpDomain implements AutoCloseable { public boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter) { checkFilter(filter); if (filter.getSxpFilter().getDomains().getDomain().isEmpty() || filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(d -> d.getName().equals(getName())) || checkDomainOverlap( filter.getSxpFilter().getFilterSpecific(), filter.getSxpFilter().getDomains())) { return false; } synchronized (filters) { if (filters.get(filter.getSxpFilter().getFilterSpecific()) .containsKey(filter.getSxpFilter().getFilterName())) { return false; } filters.get(filter.getSxpFilter().getFilterSpecific()).put(filter.getSxpFilter().getFilterName(), filter); } for (SxpDomain domain : node.getDomains()) { if (!domain.getName().equals(getName()) && filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(f -> f.getName().equals(domain.getName()))) { propagateToSharedMasterDatabases(Collections.emptyList(), getMasterDatabase().getBindings(BindingOriginsConfig.LOCAL_ORIGIN).stream().filter(filter).collect(Collectors.toList()), domain); getConnections().stream().filter(SxpConnection::isModeListener).forEach(c -> { propagateToSharedSxpDatabases(Collections.emptyList(), getSxpDatabase().getBindings(c.getId()) .stream() .filter(filter) .collect(Collectors.toList()), domain, c.getId(), c.getFilter(FilterType.Inbound)); }); } } return true; } private  SxpDomain(SxpNode owner, String name, SxpDatabaseInf sxpDatabase, MasterDatabaseInf masterDatabase); static SxpDomain createInstance(SxpNode owner, String name, SxpDatabaseInf sxpDatabase,
            MasterDatabaseInf masterDatabase); static SxpDomain createInstance(SxpNode owner,
                                           org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.network.topology.topology.node.sxp.domains.SxpDomain domain,
                                           MasterDatabaseInf masterDB,
                                           SxpDatabaseInf sxpDB); static SxpDomain createInstance(SxpNode owner,
            org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.network.topology.topology.node.sxp.domains.SxpDomain domain); Map<String, SxpBindingFilter<?, ? extends SxpDomainFilterFields>> getFilters(); boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter); SxpBindingFilter<?, ? extends SxpDomainFilterFields> removeFilter(FilterSpecific specific, String name); boolean updateFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> newFilter); void pushToSharedMasterDatabases(final List<T> removed, final List<T> added); void pushToSharedSxpDatabases(NodeId nodeIdRemote, SxpBindingFilter<?, ? extends SxpFilterFields> sxpFilter,
            List<SxpDatabaseBinding> removed, List<SxpDatabaseBinding> added); MasterDatabaseInf getMasterDatabase(); SxpDatabaseInf getSxpDatabase(); String getName(); List<SxpConnection> getConnections(); SxpConnection getConnection(InetSocketAddress address); boolean addConnectionTemplate(T template); SxpConnectionTemplateFields removeConnectionTemplate(IpPrefix templatePrefix); SxpConnectionTemplateFields getTemplate(InetSocketAddress address); Collection<SxpConnectionTemplateFields> getConnectionTemplates(); boolean hasConnection(InetSocketAddress address); SxpConnection putConnection(SxpConnection connection); SxpConnection removeConnection(InetSocketAddress address); @Override void close(); }
SxpDomain implements AutoCloseable { public boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter) { checkFilter(filter); if (filter.getSxpFilter().getDomains().getDomain().isEmpty() || filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(d -> d.getName().equals(getName())) || checkDomainOverlap( filter.getSxpFilter().getFilterSpecific(), filter.getSxpFilter().getDomains())) { return false; } synchronized (filters) { if (filters.get(filter.getSxpFilter().getFilterSpecific()) .containsKey(filter.getSxpFilter().getFilterName())) { return false; } filters.get(filter.getSxpFilter().getFilterSpecific()).put(filter.getSxpFilter().getFilterName(), filter); } for (SxpDomain domain : node.getDomains()) { if (!domain.getName().equals(getName()) && filter.getSxpFilter() .getDomains() .getDomain() .stream() .anyMatch(f -> f.getName().equals(domain.getName()))) { propagateToSharedMasterDatabases(Collections.emptyList(), getMasterDatabase().getBindings(BindingOriginsConfig.LOCAL_ORIGIN).stream().filter(filter).collect(Collectors.toList()), domain); getConnections().stream().filter(SxpConnection::isModeListener).forEach(c -> { propagateToSharedSxpDatabases(Collections.emptyList(), getSxpDatabase().getBindings(c.getId()) .stream() .filter(filter) .collect(Collectors.toList()), domain, c.getId(), c.getFilter(FilterType.Inbound)); }); } } return true; } private  SxpDomain(SxpNode owner, String name, SxpDatabaseInf sxpDatabase, MasterDatabaseInf masterDatabase); static SxpDomain createInstance(SxpNode owner, String name, SxpDatabaseInf sxpDatabase,
            MasterDatabaseInf masterDatabase); static SxpDomain createInstance(SxpNode owner,
                                           org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.network.topology.topology.node.sxp.domains.SxpDomain domain,
                                           MasterDatabaseInf masterDB,
                                           SxpDatabaseInf sxpDB); static SxpDomain createInstance(SxpNode owner,
            org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.node.rev160308.network.topology.topology.node.sxp.domains.SxpDomain domain); Map<String, SxpBindingFilter<?, ? extends SxpDomainFilterFields>> getFilters(); boolean addFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> filter); SxpBindingFilter<?, ? extends SxpDomainFilterFields> removeFilter(FilterSpecific specific, String name); boolean updateFilter(SxpBindingFilter<?, ? extends SxpDomainFilterFields> newFilter); void pushToSharedMasterDatabases(final List<T> removed, final List<T> added); void pushToSharedSxpDatabases(NodeId nodeIdRemote, SxpBindingFilter<?, ? extends SxpFilterFields> sxpFilter,
            List<SxpDatabaseBinding> removed, List<SxpDatabaseBinding> added); MasterDatabaseInf getMasterDatabase(); SxpDatabaseInf getSxpDatabase(); String getName(); List<SxpConnection> getConnections(); SxpConnection getConnection(InetSocketAddress address); boolean addConnectionTemplate(T template); SxpConnectionTemplateFields removeConnectionTemplate(IpPrefix templatePrefix); SxpConnectionTemplateFields getTemplate(InetSocketAddress address); Collection<SxpConnectionTemplateFields> getConnectionTemplates(); boolean hasConnection(InetSocketAddress address); SxpConnection putConnection(SxpConnection connection); SxpConnection removeConnection(InetSocketAddress address); @Override void close();  }