Remove unused test class
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / PolicyDatabase.java
index cec9cc280397abcca17b8b5f6c15dd7bef20f724..a376928fc2a0d7a1dc38e55d9921130ebed943c2 100644 (file)
@@ -9,7 +9,8 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import java.util.EnumMap;
 import java.util.Map;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.protocol.bgp.rib.impl.spi.AbstractImportPolicy;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
 
@@ -22,22 +23,30 @@ final class PolicyDatabase {
     private final Map<PeerRole, AbstractImportPolicy> importPolicies = new EnumMap<>(PeerRole.class);
 
     PolicyDatabase(final Long localAs, final Ipv4Address bgpId, final ClusterIdentifier clusterId) {
-        exportPolicies.put(PeerRole.Ebgp, new ToExternalExportPolicy(localAs));
-        exportPolicies.put(PeerRole.Ibgp, new ToInternalExportPolicy(bgpId, clusterId));
-        exportPolicies.put(PeerRole.RrClient, new ToReflectorClientExportPolicy(bgpId, clusterId));
-        exportPolicies.put(PeerRole.Internal, new ToInternalReflectorClientExportPolicy(bgpId, clusterId));
+        this.exportPolicies.put(PeerRole.Ebgp, new ToExternalExportPolicy(localAs));
+        this.exportPolicies.put(PeerRole.Ibgp, new ToInternalExportPolicy(bgpId, clusterId));
+        this.exportPolicies.put(PeerRole.RrClient, new ToReflectorClientExportPolicy(bgpId, clusterId));
+        this.exportPolicies.put(PeerRole.Internal, new ToInternalReflectorClientExportPolicy(bgpId, clusterId));
 
-        importPolicies.put(PeerRole.Ebgp, new FromExternalImportPolicy());
-        importPolicies.put(PeerRole.Ibgp, new FromInternalImportPolicy(bgpId, clusterId));
-        importPolicies.put(PeerRole.RrClient, new FromReflectorClientImportPolicy(bgpId, clusterId));
-        importPolicies.put(PeerRole.Internal, new FromInternalReflectorClientImportPolicy(bgpId, clusterId));
+        this.importPolicies.put(PeerRole.Ebgp, new FromExternalImportPolicy());
+        this.importPolicies.put(PeerRole.Ibgp, new FromInternalImportPolicy(bgpId, clusterId));
+        this.importPolicies.put(PeerRole.RrClient, new FromReflectorClientImportPolicy(bgpId, clusterId));
+        this.importPolicies.put(PeerRole.Internal, new FromInternalReflectorClientImportPolicy(bgpId, clusterId));
     }
 
     AbstractExportPolicy exportPolicyForRole(final PeerRole peerRole) {
-        return exportPolicies.get(peerRole);
+        return this.exportPolicies.get(peerRole);
     }
 
     AbstractImportPolicy importPolicyForRole(final PeerRole peerRole) {
-        return importPolicies.get(peerRole);
+        /*
+         * TODO: this solution does not share equivalent attributes across
+         *       multiple peers. If we need to do that, consider carefully:
+         *       - whether the interner should be shared with RIBSupportContextImpl.writeRoutes()
+         *       - lookup/update contention of both the cache and the interner
+         *       - ability to share resulting attributes across import policies
+         *       - ability to share resulting attributes with export policies
+         */
+        return new CachingImportPolicy(importPolicies.get(peerRole));
     }
 }