2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import java.util.EnumMap;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
17 * Policy database attached to a particular RIB instance. Acts as the unified
20 final class PolicyDatabase {
21 private final Map<PeerRole, AbstractExportPolicy> exportPolicies = new EnumMap<>(PeerRole.class);
22 private final Map<PeerRole, AbstractImportPolicy> importPolicies = new EnumMap<>(PeerRole.class);
24 PolicyDatabase(final Long localAs, final Ipv4Address bgpId, final ClusterIdentifier clusterId) {
25 exportPolicies.put(PeerRole.Ebgp, new ToExternalExportPolicy(localAs));
26 exportPolicies.put(PeerRole.Ibgp, new ToInternalExportPolicy(bgpId, clusterId));
27 exportPolicies.put(PeerRole.RrClient, new ToReflectorClientExportPolicy(bgpId, clusterId));
29 importPolicies.put(PeerRole.Ebgp, new FromExternalImportPolicy());
30 importPolicies.put(PeerRole.Ibgp, new FromInternalImportPolicy(bgpId, clusterId));
31 importPolicies.put(PeerRole.RrClient, new FromReflectorClientImportPolicy(bgpId, clusterId));
34 AbstractExportPolicy exportPolicyForRole(final PeerRole peerRole) {
35 return exportPolicies.get(peerRole);
38 AbstractImportPolicy importPolicyForRole(final PeerRole peerRole) {
39 return importPolicies.get(peerRole);