BGPCEP-685: Rework deployers 88/66088/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 30 Nov 2017 11:26:47 +0000 (12:26 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 30 Nov 2017 11:39:21 +0000 (12:39 +0100)
Remove no longer Deployers services/Interfaces,
they were used to provide backward compatibility
and offering services to store on DS.
Once remove CSS Config, Deployers should only listen
changes on DS and not offer more than required.
this add simplicity and avoids boilerplate.

Change-Id: Icb1382c72b1ac1700c596c5ce020aa98c41e09ee
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
27 files changed:
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/AppPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpDeployerImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/PeerBean.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BgpDeployer.java [deleted file]
bgp/rib-impl/src/main/resources/org/opendaylight/blueprint/bgp-rib.xml
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRIBTestSetup.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathBasePathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/AbstractConfig.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/AppPeerTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpDeployerImplTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeerTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImplTest.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/AbstractBgpTopologyProvider.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/BackwardsCssTopologyProvider.java [deleted file]
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/BgpTopologyDeployerImpl.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/TopologyReferenceSingletonServiceImpl.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/spi/BgpTopologyDeployer.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/spi/BgpTopologyProvider.java
bgp/topology-provider/src/main/resources/org/opendaylight/blueprint/bgp-topology-provider.xml
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/config/BmpDeployerImpl.java

index 776405614ea58a45a9496d7f6442f793e21edd32..0a66e055ffc4499f2abd5b0b0e2fbc067db050ee 100755 (executable)
@@ -44,7 +44,6 @@ import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
 import org.opendaylight.protocol.bgp.mode.impl.base.BasePathSelectionModeFactory;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.ImportPolicyPeerTracker;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
@@ -103,15 +102,13 @@ public final class RIBImpl extends BGPRIBStateImpl implements ClusterSingletonSe
     private final CodecsRegistryImpl codecsRegistry;
     private final ServiceGroupIdentifier serviceGroupIdentifier;
     private final ClusterSingletonServiceProvider provider;
-    private final BgpDeployer.WriteConfiguration configurationWriter;
-    private ClusterSingletonServiceRegistration registration;
     private final DOMDataBrokerExtension service;
     private final Map<TransactionChain<?, ?>, LocRibWriter> txChainToLocRibWriter = new HashMap<>();
     private final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies;
     private final ImportPolicyPeerTracker importPolicyPeerTracker;
     private final RibId ribId;
     private final Map<TablesKey, ExportPolicyPeerTracker> exportPolicyPeerTrackerMap;
-
+    private ClusterSingletonServiceRegistration registration;
     private DOMTransactionChain domChain;
     @GuardedBy("this")
     private boolean isServiceInstantiated;
@@ -119,8 +116,8 @@ public final class RIBImpl extends BGPRIBStateImpl implements ClusterSingletonSe
     public RIBImpl(final ClusterSingletonServiceProvider provider, final RibId ribId, final AsNumber localAs, final BgpId localBgpId,
             final ClusterIdentifier clusterId, final RIBExtensionConsumerContext extensions, final BGPDispatcher dispatcher,
             final BindingCodecTreeFactory codecFactory, final DOMDataBroker domDataBroker, final List<BgpTableType> localTables,
-            @Nonnull final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies, final GeneratedClassLoadingStrategy classStrategy,
-            final BgpDeployer.WriteConfiguration configurationWriter) {
+            @Nonnull final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies,
+            final GeneratedClassLoadingStrategy classStrategy) {
         super(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(requireNonNull(ribId))),
                 localBgpId, localAs);
         this.localAs = requireNonNull(localAs);
@@ -143,7 +140,6 @@ public final class RIBImpl extends BGPRIBStateImpl implements ClusterSingletonSe
         this.serviceGroupIdentifier = ServiceGroupIdentifier.create(this.ribId.getValue() + "-service-group");
         requireNonNull(provider, "ClusterSingletonServiceProvider is null");
         this.provider = provider;
-        this.configurationWriter = configurationWriter;
 
         final ImmutableMap.Builder<TablesKey, ExportPolicyPeerTracker> exportPolicies = new ImmutableMap.Builder<>();
         for (final BgpTableType t : this.localTables) {
@@ -314,9 +310,6 @@ public final class RIBImpl extends BGPRIBStateImpl implements ClusterSingletonSe
         this.isServiceInstantiated = true;
         setActive(true);
         this.domChain = this.domDataBroker.createTransactionChain(this);
-        if (this.configurationWriter != null) {
-            this.configurationWriter.apply();
-        }
         LOG.info("RIB Singleton Service {} instantiated, RIB {}", getIdentifier().getValue(), this.ribId.getValue());
         LOG.debug("Instantiating RIB table {} at {}", this.ribId, this.yangRibId);
 
index 29ee2e1719f104ea80dbd7528aaa68b4738d4541..065eca327a9eb2d36a8188bd1b3b012b7ecd120e 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.impl.ApplicationPeer;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer.WriteConfiguration;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerStateConsumer;
@@ -48,19 +47,27 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
     @GuardedBy("this")
     private ServiceRegistration<?> serviceRegistration;
 
+    private static ApplicationRibId createAppRibId(final Neighbor neighbor) {
+        final Config config = neighbor.getConfig();
+        if (config != null && !Strings.isNullOrEmpty(config.getDescription())) {
+            return new ApplicationRibId(config.getDescription());
+        }
+        return new ApplicationRibId(neighbor.getNeighborAddress().getIpv4Address().getValue());
+    }
+
     @Override
-    public synchronized void start(final RIB rib, final Neighbor neighbor, final BGPTableTypeRegistryConsumer tableTypeRegistry,
-        final WriteConfiguration configurationWriter) {
+    public synchronized void start(final RIB rib, final Neighbor neighbor,
+            final BGPTableTypeRegistryConsumer tableTypeRegistry) {
         Preconditions.checkState(this.bgpAppPeerSingletonService == null, "Previous peer instance was not closed.");
         this.currentConfiguration = neighbor;
         this.bgpAppPeerSingletonService = new BgpAppPeerSingletonService(rib, createAppRibId(neighbor),
-            neighbor.getNeighborAddress().getIpv4Address(), configurationWriter);
+                neighbor.getNeighborAddress().getIpv4Address());
     }
 
     @Override
     public synchronized void restart(final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
         Preconditions.checkState(this.currentConfiguration != null);
-        start(rib, this.currentConfiguration, tableTypeRegistry, null);
+        start(rib, this.currentConfiguration, tableTypeRegistry);
     }
 
     @Override
@@ -94,14 +101,6 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
                 && OpenConfigMappingUtil.isApplicationPeer(neighbor);
     }
 
-    private static ApplicationRibId createAppRibId(final Neighbor neighbor) {
-        final Config config = neighbor.getConfig();
-        if (config != null && !Strings.isNullOrEmpty(config.getDescription())) {
-            return new ApplicationRibId(config.getDescription());
-        }
-        return new ApplicationRibId(neighbor.getNeighborAddress().getIpv4Address().getValue());
-    }
-
     @Override
     public BGPPeerState getPeerState() {
         return this.bgpAppPeerSingletonService.getPeerState();
@@ -112,25 +111,22 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
     }
 
     private final class BgpAppPeerSingletonService implements ClusterSingletonService, BGPPeerStateConsumer,
-        AutoCloseable {
+            AutoCloseable {
         private final ApplicationPeer applicationPeer;
         private final DOMDataTreeChangeService dataTreeChangeService;
         private final ApplicationRibId appRibId;
-        private ClusterSingletonServiceRegistration singletonServiceRegistration;
         private final ServiceGroupIdentifier serviceGroupIdentifier;
-        private final WriteConfiguration configurationWriter;
+        private ClusterSingletonServiceRegistration singletonServiceRegistration;
         @GuardedBy("this")
         private boolean isServiceInstantiated;
 
-        BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress,
-            final WriteConfiguration configurationWriter) {
+        BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress) {
             this.applicationPeer = new ApplicationPeer(appRibId, neighborAddress, rib);
             this.appRibId = appRibId;
             this.dataTreeChangeService = rib.getService();
             this.serviceGroupIdentifier = rib.getRibIServiceGroupIdentifier();
-            this.configurationWriter = configurationWriter;
             LOG.info("Application Peer Singleton Service {} registered, Application peer {}",
-                getIdentifier().getValue(), this.appRibId.getValue());
+                    getIdentifier().getValue(), this.appRibId.getValue());
             //this need to be always the last step
             this.singletonServiceRegistration = rib.registerClusterSingletonService(this);
         }
@@ -146,26 +142,24 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
         @Override
         public synchronized void instantiateServiceInstance() {
             this.isServiceInstantiated = true;
-            if(this.configurationWriter != null) {
-                this.configurationWriter.apply();
-            }
             LOG.info("Application Peer Singleton Service {} instantiated, Application peer {}",
-                getIdentifier().getValue(), this.appRibId.getValue());
+                    getIdentifier().getValue(), this.appRibId.getValue());
             final YangInstanceIdentifier yangIId = YangInstanceIdentifier.builder().node(ApplicationRib.QNAME)
-                .nodeWithKey(ApplicationRib.QNAME, APP_ID_QNAME, this.appRibId.getValue()).node(Tables.QNAME).node(Tables.QNAME).build();
+                    .nodeWithKey(ApplicationRib.QNAME, APP_ID_QNAME, this.appRibId.getValue())
+                    .node(Tables.QNAME).node(Tables.QNAME).build();
             this.applicationPeer.instantiateServiceInstance(this.dataTreeChangeService,
-                new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yangIId));
+                    new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yangIId));
         }
 
         @Override
         public synchronized ListenableFuture<Void> closeServiceInstance() {
-            if(!this.isServiceInstantiated) {
+            if (!this.isServiceInstantiated) {
                 LOG.trace("Application Peer Singleton Service {} instance already closed, Application peer {}",
-                    getIdentifier().getValue(), this.appRibId.getValue());
+                        getIdentifier().getValue(), this.appRibId.getValue());
                 return Futures.immediateFuture(null);
             }
             LOG.info("Application Peer Singleton Service {} instance closed, Application peer {}",
-                getIdentifier().getValue(), this.appRibId.getValue());
+                    getIdentifier().getValue(), this.appRibId.getValue());
             this.isServiceInstantiated = false;
             return this.applicationPeer.close();
         }
index e3c5b29ab0eb4097950ca91aaf7749291baa660c..ae736583f267b8afd7f748fdb5b66e785a653b91 100644 (file)
@@ -14,6 +14,7 @@ import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUti
 import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getNeighborInstanceName;
 import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getRibInstanceName;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -35,7 +36,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.InstanceType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp;
@@ -58,7 +58,7 @@ import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChangeListener<Bgp>, AutoCloseable {
+public final class BgpDeployerImpl implements ClusteredDataTreeChangeListener<Bgp>, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(BgpDeployerImpl.class);
     private final InstanceIdentifier<NetworkInstance> networkInstanceIId;
     private final BlueprintContainer container;
@@ -74,14 +74,14 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
     private boolean closed;
 
     public BgpDeployerImpl(final String networkInstanceName, final BlueprintContainer container,
-        final BundleContext bundleContext, final DataBroker dataBroker,
-        final BGPTableTypeRegistryConsumer mappingService) {
+            final BundleContext bundleContext, final DataBroker dataBroker,
+            final BGPTableTypeRegistryConsumer mappingService) {
         this.dataBroker = requireNonNull(dataBroker);
         this.container = requireNonNull(container);
         this.bundleContext = requireNonNull(bundleContext);
         this.tableTypeRegistry = requireNonNull(mappingService);
         this.networkInstanceIId = InstanceIdentifier.create(NetworkInstances.class)
-            .child(NetworkInstance.class, new NetworkInstanceKey(networkInstanceName));
+                .child(NetworkInstance.class, new NetworkInstanceKey(networkInstanceName));
         Futures.addCallback(initializeNetworkInstance(dataBroker, this.networkInstanceIId), new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
@@ -94,11 +94,20 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
             }
         }, MoreExecutors.directExecutor());
         this.registration = dataBroker.registerDataTreeChangeListener(
-            new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, this.networkInstanceIId.child(Protocols.class)
-                .child(Protocol.class).augmentation(Protocol1.class).child(Bgp.class)), this);
+                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, this.networkInstanceIId.child(Protocols.class)
+                        .child(Protocol.class).augmentation(Protocol1.class).child(Bgp.class)), this);
         LOG.info("BGP Deployer {} started.", networkInstanceName);
     }
 
+    private static ListenableFuture<Void> initializeNetworkInstance(
+            final DataBroker dataBroker, final InstanceIdentifier<NetworkInstance> networkInstance) {
+        final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        wTx.merge(LogicalDatastoreType.CONFIGURATION, networkInstance,
+                new NetworkInstanceBuilder().setName(networkInstance.firstKeyOf(NetworkInstance.class).getName())
+                        .setProtocols(new ProtocolsBuilder().build()).build());
+        return wTx.submit();
+    }
+
     @Override
     public synchronized void onDataTreeChanged(final Collection<DataTreeModification<Bgp>> changes) {
         if (this.closed) {
@@ -119,7 +128,7 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         }
     }
 
-    @Override
+    @VisibleForTesting
     public InstanceIdentifier<NetworkInstance> getInstanceIdentifier() {
         return this.networkInstanceIId;
     }
@@ -131,18 +140,18 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         this.closed = true;
 
         final List<ListenableFuture<Void>> futurePeerCloseList = this.peers.values().stream()
-            .map(PeerBean::closeServiceInstance).collect(Collectors.toList());
+                .map(PeerBean::closeServiceInstance).collect(Collectors.toList());
         final ListenableFuture<List<Void>> futureOfRelevance = Futures.allAsList(futurePeerCloseList);
 
         final ListenableFuture<ListenableFuture<List<Void>>> maxRelevanceFuture = transform(futureOfRelevance,
-            futurePeersClose -> {
-                this.peers.values().forEach(PeerBean::close);
-                BgpDeployerImpl.this.peers.clear();
+                futurePeersClose -> {
+                    this.peers.values().forEach(PeerBean::close);
+                    BgpDeployerImpl.this.peers.clear();
 
-                final List<ListenableFuture<Void>> futureRIBCloseList = BgpDeployerImpl.this.ribs.values().stream()
-                    .map(RibImpl::closeServiceInstance).collect(Collectors.toList());
-                return Futures.allAsList(futureRIBCloseList);
-            }, MoreExecutors.directExecutor());
+                    final List<ListenableFuture<Void>> futureRIBCloseList = BgpDeployerImpl.this.ribs.values().stream()
+                            .map(RibImpl::closeServiceInstance).collect(Collectors.toList());
+                    return Futures.allAsList(futureRIBCloseList);
+                }, MoreExecutors.directExecutor());
 
         final ListenableFuture<Void> ribFutureClose = transform(maxRelevanceFuture, futurePeersClose -> {
             BgpDeployerImpl.this.ribs.values().forEach(RibImpl::close);
@@ -153,45 +162,35 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         ribFutureClose.get();
     }
 
-    private static ListenableFuture<Void> initializeNetworkInstance(
-        final DataBroker dataBroker, final InstanceIdentifier<NetworkInstance> networkInstance) {
-        final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
-        wTx.merge(LogicalDatastoreType.CONFIGURATION, networkInstance,
-            new NetworkInstanceBuilder().setName(networkInstance.firstKeyOf(NetworkInstance.class).getName())
-                .setProtocols(new ProtocolsBuilder().build()).build());
-        return wTx.submit();
-    }
-
     private synchronized void onGlobalChanged(final DataObjectModification<Global> dataObjectModification,
-        final InstanceIdentifier<Bgp> rootIdentifier) {
+            final InstanceIdentifier<Bgp> rootIdentifier) {
         switch (dataObjectModification.getModificationType()) {
-        case DELETE:
-            onGlobalRemoved(rootIdentifier);
-            break;
-        case SUBTREE_MODIFIED:
-        case WRITE:
-            onGlobalModified(rootIdentifier, dataObjectModification.getDataAfter(), null);
-            break;
-        default:
-            break;
+            case DELETE:
+                onGlobalRemoved(rootIdentifier);
+                break;
+            case SUBTREE_MODIFIED:
+            case WRITE:
+                onGlobalModified(rootIdentifier, dataObjectModification.getDataAfter());
+                break;
+            default:
+                break;
         }
     }
 
-    @Override
-    public synchronized void onGlobalModified(final InstanceIdentifier<Bgp> rootIdentifier, final Global global,
-        final WriteConfiguration configurationWriter) {
+    @VisibleForTesting
+    synchronized void onGlobalModified(final InstanceIdentifier<Bgp> rootIdentifier, final Global global) {
         final RibImpl ribImpl = this.ribs.get(rootIdentifier);
-        if(ribImpl == null ) {
-            onGlobalCreated(rootIdentifier, global, configurationWriter);
+        if (ribImpl == null) {
+            onGlobalCreated(rootIdentifier, global);
         } else if (!ribImpl.isGlobalEqual(global)) {
-            onGlobalUpdated(rootIdentifier, global, ribImpl, configurationWriter);
+            onGlobalUpdated(rootIdentifier, global, ribImpl);
         }
     }
 
     private synchronized List<PeerBean> closeAllBindedPeers(final InstanceIdentifier<Bgp> rootIdentifier) {
         final List<PeerBean> filtered = new ArrayList<>();
         this.peers.entrySet().stream().filter(entry -> entry.getKey().firstIdentifierOf(Bgp.class)
-            .contains(rootIdentifier)).forEach(entry -> {
+                .contains(rootIdentifier)).forEach(entry -> {
             final PeerBean peer = entry.getValue();
             try {
                 peer.closeServiceInstance().get();
@@ -204,17 +203,16 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         return filtered;
     }
 
-    private synchronized void onGlobalCreated(final InstanceIdentifier<Bgp> rootIdentifier, final Global global,
-        final WriteConfiguration configurationWriter) {
+    private synchronized void onGlobalCreated(final InstanceIdentifier<Bgp> rootIdentifier, final Global global) {
         LOG.debug("Creating RIB instance with configuration: {}", global);
         final RibImpl ribImpl = (RibImpl) this.container.getComponentInstance(InstanceType.RIB.getBeanName());
-        initiateRibInstance(rootIdentifier, global, ribImpl, configurationWriter);
+        initiateRibInstance(rootIdentifier, global, ribImpl);
         this.ribs.put(rootIdentifier, ribImpl);
         LOG.debug("RIB instance created: {}", ribImpl);
     }
 
     private synchronized void onGlobalUpdated(final InstanceIdentifier<Bgp> rootIdentifier, final Global global,
-        final RibImpl ribImpl, final WriteConfiguration configurationWriter) {
+            final RibImpl ribImpl) {
         LOG.debug("Modifying RIB instance with configuration: {}", global);
         final List<PeerBean> closedPeers = closeAllBindedPeers(rootIdentifier);
         try {
@@ -223,13 +221,13 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
             LOG.error("RIB instance failed to close service instance", e);
         }
         ribImpl.close();
-        initiateRibInstance(rootIdentifier, global, ribImpl, configurationWriter);
+        initiateRibInstance(rootIdentifier, global, ribImpl);
         closedPeers.forEach(peer -> peer.restart(ribImpl, this.tableTypeRegistry));
         LOG.debug("RIB instance created: {}", ribImpl);
     }
 
-    @Override
-    public synchronized void onGlobalRemoved(final InstanceIdentifier<Bgp> rootIdentifier) {
+    @VisibleForTesting
+    synchronized void onGlobalRemoved(final InstanceIdentifier<Bgp> rootIdentifier) {
         LOG.debug("Removing RIB instance: {}", rootIdentifier);
         final RibImpl ribImpl = this.ribs.remove(rootIdentifier);
         if (ribImpl != null) {
@@ -244,48 +242,46 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         final Dictionary<String, String> properties = new Hashtable<>();
         properties.put(InstanceType.RIB.getBeanName(), ribInstanceName);
         final ServiceRegistration<?> serviceRegistration = this.bundleContext.registerService(
-            InstanceType.RIB.getServices(), ribImpl, properties);
+                InstanceType.RIB.getServices(), ribImpl, properties);
         ribImpl.setServiceRegistration(serviceRegistration);
     }
 
     private synchronized void initiateRibInstance(final InstanceIdentifier<Bgp> rootIdentifier, final Global global,
-        final RibImpl ribImpl, final WriteConfiguration configurationWriter) {
+            final RibImpl ribImpl) {
         final String ribInstanceName = getRibInstanceName(rootIdentifier);
-        ribImpl.start(global, ribInstanceName, this.tableTypeRegistry, configurationWriter);
+        ribImpl.start(global, ribInstanceName, this.tableTypeRegistry);
         registerRibInstance(ribImpl, ribInstanceName);
     }
 
     private synchronized void onNeighborsChanged(final DataObjectModification<Neighbors> dataObjectModification,
-        final InstanceIdentifier<Bgp> rootIdentifier) {
+            final InstanceIdentifier<Bgp> rootIdentifier) {
         for (final DataObjectModification<? extends DataObject> neighborModification : dataObjectModification.getModifiedChildren()) {
             switch (neighborModification.getModificationType()) {
-            case DELETE:
-                onNeighborRemoved(rootIdentifier, (Neighbor) neighborModification.getDataBefore());
-                break;
-            case SUBTREE_MODIFIED:
-            case WRITE:
-                onNeighborModified(rootIdentifier, (Neighbor) neighborModification.getDataAfter(), null);
-                break;
-            default:
-                break;
+                case DELETE:
+                    onNeighborRemoved(rootIdentifier, (Neighbor) neighborModification.getDataBefore());
+                    break;
+                case SUBTREE_MODIFIED:
+                case WRITE:
+                    onNeighborModified(rootIdentifier, (Neighbor) neighborModification.getDataAfter());
+                    break;
+                default:
+                    break;
             }
         }
     }
 
-    @Override
-    public synchronized void onNeighborModified(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor,
-        final WriteConfiguration configurationWriter) {
+    @VisibleForTesting
+    synchronized void onNeighborModified(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor) {
         //restart peer instance with a new configuration
         final PeerBean bgpPeer = this.peers.get(getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey()));
         if (bgpPeer == null) {
-            onNeighborCreated(rootIdentifier, neighbor, configurationWriter);
-        } else if(!bgpPeer.containsEqualConfiguration(neighbor)){
-            onNeighborUpdated(bgpPeer, rootIdentifier, neighbor, configurationWriter);
+            onNeighborCreated(rootIdentifier, neighbor);
+        } else if (!bgpPeer.containsEqualConfiguration(neighbor)) {
+            onNeighborUpdated(bgpPeer, rootIdentifier, neighbor);
         }
     }
 
-    private synchronized void onNeighborCreated(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor,
-        final WriteConfiguration configurationWriter) {
+    private synchronized void onNeighborCreated(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor) {
         LOG.debug("Creating Peer instance with configuration: {}", neighbor);
         final PeerBean bgpPeer;
         if (OpenConfigMappingUtil.isApplicationPeer(neighbor)) {
@@ -293,23 +289,25 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         } else {
             bgpPeer = (PeerBean) this.container.getComponentInstance(InstanceType.PEER.getBeanName());
         }
-        final InstanceIdentifier<Neighbor> neighborInstanceIdentifier = getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey());
-        initiatePeerInstance(rootIdentifier, neighborInstanceIdentifier, neighbor, bgpPeer, configurationWriter);
+        final InstanceIdentifier<Neighbor> neighborInstanceIdentifier =
+                getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey());
+        initiatePeerInstance(rootIdentifier, neighborInstanceIdentifier, neighbor, bgpPeer);
         this.peers.put(neighborInstanceIdentifier, bgpPeer);
         LOG.debug("Peer instance created {}", bgpPeer);
     }
 
-    private synchronized void onNeighborUpdated(final PeerBean bgpPeer, final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor,
-            final WriteConfiguration configurationWriter) {
+    private synchronized void onNeighborUpdated(final PeerBean bgpPeer, final InstanceIdentifier<Bgp> rootIdentifier,
+            final Neighbor neighbor) {
         LOG.debug("Updating Peer instance with configuration: {}", neighbor);
         bgpPeer.close();
-        final InstanceIdentifier<Neighbor> neighborInstanceIdentifier = getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey());
-        initiatePeerInstance(rootIdentifier, neighborInstanceIdentifier, neighbor, bgpPeer, configurationWriter);
+        final InstanceIdentifier<Neighbor> neighborInstanceIdentifier =
+                getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey());
+        initiatePeerInstance(rootIdentifier, neighborInstanceIdentifier, neighbor, bgpPeer);
         LOG.debug("Peer instance updated {}", bgpPeer);
     }
 
-    @Override
-    public synchronized void onNeighborRemoved(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor) {
+    @VisibleForTesting
+    synchronized void onNeighborRemoved(final InstanceIdentifier<Bgp> rootIdentifier, final Neighbor neighbor) {
         LOG.debug("Removing Peer instance: {}", rootIdentifier);
         final PeerBean bgpPeer = this.peers.remove(getNeighborInstanceIdentifier(rootIdentifier, neighbor.getKey()));
         if (bgpPeer != null) {
@@ -322,7 +320,7 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         final Dictionary<String, String> properties = new Hashtable<>();
         properties.put(InstanceType.PEER.getBeanName(), peerInstanceName);
         final ServiceRegistration<?> serviceRegistration = this.bundleContext
-            .registerService(InstanceType.PEER.getServices(), bgpPeer, properties);
+                .registerService(InstanceType.PEER.getServices(), bgpPeer, properties);
         bgpPeer.setServiceRegistration(serviceRegistration);
     }
 
@@ -330,43 +328,27 @@ public final class BgpDeployerImpl implements BgpDeployer, ClusteredDataTreeChan
         final Dictionary<String, String> properties = new Hashtable<>();
         properties.put(InstanceType.PEER.getBeanName(), peerInstanceName);
         final ServiceRegistration<?> serviceRegistration = this.bundleContext
-            .registerService(InstanceType.APP_PEER.getServices(), appPeer, properties);
+                .registerService(InstanceType.APP_PEER.getServices(), appPeer, properties);
         appPeer.setServiceRegistration(serviceRegistration);
     }
 
     private synchronized void initiatePeerInstance(final InstanceIdentifier<Bgp> rootIdentifier,
-        final InstanceIdentifier<Neighbor> neighborIdentifier, final Neighbor neighbor,
-        final PeerBean bgpPeer, final WriteConfiguration configurationWriter) {
+            final InstanceIdentifier<Neighbor> neighborIdentifier, final Neighbor neighbor,
+            final PeerBean bgpPeer) {
         final String peerInstanceName = getNeighborInstanceName(neighborIdentifier);
         final RibImpl rib = this.ribs.get(rootIdentifier);
         if (rib != null) {
-            bgpPeer.start(rib, neighbor, this.tableTypeRegistry, configurationWriter);
+            bgpPeer.start(rib, neighbor, this.tableTypeRegistry);
             if (bgpPeer instanceof BgpPeer) {
                 registerPeerInstance((BgpPeer) bgpPeer, peerInstanceName);
-            } else if(bgpPeer instanceof AppPeer) {
+            } else if (bgpPeer instanceof AppPeer) {
                 registerAppPeerInstance((AppPeer) bgpPeer, peerInstanceName);
             }
         }
     }
 
-    @Override
-    public BGPTableTypeRegistryConsumer getTableTypeRegistry() {
+    @VisibleForTesting
+    BGPTableTypeRegistryConsumer getTableTypeRegistry() {
         return this.tableTypeRegistry;
     }
-
-    @Override
-    public <T extends DataObject> ListenableFuture<Void> writeConfiguration(final T data,
-        final InstanceIdentifier<T> identifier) {
-        final WriteTransaction wTx = this.dataBroker.newWriteOnlyTransaction();
-        wTx.put(LogicalDatastoreType.CONFIGURATION, identifier, data, true);
-        return wTx.submit();
-    }
-
-    @Override
-    public <T extends DataObject> ListenableFuture<Void> removeConfiguration(
-        final InstanceIdentifier<T> identifier) {
-        final WriteTransaction wTx = this.dataBroker.newWriteOnlyTransaction();
-        wTx.delete(LogicalDatastoreType.CONFIGURATION, identifier);
-        return wTx.submit();
-    }
 }
index 6a8fc10c7e239ac84f968342b294d4c3961258c8..953eca1cb4597b8f51fd7c14a4f2f8b6b00b20c5 100644 (file)
@@ -36,7 +36,6 @@ import org.opendaylight.protocol.bgp.parser.spi.MultiprotocolCapabilitiesUtil;
 import org.opendaylight.protocol.bgp.rib.impl.BGPPeer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer.WriteConfiguration;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState;
 import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerStateConsumer;
@@ -80,18 +79,65 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
         this.rpcRegistry = rpcRegistry;
     }
 
+    private static List<BgpParameters> getBgpParameters(final Neighbor neighbor, final RIB rib,
+            final BGPTableTypeRegistryConsumer tableTypeRegistry) {
+        final List<BgpParameters> tlvs = new ArrayList<>();
+        final List<OptionalCapabilities> caps = new ArrayList<>();
+        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(
+                new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
+
+        caps.add(new OptionalCapabilitiesBuilder()
+                .setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
+        caps.add(new OptionalCapabilitiesBuilder()
+                .setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
+
+        final List<AfiSafi> afiSafi = OpenConfigMappingUtil
+                .getAfiSafiWithDefault(neighbor.getAfiSafis(), false);
+        final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil
+                .toAddPathCapability(afiSafi, tableTypeRegistry);
+        if (!addPathCapability.isEmpty()) {
+            caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+                    .addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(
+                            new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability)
+                                    .build()).build()).build()).build());
+        }
+
+        final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
+        for (final BgpTableType tableType : tableTypes) {
+            if (!rib.getLocalTables().contains(tableType)) {
+                LOG.info("RIB instance does not list {} in its local tables. Incoming data will be dropped.",
+                        tableType);
+            }
+
+            caps.add(new OptionalCapabilitiesBuilder().setCParameters(
+                    new CParametersBuilder().addAugmentation(CParameters1.class,
+                            new CParameters1Builder().setMultiprotocolCapability(
+                                    new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
+        }
+        tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
+        return tlvs;
+    }
+
+    private static Optional<byte[]> getPassword(final KeyMapping key) {
+        if (key != null) {
+            return Optional.of(Iterables.getOnlyElement(key.values()));
+        }
+        return Optional.absent();
+    }
+
     @Override
-    public synchronized void start(final RIB rib, final Neighbor neighbor, final BGPTableTypeRegistryConsumer tableTypeRegistry,
-            final WriteConfiguration configurationWriter) {
-        Preconditions.checkState(this.bgpPeerSingletonService == null, "Previous peer instance was not closed.");
-        this.bgpPeerSingletonService = new BgpPeerSingletonService(rib, neighbor, tableTypeRegistry, configurationWriter);
+    public synchronized void start(final RIB rib, final Neighbor neighbor,
+            final BGPTableTypeRegistryConsumer tableTypeRegistry) {
+        Preconditions.checkState(this.bgpPeerSingletonService == null,
+                "Previous peer instance was not closed.");
+        this.bgpPeerSingletonService = new BgpPeerSingletonService(rib, neighbor, tableTypeRegistry);
         this.currentConfiguration = neighbor;
     }
 
     @Override
     public synchronized void restart(final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
         Preconditions.checkState(this.currentConfiguration != null);
-        start(rib, this.currentConfiguration, tableTypeRegistry, null);
+        start(rib, this.currentConfiguration, tableTypeRegistry);
     }
 
     @Override
@@ -144,46 +190,6 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
                 && Objects.equals(this.currentConfiguration.getTransport(), neighbor.getTransport());
     }
 
-    private static List<BgpParameters> getBgpParameters(final Neighbor neighbor, final RIB rib,
-            final BGPTableTypeRegistryConsumer tableTypeRegistry) {
-        final List<BgpParameters> tlvs = new ArrayList<>();
-        final List<OptionalCapabilities> caps = new ArrayList<>();
-        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(
-                new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
-
-        caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
-        caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
-
-        final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(neighbor.getAfiSafis(), false);
-        final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
-        if (!addPathCapability.isEmpty()) {
-            caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
-                    new CParameters1Builder().setAddPathCapability(
-                            new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
-        }
-
-        final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
-        for (final BgpTableType tableType : tableTypes) {
-            if (!rib.getLocalTables().contains(tableType)) {
-                LOG.info("RIB instance does not list {} in its local tables. Incoming data will be dropped.", tableType);
-            }
-
-            caps.add(new OptionalCapabilitiesBuilder().setCParameters(
-                    new CParametersBuilder().addAugmentation(CParameters1.class,
-                            new CParameters1Builder().setMultiprotocolCapability(
-                                    new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
-        }
-        tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
-        return tlvs;
-    }
-
-    private static Optional<byte[]> getPassword(final KeyMapping key) {
-        if (key != null) {
-            return Optional.of(Iterables.getOnlyElement(key.values()));
-        }
-        return Optional.absent();
-    }
-
     @Override
     public BGPPeerState getPeerState() {
         if (this.bgpPeerSingletonService == null) {
@@ -204,24 +210,23 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
         private final InetSocketAddress inetAddress;
         private final int retryTimer;
         private final KeyMapping keys;
-        private final WriteConfiguration configurationWriter;
-        private ClusterSingletonServiceRegistration registration;
         private final BGPPeer bgpPeer;
         private final IpAddress neighborAddress;
         private final BGPSessionPreferences prefs;
+        private ClusterSingletonServiceRegistration registration;
         private Future<Void> connection;
         @GuardedBy("this")
         private boolean isServiceInstantiated;
 
         private BgpPeerSingletonService(final RIB rib, final Neighbor neighbor,
-                final BGPTableTypeRegistryConsumer tableTypeRegistry, final WriteConfiguration configurationWriter) {
+                final BGPTableTypeRegistryConsumer tableTypeRegistry) {
             this.neighborAddress = neighbor.getNeighborAddress();
             final AfiSafis afisSAfis = requireNonNull(neighbor.getAfiSafis());
             final Set<TablesKey> afiSafisAdvertized = OpenConfigMappingUtil
                     .toTableKey(afisSAfis.getAfiSafi(), tableTypeRegistry);
             this.bgpPeer = new BGPPeer(Ipv4Util.toStringIP(this.neighborAddress), rib,
-                    OpenConfigMappingUtil.toPeerRole(neighbor), getSimpleRoutingPolicy(neighbor), BgpPeer.this.rpcRegistry,
-                    afiSafisAdvertized, Collections.emptySet());
+                    OpenConfigMappingUtil.toPeerRole(neighbor), getSimpleRoutingPolicy(neighbor),
+                    BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
             final List<BgpParameters> bgpParameters = getBgpParameters(neighbor, rib, tableTypeRegistry);
             final KeyMapping keyMapping = OpenConfigMappingUtil.getNeighborKey(neighbor);
             this.prefs = new BGPSessionPreferences(rib.getLocalAs(), getHoldTimer(neighbor), rib.getBgpIdentifier(),
@@ -231,7 +236,6 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
             this.inetAddress = Ipv4Util.toInetSocketAddress(this.neighborAddress, OpenConfigMappingUtil.getPort(neighbor));
             this.retryTimer = OpenConfigMappingUtil.getRetryTimer(neighbor);
             this.keys = keyMapping;
-            this.configurationWriter = configurationWriter;
             this.serviceGroupIdentifier = rib.getRibIServiceGroupIdentifier();
             LOG.info("Peer Singleton Service {} registered", this.serviceGroupIdentifier.getValue());
             //this need to be always the last step
@@ -249,14 +253,13 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
         @Override
         public synchronized void instantiateServiceInstance() {
             this.isServiceInstantiated = true;
-            if (this.configurationWriter != null) {
-                this.configurationWriter.apply();
-            }
-            LOG.info("Peer Singleton Service {} instantiated, Peer {}", getIdentifier().getValue(), this.neighborAddress);
+            LOG.info("Peer Singleton Service {} instantiated, Peer {}", getIdentifier().getValue(),
+                    this.neighborAddress);
             this.bgpPeer.instantiateServiceInstance();
             this.dispatcher.getBGPPeerRegistry().addPeer(this.neighborAddress, this.bgpPeer, this.prefs);
             if (this.activeConnection) {
-                this.connection = this.dispatcher.createReconnectingClient(this.inetAddress, this.retryTimer, this.keys);
+                this.connection = this.dispatcher.createReconnectingClient(this.inetAddress, this.retryTimer,
+                        this.keys);
             }
         }
 
index d53c59ea3b76ab7c0c79408887d8800852650c67..1a89f4329f92264fc5cd6a7e8dc8dcc1513da200 100644 (file)
@@ -10,17 +10,15 @@ package org.opendaylight.protocol.bgp.rib.impl.config;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer.WriteConfiguration;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
 
 /**
  * Common interface for BgpPeer and AppPeer beans
- *
  */
 public interface PeerBean extends AutoCloseable {
 
-    void start(RIB rib, Neighbor neighbor, BGPTableTypeRegistryConsumer tableTypeRegistry, WriteConfiguration configurationWriter);
+    void start(RIB rib, Neighbor neighbor, BGPTableTypeRegistryConsumer tableTypeRegistry);
 
     void restart(RIB rib, BGPTableTypeRegistryConsumer tableTypeRegistry);
 
index 9379eefeb7aa24f99631640297ba00ae2e704567..901d07ce4ecd3ae2904008e9d7a87eb709254d33 100644 (file)
@@ -34,7 +34,6 @@ import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.impl.RIBImpl;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.ImportPolicyPeerTracker;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
@@ -93,11 +92,10 @@ public final class RibImpl implements RIB, BGPRIBStateConsumer, AutoCloseable {
         this.domSchemaService = domSchemaService;
     }
 
-    void start(final Global global, final String instanceName, final BGPTableTypeRegistryConsumer tableTypeRegistry,
-            final BgpDeployer.WriteConfiguration configurationWriter) {
+    void start(final Global global, final String instanceName, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
         Preconditions.checkState(this.ribImpl == null,
                 "Previous instance %s was not closed.", this);
-        this.ribImpl = createRib(global, instanceName, tableTypeRegistry, configurationWriter);
+        this.ribImpl = createRib(global, instanceName, tableTypeRegistry);
         this.schemaContextRegistration = this.domSchemaService.registerSchemaContextListener(this.ribImpl);
     }
 
@@ -231,8 +229,7 @@ public final class RibImpl implements RIB, BGPRIBStateConsumer, AutoCloseable {
     private RIBImpl createRib(
             final Global global,
             final String bgpInstanceName,
-            final BGPTableTypeRegistryConsumer tableTypeRegistry,
-            final BgpDeployer.WriteConfiguration configurationWriter) {
+            final BGPTableTypeRegistryConsumer tableTypeRegistry) {
         this.afiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true);
         final Config globalConfig = global.getConfig();
         this.asNumber = globalConfig.getAs();
@@ -254,8 +251,7 @@ public final class RibImpl implements RIB, BGPRIBStateConsumer, AutoCloseable {
                 this.domBroker,
                 toTableTypes(this.afiSafi, tableTypeRegistry),
                 pathSelectionModes,
-                this.extensions.getClassLoadingStrategy(),
-                configurationWriter);
+                this.extensions.getClassLoadingStrategy());
     }
 
     @Override
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BgpDeployer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BgpDeployer.java
deleted file mode 100644 (file)
index b8d6e8f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.bgp.rib.impl.spi;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * The BgpDeployer service is managing RIB, Peer, Application Peer instances based on the OpenConfig BGP
- * configuration status.
- * BGP configuration is held under the specific OpenConfig's NetworkInstance subtree.
- */
-public interface BgpDeployer {
-
-    interface WriteConfiguration {
-        void apply();
-    }
-
-    /**
-     * Get pointer to NetworkInstance instance where this particular BGP deployer is binded.
-     *
-     * @return InstanceIdentifier
-     */
-    InstanceIdentifier<NetworkInstance> getInstanceIdentifier();
-
-    BGPTableTypeRegistryConsumer getTableTypeRegistry();
-
-    <T extends DataObject> ListenableFuture<Void> writeConfiguration(T data, InstanceIdentifier<T> identifier);
-
-    <T extends DataObject> ListenableFuture<Void> removeConfiguration(InstanceIdentifier<T> identifier);
-
-    /**
-     * Create, start and register rib instance
-     * @param rootIdentifier
-     * @param global
-     * @param configurationWriter
-     */
-    void onGlobalModified(InstanceIdentifier<Bgp> rootIdentifier, Global global, WriteConfiguration configurationWriter);
-
-    /**
-     * Destroy rib instance
-     * @param rootIdentifier
-     */
-    void onGlobalRemoved(InstanceIdentifier<Bgp> rootIdentifier);
-
-    /**
-     * Create, start and register peer instance
-     * @param rootIdentifier
-     * @param neighbor
-     */
-    void onNeighborModified(InstanceIdentifier<Bgp> rootIdentifier, Neighbor neighbor, WriteConfiguration configurationWriter);
-
-    /**
-     * Destroy peer instance
-     * @param rootIdentifier
-     * @param neighbor
-     */
-    void onNeighborRemoved(InstanceIdentifier<Bgp> rootIdentifier, Neighbor neighbor);
-}
index 0badd498a244186b6328ad43341f3a94262e3e7c..25f2082896f5196ff0c3abb1678ca8d5317e65a4 100644 (file)
@@ -58,8 +58,6 @@
     <argument ref="bgpTableTypeRegistry"/>
   </bean>
 
-  <service ref="bgpDeployer" interface="org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer"/>
-
   <bean id="ribImpl" class="org.opendaylight.protocol.bgp.rib.impl.config.RibImpl" scope="prototype">
     <argument ref="clusterSingletonServiceProvider"/>
     <argument ref="globalBgpExtensions"/>
index e10b1c574410848f8eff4ffc93fafafbdd00f055..08cfe09030f7ec52383e0768fc44ea95124346f4 100644 (file)
@@ -93,19 +93,16 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class AbstractRIBTestSetup {
 
-    private RIBImpl rib;
-    private static final ClusterIdentifier CLUSTER_ID = new ClusterIdentifier("128.0.0.1");
-    private static final BgpId RIB_ID = new BgpId("127.0.0.1");
     protected static final Class<? extends AddressFamily> AFI = Ipv4AddressFamily.class;
     protected static final Class<? extends SubsequentAddressFamily> SAFI = UnicastSubsequentAddressFamily.class;
-    protected static final QName AFI_QNAME = BindingReflections.findQName(AFI).intern();
-    protected static final QName SAFI_QNAME = BindingReflections.findQName(SAFI).intern();
     protected static final TablesKey KEY = new TablesKey(AFI, SAFI);
+    protected static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
+    private static final ClusterIdentifier CLUSTER_ID = new ClusterIdentifier("128.0.0.1");
+    private static final BgpId RIB_ID = new BgpId("127.0.0.1");
+    private RIBImpl rib;
     private BindingCodecTreeFactory codecFactory;
     private RIBActivator a1;
     private RIBSupport ribSupport;
-    protected static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
-
     @Mock
     private BGPDispatcher dispatcher;
 
@@ -125,7 +122,7 @@ public class AbstractRIBTestSetup {
     private DOMDataWriteTransaction domTransWrite;
 
     @Mock
-    private CheckedFuture<?,?> future;
+    private CheckedFuture<?, ?> future;
 
     @Mock
     private Optional<Rib> o;
@@ -136,6 +133,25 @@ public class AbstractRIBTestSetup {
     @Mock
     private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
 
+    private static ModuleInfoBackedContext createClassLoadingStrategy() {
+        final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
+        try {
+            ctx.registerModuleInfo(BindingReflections.getModuleInfo(Ipv4Route.class));
+        } catch (final RuntimeException e) {
+            throw e;
+        } catch (final Exception e) {
+            throw new RuntimeException(e);
+        }
+        return ctx;
+    }
+
+    private static BindingCodecTreeFactory createCodecFactory(final ClassLoadingStrategy str, final SchemaContext ctx) {
+        final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
+        final BindingNormalizedNodeCodecRegistry codec = new BindingNormalizedNodeCodecRegistry(generator);
+        codec.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(str, ctx));
+        return codec;
+    }
+
     @Before
     public void setUp() throws Exception {
         mockRib();
@@ -145,7 +161,7 @@ public class AbstractRIBTestSetup {
         final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
         final ModuleInfoBackedContext strategy = createClassLoadingStrategy();
         final SchemaContext schemaContext = strategy.tryToCreateSchemaContext().get();
-        this.codecFactory = createCodecFactory(strategy,schemaContext);
+        this.codecFactory = createCodecFactory(strategy, schemaContext);
         final List<BgpTableType> localTables = new ArrayList<>();
         localTables.add(new BgpTableTypeImpl(AFI, SAFI));
 
@@ -153,33 +169,17 @@ public class AbstractRIBTestSetup {
         this.a1.startRIBExtensionProvider(context);
         mockedMethods();
         doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
-            .registerClusterSingletonService(any(ClusterSingletonService.class));
-        this.rib = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test"), new AsNumber(5L), RIB_ID, CLUSTER_ID, context,
-            this.dispatcher, this.codecFactory, this.dom, localTables, Collections.singletonMap(new TablesKey(AFI, SAFI),
-            BasePathSelectionModeFactory.createBestPathSelectionStrategy()), GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), null);
+                .registerClusterSingletonService(any(ClusterSingletonService.class));
+        this.rib = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test"),
+                new AsNumber(5L), RIB_ID, CLUSTER_ID, context,
+                this.dispatcher, this.codecFactory, this.dom, localTables,
+                Collections.singletonMap(new TablesKey(AFI, SAFI),
+                        BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
+                GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
         this.rib.onGlobalContextUpdated(schemaContext);
         this.ribSupport = getRib().getRibSupportContext().getRIBSupportContext(KEY).getRibSupport();
     }
 
-    private static ModuleInfoBackedContext createClassLoadingStrategy() {
-        final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
-        try {
-            ctx.registerModuleInfo(BindingReflections.getModuleInfo(Ipv4Route.class));
-        } catch (final RuntimeException e) {
-            throw e;
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
-        }
-        return ctx;
-    }
-
-    private static BindingCodecTreeFactory createCodecFactory(final ClassLoadingStrategy str, final SchemaContext ctx) {
-        final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
-        final BindingNormalizedNodeCodecRegistry codec = new BindingNormalizedNodeCodecRegistry(generator);
-        codec.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(str, ctx));
-        return codec;
-    }
-
     @SuppressWarnings("unchecked")
     private void mockedMethods() throws Exception {
         MockitoAnnotations.initMocks(this);
@@ -245,10 +245,6 @@ public class AbstractRIBTestSetup {
         return this.rib;
     }
 
-    public DOMDataBroker getDOMBroker() {
-        return this.dom;
-    }
-
     public DOMDataWriteTransaction getTransaction() {
         return this.domTransWrite;
     }
index ea8495600f45ddeec6c36d3270da0f3864d01da8..acb325c46410c3c046785f50e5d64a5b06771a06 100644 (file)
@@ -56,7 +56,7 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
 
         this.ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"),
             AS_NUMBER, BGP_ID, null, this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
-            getDomBroker(), TABLES_TYPE, pathTables, this.ribExtension.getClassLoadingStrategy(), null);
+            getDomBroker(), TABLES_TYPE, pathTables, this.ribExtension.getClassLoadingStrategy());
 
         this.ribImpl.instantiateServiceInstance();
         this.ribImpl.onGlobalContextUpdated(this.schemaContext);
index 8cec9a283b59395a33541e18171e7c6f83501619..28556d143403e74eb2e50e4a31b1a4681f0b6974 100644 (file)
@@ -45,7 +45,7 @@ public class AddPathBasePathsTest extends AbstractAddPathTest {
         this.ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"),
             AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher,
             this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables,
-            this.ribExtension.getClassLoadingStrategy(), null);
+            this.ribExtension.getClassLoadingStrategy());
         this.ribImpl.instantiateServiceInstance();
         this.ribImpl.onGlobalContextUpdated(this.schemaContext);
         final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
index 81dce3b1064e26ec2d5fd9ddeab1c990258dc69a..a22d9de6dd6da0886b2315829351740f1d06475b 100644 (file)
@@ -44,7 +44,7 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
         this.ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"),
             AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher,
             this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables,
-            this.ribExtension.getClassLoadingStrategy(), null);
+            this.ribExtension.getClassLoadingStrategy());
 
         this.ribImpl.instantiateServiceInstance();
         this.ribImpl.onGlobalContextUpdated(this.schemaContext);
index b9b40e61ee9f4ca8591ab93664f6a16450bcfd95..54437d5a164fe8f2dc324f7fed393e4304cbcfa1 100755 (executable)
@@ -142,7 +142,7 @@ public class ParserToSalTest extends AbstractConcurrentDataBrokerTest {
             AS_NUMBER, new BgpId("127.0.0.1"), null, this.ext2, this.dispatcher,
             this.codecFactory, getDomBroker(), tables, Collections.singletonMap(TABLE_KEY,
             BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
-            GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), null);
+            GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
         rib.instantiateServiceInstance();
         assertTablesExists(tables);
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
@@ -160,7 +160,7 @@ public class ParserToSalTest extends AbstractConcurrentDataBrokerTest {
         final RIBImpl rib = new RIBImpl(this.clusterSingletonServiceProvider, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID,
             null, this.ext1, this.dispatcher, this.codecFactory, getDomBroker(), tables,
             Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
-            GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), null);
+            GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
         rib.instantiateServiceInstance();
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
         assertTablesExists(tables);
index c01794131e24289850944c307e85bc516d2d93b7..51b0b8df6302f9a2dc8831f22f00aa2051cf8410 100644 (file)
@@ -199,8 +199,7 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
             BasePathSelectionModeFactory.createBestPathSelectionStrategy());
         final RIBImpl ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId(RIB_ID), AS_NUMBER,
             new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
-            this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy(),
-            null);
+            this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy());
         ribImpl.instantiateServiceInstance();
         ribImpl.onGlobalContextUpdated(this.schemaContext);
 
@@ -240,8 +239,7 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
             BasePathSelectionModeFactory.createBestPathSelectionStrategy());
         final RIBImpl ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId(RIB_ID), AS_NUMBER,
             new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
-            this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy(),
-            null);
+            this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy());
         ribImpl.instantiateServiceInstance();
         ribImpl.onGlobalContextUpdated(this.schemaContext);
 
index 0985852752d604ac7137e99f4c4a7ff16e5c03b6..25575d18c7e1670583e613b96970ef320b04f44d 100644 (file)
@@ -18,7 +18,6 @@ import io.netty.util.concurrent.Future;
 import java.net.InetSocketAddress;
 import java.util.Collections;
 import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.LongAdder;
 import org.junit.Before;
 import org.mockito.Mock;
 import org.mockito.Mockito;
@@ -37,7 +36,6 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.AbstractImportPolicy;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.ImportPolicyPeerTracker;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
@@ -63,8 +61,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.osgi.framework.ServiceRegistration;
 
 class AbstractConfig {
-    static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
     protected static final AsNumber AS = new AsNumber(72L);
+    protected static final RibId RIB_ID = new RibId("test");
+    static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
     protected ClusterSingletonService singletonService;
     @Mock
     protected RIB rib;
@@ -73,8 +72,6 @@ class AbstractConfig {
     @Mock
     protected BGPTableTypeRegistryConsumer tableTypeRegistry;
     @Mock
-    protected BgpDeployer.WriteConfiguration configurationWriter;
-    @Mock
     protected DOMTransactionChain domTx;
     @Mock
     protected BGPDispatcher dispatcher;
@@ -92,7 +89,6 @@ class AbstractConfig {
     private ImportPolicyPeerTracker importPolicyPeerTracker;
     @Mock
     private DOMDataTreeChangeService dataTreeChangeService;
-    protected static final RibId RIB_ID = new RibId("test");
 
     @Before
     public void setUp() throws Exception {
@@ -146,7 +142,6 @@ class AbstractConfig {
         Mockito.doReturn(java.util.Optional.of(TABLES_KEY)).when(this.tableTypeRegistry).getTableKey(any());
         Mockito.doReturn(Collections.singleton(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)))
                 .when(this.rib).getLocalTables();
-        Mockito.doNothing().when(this.configurationWriter).apply();
 
         Mockito.doNothing().when(this.bgpPeerRegistry).addPeer(any(IpAddress.class), any(BGPSessionListener.class), any(BGPSessionPreferences.class));
         Mockito.doNothing().when(this.bgpPeerRegistry).removePeer(any(IpAddress.class));
index 5316345efd51547d63f869bb4da5c91ba00c54f5..a7a65759a8e4d1a48f843be033e906f231419c5a 100644 (file)
@@ -28,8 +28,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.open
 public class AppPeerTest extends AbstractConfig {
     private static final AppPeer APP_PEER = new AppPeer();
     private final Neighbor neighbor = new NeighborBuilder().setConfig(new ConfigBuilder().addAugmentation(Config2.class,
-        new Config2Builder().setPeerGroup(OpenConfigMappingUtil.APPLICATION_PEER_GROUP_NAME).build()).build())
-        .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
+            new Config2Builder().setPeerGroup(OpenConfigMappingUtil.APPLICATION_PEER_GROUP_NAME).build()).build())
+            .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
 
     @Override
     @Before
@@ -39,7 +39,7 @@ public class AppPeerTest extends AbstractConfig {
 
     @Test
     public void testAppPeer() throws Exception {
-        APP_PEER.start(this.rib, this.neighbor, this.tableTypeRegistry, this.configurationWriter);
+        APP_PEER.start(this.rib, this.neighbor, this.tableTypeRegistry);
         Mockito.verify(this.rib).getYangRibId();
         Mockito.verify(this.rib).getService();
         Mockito.verify(this.rib).getRibIServiceGroupIdentifier();
@@ -48,7 +48,6 @@ public class AppPeerTest extends AbstractConfig {
 
         this.singletonService.instantiateServiceInstance();
         Mockito.verify(this.rib, times(2)).getYangRibId();
-        Mockito.verify(this.configurationWriter).apply();
         Mockito.verify(this.rib).getRibSupportContext();
         Mockito.verify(this.rib, times(2)).getLocalTablesKeys();
         Mockito.verify(this.domTx).newWriteOnlyTransaction();
@@ -61,12 +60,13 @@ public class AppPeerTest extends AbstractConfig {
         Mockito.verify(this.rib, times(4)).getYangRibId();
         Mockito.verify(this.rib, times(4)).getService();
         Mockito.verify(this.rib, times(2)).getRibIServiceGroupIdentifier();
-        Mockito.verify(this.rib, times(2)).registerClusterSingletonService(any(ClusterSingletonService.class));
+        Mockito.verify(this.rib, times(2))
+                .registerClusterSingletonService(any(ClusterSingletonService.class));
         Mockito.verify(this.listener, times(2)).close();
 
         assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
         assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder()
-            .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
+                .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
         APP_PEER.close();
         Mockito.verify(this.singletonServiceRegistration, times(2)).close();
     }
index 9c132f708e937b54493f2e69ee682cc7545cb863..808e99cd19b483638fdf3e163bc3e3ea393b1b1a 100644 (file)
@@ -57,7 +57,6 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.InstanceType;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
@@ -222,10 +221,9 @@ public class BgpDeployerImplTest {
         verify(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
         verify(this.bundleContext).registerService(eq(InstanceType.RIB.getServices()), any(), any(Dictionary.class));
         verify(spyDeployer).onDataTreeChanged(any(Collection.class));
-        verify(spyDeployer).onGlobalModified(any(InstanceIdentifier.class), any(), any());
-        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class), any(BgpDeployer.WriteConfiguration.class));
-        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any(BgpDeployer
-            .WriteConfiguration.class));
+        verify(spyDeployer).onGlobalModified(any(InstanceIdentifier.class), any());
+        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class));
+        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer).invoke("registerRibInstance", any(RibImpl.class), anyString());
         verify(spyDeployer).onDataTreeChanged(any(Collection.class));
 
@@ -235,11 +233,9 @@ public class BgpDeployerImplTest {
         verify(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
         verify(this.bundleContext).registerService(eq(InstanceType.RIB.getServices()), any(), any(Dictionary.class));
         verify(spyDeployer, times(2)).onDataTreeChanged(any(Collection.class));
-        verify(spyDeployer, times(2)).onGlobalModified(any(InstanceIdentifier.class), any(), any());
-        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class), any(BgpDeployer
-            .WriteConfiguration.class));
-        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any(BgpDeployer
-            .WriteConfiguration.class));
+        verify(spyDeployer, times(2)).onGlobalModified(any(InstanceIdentifier.class), any());
+        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class));
+        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer).invoke("registerRibInstance", any(RibImpl.class), anyString());
         verify(spyDeployer, times(2)).onDataTreeChanged(any(Collection.class));
 
@@ -250,15 +246,14 @@ public class BgpDeployerImplTest {
         verify(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
         verify(this.bundleContext, times(2)).registerService(eq(InstanceType.RIB.getServices()), any(), any(Dictionary.class));
         verify(spyDeployer, times(3)).onDataTreeChanged(any(Collection.class));
-        verify(spyDeployer, times(3)).onGlobalModified(any(InstanceIdentifier.class), any(), any());
-        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class),
-            any(BgpDeployer.WriteConfiguration.class));
-        verifyPrivate(spyDeployer).invoke("onGlobalUpdated", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any(BgpDeployer.WriteConfiguration.class));
+        verify(spyDeployer, times(3)).onGlobalModified(any(InstanceIdentifier.class), any());
+        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class));
+        verifyPrivate(spyDeployer).invoke("onGlobalUpdated", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verify(this.dataTreeRegistration).close();
         verify(this.registration).unregister();
         verifyPrivate(spyDeployer).invoke("closeAllBindedPeers", any(InstanceIdentifier.class));
-        verifyPrivate(spyDeployer, times(2)).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any
-            (BgpDeployer.WriteConfiguration.class));
+        verifyPrivate(spyDeployer, times(2)).invoke("initiateRibInstance",
+                any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer, times(2)).invoke("registerRibInstance", any(RibImpl.class), anyString());
         verify(spyDeployer, times(3)).onDataTreeChanged(any(Collection.class));
 
@@ -270,16 +265,15 @@ public class BgpDeployerImplTest {
         verify(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
         verify(this.bundleContext, times(2)).registerService(eq(InstanceType.RIB.getServices()), any(), any(Dictionary.class));
         verify(spyDeployer, times(4)).onDataTreeChanged(any(Collection.class));
-        verify(spyDeployer, times(3)).onGlobalModified(any(InstanceIdentifier.class), any(), any());
+        verify(spyDeployer, times(3)).onGlobalModified(any(InstanceIdentifier.class), any());
         verify(spyDeployer).onGlobalRemoved(any(InstanceIdentifier.class));
         verify(this.dataTreeRegistration, times(2)).close();
         verify(this.registration, times(2)).unregister();
-        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class),
-            any(BgpDeployer.WriteConfiguration.class));
-        verifyPrivate(spyDeployer).invoke("onGlobalUpdated", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any(BgpDeployer.WriteConfiguration.class));
+        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class));
+        verifyPrivate(spyDeployer).invoke("onGlobalUpdated", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer, times(2)).invoke("closeAllBindedPeers", any(InstanceIdentifier.class));
-        verifyPrivate(spyDeployer, times(2)).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any
-            (BgpDeployer.WriteConfiguration.class));
+        verifyPrivate(spyDeployer, times(2)).invoke("initiateRibInstance",
+                any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer, times(2)).invoke("registerRibInstance", any(RibImpl.class), anyString());
         verify(spyDeployer, times(4)).onDataTreeChanged(any(Collection.class));
 
@@ -314,10 +308,9 @@ public class BgpDeployerImplTest {
         verify(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
         verify(this.bundleContext).registerService(eq(InstanceType.RIB.getServices()), any(), any(Dictionary.class));
         verify(spyDeployer).onDataTreeChanged(any(Collection.class));
-        verify(spyDeployer).onGlobalModified(any(InstanceIdentifier.class), any(), any());
-        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class), any(BgpDeployer.WriteConfiguration.class));
-        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class), any(BgpDeployer
-            .WriteConfiguration.class));
+        verify(spyDeployer).onGlobalModified(any(InstanceIdentifier.class), any());
+        verifyPrivate(spyDeployer).invoke("onGlobalCreated", any(InstanceIdentifier.class), any(Global.class));
+        verifyPrivate(spyDeployer).invoke("initiateRibInstance", any(InstanceIdentifier.class), any(Global.class), any(RibImpl.class));
         verifyPrivate(spyDeployer).invoke("registerRibInstance", any(RibImpl.class), anyString());
         verify(spyDeployer).onDataTreeChanged(any(Collection.class));
 
@@ -340,11 +333,11 @@ public class BgpDeployerImplTest {
         spyDeployer.onDataTreeChanged(this.collection);
         verify(spyDeployer, times(2)).onDataTreeChanged(any(Collection.class));
         verifyPrivate(spyDeployer).invoke("onNeighborsChanged", any(DataObjectModification.class), any(InstanceIdentifier.class));
-        verify(spyDeployer).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class), any());
-        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class), any(BgpDeployer.WriteConfiguration.class));
+        verify(spyDeployer).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class));
+        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class));
         verify(this.blueprintContainer).getComponentInstance(eq("bgpPeer"));
         verifyPrivate(spyDeployer).invoke("initiatePeerInstance", any(InstanceIdentifier.class), any(InstanceIdentifier.class), any(Neighbor.class),
-            any(PeerBean.class), any(BgpDeployer.WriteConfiguration.class));
+            any(PeerBean.class));
         verifyPrivate(spyDeployer).invoke("registerPeerInstance", any(BgpPeer.class), anyString());
         verify(this.bundleContext).registerService(eq(InstanceType.PEER.getServices()), any(BgpPeer.class), any(Dictionary.class));
 
@@ -352,11 +345,11 @@ public class BgpDeployerImplTest {
         spyDeployer.onDataTreeChanged(this.collection);
         verify(spyDeployer, times(3)).onDataTreeChanged(any(Collection.class));
         verifyPrivate(spyDeployer, times(2)).invoke("onNeighborsChanged", any(DataObjectModification.class), any(InstanceIdentifier.class));
-        verify(spyDeployer, times(2)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class), any());
-        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class), any(BgpDeployer.WriteConfiguration.class));
+        verify(spyDeployer, times(2)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class));
+        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class));
         verify(this.blueprintContainer).getComponentInstance(eq("bgpPeer"));
         verifyPrivate(spyDeployer).invoke("initiatePeerInstance", any(InstanceIdentifier.class), any(InstanceIdentifier.class), any(Neighbor.class),
-            any(PeerBean.class), any(BgpDeployer.WriteConfiguration.class));
+            any(PeerBean.class));
         verifyPrivate(spyDeployer).invoke("registerPeerInstance", any(Neighbor.class), anyString());
         verify(this.bundleContext).registerService(eq(InstanceType.PEER.getServices()), any(BgpPeer.class), any(Dictionary.class));
 
@@ -365,11 +358,11 @@ public class BgpDeployerImplTest {
         spyDeployer.onDataTreeChanged(this.collection);
         verify(spyDeployer, times(4)).onDataTreeChanged(any(Collection.class));
         verifyPrivate(spyDeployer, times(3)).invoke("onNeighborsChanged", any(DataObjectModification.class), any(InstanceIdentifier.class));
-        verify(spyDeployer, times(3)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class), any());
-        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class), any(BgpDeployer.WriteConfiguration.class));
+        verify(spyDeployer, times(3)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class));
+        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class));
         verify(this.blueprintContainer).getComponentInstance(eq("bgpPeer"));
         verifyPrivate(spyDeployer, times(2)).invoke("initiatePeerInstance", any(InstanceIdentifier.class), any(InstanceIdentifier.class), any(Neighbor.class),
-            any(PeerBean.class), any(BgpDeployer.WriteConfiguration.class));
+            any(PeerBean.class));
         verifyPrivate(spyDeployer, times(2)).invoke("registerPeerInstance", any(Neighbor.class), anyString());
         verify(this.bundleContext, times(2)).registerService(eq(InstanceType.PEER.getServices()), any(BgpPeer.class), any(Dictionary.class));
 
@@ -380,12 +373,12 @@ public class BgpDeployerImplTest {
         verify(spyDeployer, times(5)).onDataTreeChanged(any(Collection.class));
         verify( this.dObject).getDataBefore();
         verifyPrivate(spyDeployer, times(4)).invoke("onNeighborsChanged", any(DataObjectModification.class), any(InstanceIdentifier.class));
-        verify(spyDeployer, times(3)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class), any());
+        verify(spyDeployer, times(3)).onNeighborModified(any(InstanceIdentifier.class), any(Neighbor.class));
         verify(spyDeployer, times(1)).onNeighborRemoved(any(InstanceIdentifier.class), any(Neighbor.class));
-        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class), any(BgpDeployer.WriteConfiguration.class));
+        verifyPrivate(spyDeployer).invoke("onNeighborCreated", any(InstanceIdentifier.class), any(Neighbor.class));
         verify(this.blueprintContainer).getComponentInstance(eq("bgpPeer"));
         verifyPrivate(spyDeployer, times(2)).invoke("initiatePeerInstance", any(InstanceIdentifier.class), any(InstanceIdentifier.class), any(Neighbor.class),
-            any(PeerBean.class), any(BgpDeployer.WriteConfiguration.class));
+            any(PeerBean.class));
         verifyPrivate(spyDeployer, times(2)).invoke("registerPeerInstance", any(Neighbor.class), anyString());
         verify(this.bundleContext, times(2)).registerService(eq(InstanceType.PEER.getServices()), any(BgpPeer.class), any(Dictionary.class));
 
index 75d6397693f1046bebafac090ac9d0644ef652b9..ea08ec3f358715594ad7d31a95e55035e4f16c72 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.protocol.bgp.rib.impl.config;
 import static junit.framework.TestCase.fail;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
@@ -62,10 +61,56 @@ public class BgpPeerTest extends AbstractConfig {
     static final String MD5_PASSWORD = "123";
     static final PortNumber PORT = new PortNumber(179);
     static final AfiSafi AFI_SAFI_IPV4 = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
-    .addAugmentation(AfiSafi1.class, new AfiSafi1Builder().setReceive(true).setSendMax(SHORT).build()).build();
+            .addAugmentation(AfiSafi1.class, new AfiSafi1Builder().setReceive(true).setSendMax(SHORT).build()).build();
     static final List<AfiSafi> AFI_SAFI = Collections.singletonList(AFI_SAFI_IPV4);
     private BgpPeer bgpPeer;
 
+    static Neighbor createNeighborExpected(final IpAddress neighborAddress) {
+        return new NeighborBuilder()
+                .setAfiSafis(createAfiSafi())
+                .setConfig(createConfig())
+                .setNeighborAddress(neighborAddress)
+                .setRouteReflector(createRR())
+                .setTimers(createTimers())
+                .setTransport(createTransport())
+                .setAddPaths(createAddPath())
+                .build();
+    }
+
+    static Transport createTransport() {
+        return new TransportBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp
+                .rev151009.bgp.neighbor.group.transport.ConfigBuilder().setMtuDiscovery(false).setPassiveMode(false)
+                .addAugmentation(Config1.class, new Config1Builder().setRemotePort(PORT).build()).build()).build();
+    }
+
+    static Timers createTimers() {
+        return new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009
+                .bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(DEFAULT_TIMERS)
+                .setMinimumAdvertisementInterval(DEFAULT_TIMERS)
+                .setKeepaliveInterval(DEFAULT_TIMERS).setConnectRetry(DEFAULT_TIMERS).build()).build();
+    }
+
+    static RouteReflector createRR() {
+        return new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp
+                .rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder()
+                .setRouteReflectorClusterId(RrClusterIdTypeBuilder.getDefaultInstance("127.0.0.1"))
+                .setRouteReflectorClient(false).build()).build();
+    }
+
+    static Config createConfig() {
+        return new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
+                .ConfigBuilder().setPeerAs(AS).setPeerType(PeerType.INTERNAL).setAuthPassword(MD5_PASSWORD)
+                .setRouteFlapDamping(false).setSendCommunity(CommunityType.NONE).build();
+    }
+
+    static AfiSafis createAfiSafi() {
+        return new AfiSafisBuilder().setAfiSafi(AFI_SAFI).build();
+    }
+
+    static AddPaths createAddPath() {
+        return new AddPathsBuilder().setConfig(new ConfigBuilder().setReceive(true).setSendMax(SHORT).build()).build();
+    }
+
     @Override
     @Before
     public void setUp() throws Exception {
@@ -77,10 +122,10 @@ public class BgpPeerTest extends AbstractConfig {
     @Test
     public void testBgpPeer() throws Exception {
         final Neighbor neighbor = new NeighborBuilder().setAfiSafis(createAfiSafi()).setConfig(createConfig())
-            .setNeighborAddress(NEIGHBOR_ADDRESS).setRouteReflector(createRR()).setTimers(createTimers())
-            .setTransport(createTransport()).setAddPaths(createAddPath()).build();
+                .setNeighborAddress(NEIGHBOR_ADDRESS).setRouteReflector(createRR()).setTimers(createTimers())
+                .setTransport(createTransport()).setAddPaths(createAddPath()).build();
 
-        this.bgpPeer.start(this.rib, neighbor, this.tableTypeRegistry, this.configurationWriter);
+        this.bgpPeer.start(this.rib, neighbor, this.tableTypeRegistry);
         Mockito.verify(this.rib).createPeerChain(any());
         Mockito.verify(this.rib, times(2)).getLocalAs();
         Mockito.verify(this.rib).getLocalTables();
@@ -88,13 +133,12 @@ public class BgpPeerTest extends AbstractConfig {
         Mockito.verify(this.rib).registerClusterSingletonService(any(ClusterSingletonService.class));
 
         this.singletonService.instantiateServiceInstance();
-        Mockito.verify(this.configurationWriter).apply();
         Mockito.verify(this.bgpPeerRegistry).addPeer(any(), any(), any());
         Mockito.verify(this.dispatcher).createReconnectingClient(any(InetSocketAddress.class),
-            anyInt(), any(KeyMapping.class));
+                anyInt(), any(KeyMapping.class));
 
         try {
-            this.bgpPeer.start(this.rib, neighbor, this.tableTypeRegistry, this.configurationWriter);
+            this.bgpPeer.start(this.rib, neighbor, this.tableTypeRegistry);
             fail("Expected Exception");
         } catch (final IllegalStateException expected) {
             assertEquals("Previous peer instance was not closed.", expected.getMessage());
@@ -123,52 +167,9 @@ public class BgpPeerTest extends AbstractConfig {
         Mockito.verify(this.future, times(2)).cancel(true);
 
         final Neighbor neighborDiffConfig = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS)
-            .setAfiSafis(createAfiSafi()).build();
-        this.bgpPeer.start(this.rib, neighborDiffConfig, this.tableTypeRegistry, this.configurationWriter);
+                .setAfiSafis(createAfiSafi()).build();
+        this.bgpPeer.start(this.rib, neighborDiffConfig, this.tableTypeRegistry);
         assertTrue(this.bgpPeer.containsEqualConfiguration(neighborDiffConfig));
         this.bgpPeer.close();
     }
-
-    static Neighbor createNeighborExpected(final IpAddress neighborAddress) {
-        return new NeighborBuilder()
-            .setAfiSafis(createAfiSafi())
-            .setConfig(createConfig())
-            .setNeighborAddress(neighborAddress)
-            .setRouteReflector(createRR())
-            .setTimers(createTimers())
-            .setTransport(createTransport())
-            .setAddPaths(createAddPath())
-            .build();
-    }
-
-    static Transport createTransport() {
-        return new TransportBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor
-            .group.transport.ConfigBuilder().setMtuDiscovery(false).setPassiveMode(false).addAugmentation(Config1.class, new Config1Builder()
-            .setRemotePort(PORT).build()).build()).build();
-    }
-
-    static Timers createTimers() {
-        return new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
-            .timers.ConfigBuilder().setHoldTime(DEFAULT_TIMERS).setMinimumAdvertisementInterval(DEFAULT_TIMERS)
-            .setKeepaliveInterval(DEFAULT_TIMERS).setConnectRetry(DEFAULT_TIMERS).build()).build();
-    }
-
-    static RouteReflector createRR() {
-        return new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp
-            .neighbor.group.route.reflector.ConfigBuilder().setRouteReflectorClusterId(RrClusterIdTypeBuilder.getDefaultInstance("127.0.0.1"))
-            .setRouteReflectorClient(false).build()).build();
-    }
-
-    static Config createConfig() {
-        return new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder().setPeerAs(AS)
-            .setPeerType(PeerType.INTERNAL).setAuthPassword(MD5_PASSWORD).setRouteFlapDamping(false).setSendCommunity(CommunityType.NONE).build();
-    }
-
-    static AfiSafis createAfiSafi() {
-        return new AfiSafisBuilder().setAfiSafi(AFI_SAFI).build();
-    }
-
-    static AddPaths createAddPath() {
-        return new AddPathsBuilder().setConfig(new ConfigBuilder().setReceive(true).setSendMax(SHORT).build()).build();
-    }
 }
\ No newline at end of file
index b19f92ebb8591013d0b599ebb67b3b3a6532746e..a9994a834624af443bd28fea81b8883dc4b70bad 100644 (file)
@@ -58,12 +58,14 @@ import org.osgi.framework.ServiceRegistration;
 public class RibImplTest extends AbstractConfig {
     private static final List<AfiSafi> AFISAFIS = new ArrayList<>();
     private static final Long ALL_PATHS = 0L;
-    private static final BgpTableType TABLE_TYPE = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+    private static final BgpTableType TABLE_TYPE =
+            new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
     private static final Ipv4Address BGP_ID = new BgpId(new Ipv4Address("127.0.0.1"));
 
     static {
         AFISAFIS.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
-            .addAugmentation(AfiSafi2.class, new AfiSafi2Builder().setReceive(true).setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
+                .addAugmentation(AfiSafi2.class, new AfiSafi2Builder().setReceive(true)
+                        .setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
     }
 
     @Mock
@@ -83,6 +85,13 @@ public class RibImplTest extends AbstractConfig {
     @Mock
     private ServiceRegistration<?> serviceRegistration;
 
+    private static Global createGlobal() {
+        return new GlobalBuilder()
+                .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS).build())
+                .setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
+                        .ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build()).build();
+    }
+
     @Override
     @Before
     public void setUp() throws Exception {
@@ -90,7 +99,8 @@ public class RibImplTest extends AbstractConfig {
         Mockito.doAnswer(invocationOnMock -> {
             RibImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
             return RibImplTest.this.singletonServiceRegistration;
-        }).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
+        }).when(this.clusterSingletonServiceProvider)
+                .registerClusterSingletonService(any(ClusterSingletonService.class));
 
         Mockito.doReturn(mock(GeneratedClassLoadingStrategy.class)).when(this.extension).getClassLoadingStrategy();
         Mockito.doReturn(this.ribSupport).when(this.extension).getRIBSupport(any(TablesKey.class));
@@ -104,28 +114,29 @@ public class RibImplTest extends AbstractConfig {
         Mockito.doReturn(this.domTx).when(this.domDataBroker).createTransactionChain(any());
         final DOMDataTreeChangeService dOMDataTreeChangeService = mock(DOMDataTreeChangeService.class);
         Mockito.doReturn(Collections.singletonMap(DOMDataTreeChangeService.class, dOMDataTreeChangeService))
-            .when(this.domDataBroker).getSupportedExtensions();
+                .when(this.domDataBroker).getSupportedExtensions();
         Mockito.doReturn(this.dataTreeRegistration).when(this.domSchemaService).registerSchemaContextListener(any());
         Mockito.doNothing().when(this.dataTreeRegistration).close();
-        Mockito.doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService).registerDataTreeChangeListener(any(), any());
+        Mockito.doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService)
+                .registerDataTreeChangeListener(any(), any());
         Mockito.doNothing().when(this.serviceRegistration).unregister();
     }
 
     @Test
     public void testRibImpl() throws Exception {
         final RibImpl ribImpl = new RibImpl(this.clusterSingletonServiceProvider, this.extension, this.dispatcher,
-            this.bindingCodecTreeFactory, this.domDataBroker, this.domSchemaService);
+                this.bindingCodecTreeFactory, this.domDataBroker, this.domSchemaService);
         ribImpl.setServiceRegistration(this.serviceRegistration);
-        ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry, this.configurationWriter);
+        ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry);
         verify(this.extension).getClassLoadingStrategy();
         verify(this.domDataBroker).getSupportedExtensions();
         verify(this.clusterSingletonServiceProvider).registerClusterSingletonService(any());
         verify(this.domSchemaService).registerSchemaContextListener(any(RIBImpl.class));
         this.singletonService.instantiateServiceInstance();
-        Mockito.verify(this.configurationWriter).apply();
         assertEquals("RIBImpl{}", ribImpl.toString());
         assertEquals(ServiceGroupIdentifier.create("rib-test-service-group"), ribImpl.getRibIServiceGroupIdentifier());
-        assertEquals(Collections.singleton(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)), ribImpl.getLocalTablesKeys());
+        assertEquals(Collections.singleton(new TablesKey(Ipv4AddressFamily.class,
+                UnicastSubsequentAddressFamily.class)), ribImpl.getLocalTablesKeys());
         assertNotNull(ribImpl.getImportPolicyPeerTracker());
         assertNotNull(ribImpl.getService());
         assertNotNull(ribImpl.getInstanceIdentifier());
@@ -142,11 +153,4 @@ public class RibImplTest extends AbstractConfig {
         verify(this.dataTreeRegistration).close();
         verify(this.serviceRegistration).unregister();
     }
-
-    private static Global createGlobal() {
-        return new GlobalBuilder()
-            .setAfiSafis(new AfiSafisBuilder().setAfiSafi(AFISAFIS).build())
-            .setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
-                .ConfigBuilder().setAs(AS).setRouterId(BGP_ID).build()).build();
-    }
 }
\ No newline at end of file
index 30b5d8100d60a74849a7a9f4645efe86061d9ffe..3ae3b710f14709cac912f22cea8f792a4382ca88 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.bgpcep.bgp.topology.provider.config;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.function.Function;
 import org.opendaylight.bgpcep.bgp.topology.provider.AbstractTopologyBuilder;
 import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
 import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyProvider;
@@ -47,11 +46,11 @@ abstract class AbstractBgpTopologyProvider implements BgpTopologyProvider, AutoC
     }
 
     @Override
-    public final void onTopologyBuilderCreated(final Topology topology, final Function<Topology, Void> writeFunction) {
+    public final void onTopologyBuilderCreated(final Topology topology) {
         LOG.debug("Cretaing topology builder instance {}", topology);
         final TopologyReferenceSingletonService currentInstance = this.topologyBuilders.get(topology.getTopologyId());
         if (currentInstance == null || !currentInstance.getConfiguration().equals(topology)) {
-            final TopologyReferenceSingletonService topologyBuilder = createInstance(topology, writeFunction);
+            final TopologyReferenceSingletonService topologyBuilder = createInstance(topology);
             this.topologyBuilders.put(topology.getTopologyId(), topologyBuilder);
             LOG.debug("Topology builder instance created {}", topologyBuilder);
         }
@@ -83,14 +82,16 @@ abstract class AbstractBgpTopologyProvider implements BgpTopologyProvider, AutoC
         return aug != null && topologyTypeFilter(aug);
     }
 
-    private TopologyReferenceSingletonService createInstance(final Topology topology, final Function<Topology, Void> writeFunction) {
-        final RibReference ribReference = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(topology.getAugmentation(Topology1.class).getRibId())));
-        final AbstractTopologyBuilder<?> topologyBuilder = createTopologyBuilder(this.dataBroker, ribReference, topology.getTopologyId());
-        return new TopologyReferenceSingletonServiceImpl(topologyBuilder, this.deployer, topology, writeFunction);
+    private TopologyReferenceSingletonService createInstance(final Topology topology) {
+        final RibReference ribReference = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class)
+                .child(Rib.class, new RibKey(topology.getAugmentation(Topology1.class).getRibId())));
+        final AbstractTopologyBuilder<?> topologyBuilder = createTopologyBuilder(this.dataBroker,
+                ribReference, topology.getTopologyId());
+        return new TopologyReferenceSingletonServiceImpl(topologyBuilder, this.deployer, topology);
     }
 
-    abstract AbstractTopologyBuilder<?> createTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
-            final TopologyId topologyId);
+    abstract AbstractTopologyBuilder<?> createTopologyBuilder(final DataBroker dataProvider,
+            final RibReference locRibReference, final TopologyId topologyId);
 
     abstract boolean topologyTypeFilter(TopologyTypes1 topology);
 
diff --git a/bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/BackwardsCssTopologyProvider.java b/bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/config/BackwardsCssTopologyProvider.java
deleted file mode 100644 (file)
index 1a11d1d..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.bgpcep.bgp.topology.provider.config;
-
-import com.google.common.reflect.AbstractInvocationHandler;
-import com.google.common.reflect.Reflection;
-import java.lang.reflect.Method;
-import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
-import org.opendaylight.bgpcep.bgp.topology.provider.spi.TopologyReferenceSingletonService;
-import org.opendaylight.bgpcep.topology.TopologyReference;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.config.rev160726.Topology1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.config.rev160726.Topology1Builder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.osgi.framework.BundleContext;
-
-public final class BackwardsCssTopologyProvider {
-
-    private BackwardsCssTopologyProvider() {
-        throw new UnsupportedOperationException();
-    }
-
-    public static TopologyReferenceSingletonService createBackwardsCssInstance(final TopologyTypes topologyTypes, final TopologyId topologyId, final BundleContext bundleContext,
-            final KeyedInstanceIdentifier<Rib, RibKey> ribIId) {
-        //map configuration to topology
-        final Topology topology = createConfiguration(topologyTypes, topologyId, ribIId.getKey().getId());
-        //create instance
-        final WaitingServiceTracker<BgpTopologyDeployer> deployerTracker = WaitingServiceTracker.create(BgpTopologyDeployer.class, bundleContext);
-        final BgpTopologyDeployer topologyDeployer = deployerTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-        topologyDeployer.createInstance(topology);
-        //get topology service, use filter
-        final WaitingServiceTracker<TopologyReference> topologyTracker = WaitingServiceTracker.create(TopologyReference.class,
-                bundleContext, "(" + "topology-id" + "=" + topology.getTopologyId().getValue() + ")");
-        final TopologyReference topologyService = topologyTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-        return Reflection.newProxy(TopologyReferenceSingletonService.class, new AbstractInvocationHandler() {
-            @Override
-            protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
-                if (method.getName().equals("close")) {
-                    topologyDeployer.removeInstance(topology);
-                    deployerTracker.close();
-                    topologyTracker.close();
-                    return null;
-                }
-
-                return method.invoke(topologyService, args);
-            }
-        });
-    }
-
-    private static Topology createConfiguration(final TopologyTypes topologyTypes, final TopologyId topologyId, final RibId ribId) {
-        final TopologyBuilder topologyBuilder = new TopologyBuilder();
-        topologyBuilder.setTopologyId(topologyId);
-        topologyBuilder.setKey(new TopologyKey(topologyBuilder.getTopologyId()));
-        topologyBuilder.setTopologyTypes(topologyTypes);
-        topologyBuilder.addAugmentation(Topology1.class, new Topology1Builder().setRibId(ribId).build());
-        return topologyBuilder.build();
-    }
-
-}
\ No newline at end of file
index 2ef5c7c34905988a7d192a37ebef1b31752c9e37..601ea18b27d3a0fea3d5a436295f29892285281b 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Set;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
@@ -27,7 +26,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
@@ -35,36 +33,40 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist
 import org.opendaylight.protocol.bgp.rib.spi.util.ClusterSingletonServiceRegistrationHelper;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class BgpTopologyDeployerImpl implements AutoCloseable, ClusteredDataTreeChangeListener<Topology>, BgpTopologyDeployer {
+public final class BgpTopologyDeployerImpl implements BgpTopologyDeployer, AutoCloseable,
+        ClusteredDataTreeChangeListener<Topology> {
 
     private static final Logger LOG = LoggerFactory.getLogger(BgpTopologyDeployerImpl.class);
-    private static final InstanceIdentifier<Topology> TOPOLOGY_IID = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class);
+    private static final InstanceIdentifier<Topology> TOPOLOGY_IID =
+            InstanceIdentifier.create(NetworkTopology.class).child(Topology.class);
 
     @GuardedBy("this")
     private final Set<BgpTopologyProvider> topologyProviders = new HashSet<>();
     private final DataBroker dataBroker;
-    private final ListenerRegistration<BgpTopologyDeployerImpl> registration;
     private final BundleContext context;
     private final ClusterSingletonServiceProvider singletonProvider;
+    private ListenerRegistration<BgpTopologyDeployerImpl> registration;
     @GuardedBy("this")
     private boolean closed;
 
-    public BgpTopologyDeployerImpl(final BundleContext context, final DataBroker dataBroker, final ClusterSingletonServiceProvider singletonProvider) {
+    public BgpTopologyDeployerImpl(final BundleContext context, final DataBroker dataBroker,
+            final ClusterSingletonServiceProvider singletonProvider) {
         this.context = requireNonNull(context);
         this.dataBroker = requireNonNull(dataBroker);
         this.singletonProvider = requireNonNull(singletonProvider);
-        this.registration =
-            this.dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class)), this);
+    }
+
+    public void init() {
+        this.registration = this.dataBroker.registerDataTreeChangeListener(
+                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOPOLOGY_IID), this);
         LOG.info("BGP topology deployer started.");
     }
 
@@ -78,20 +80,25 @@ public final class BgpTopologyDeployerImpl implements AutoCloseable, ClusteredDa
             final DataObjectModification<Topology> rootNode = change.getRootNode();
             final Topology dataBefore = rootNode.getDataBefore();
             final Topology dataAfter = rootNode.getDataAfter();
-            LOG.trace("BGP topology deployer configuration changed: modification type: [{}], data before:[{}], data after: [{}]", rootNode.getModificationType(), dataBefore, dataAfter);
+            LOG.trace("BGP topology deployer configuration changed: modification type: [{}]," +
+                    " data before:[{}], data after: [{}]", rootNode.getModificationType(), dataBefore, dataAfter);
             switch (rootNode.getModificationType()) {
-            case DELETE:
-                filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
-                break;
-            case SUBTREE_MODIFIED:
-                filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
-                filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter, null));
-                break;
-            case WRITE:
-                filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter, null));
-                break;
-            default:
-                break;
+                case DELETE:
+                    filterTopologyBuilders(dataBefore)
+                            .forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
+                    break;
+                case SUBTREE_MODIFIED:
+                    filterTopologyBuilders(dataBefore).forEach(provider
+                            -> provider.onTopologyBuilderRemoved(dataBefore));
+                    filterTopologyBuilders(dataAfter).forEach(provider
+                            -> provider.onTopologyBuilderCreated(dataAfter));
+                    break;
+                case WRITE:
+                    filterTopologyBuilders(dataAfter).forEach(provider
+                            -> provider.onTopologyBuilderCreated(dataAfter));
+                    break;
+                default:
+                    break;
             }
         }
     }
@@ -117,9 +124,13 @@ public final class BgpTopologyDeployerImpl implements AutoCloseable, ClusteredDa
     @Override
     public AbstractRegistration registerService(final TopologyReferenceSingletonService topologyProviderService) {
         final Dictionary<String, String> properties = new Hashtable<>();
-        properties.put("topology-id", topologyProviderService.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
-        final ServiceRegistration<?> registerService = this.context.registerService(new String[]{TopologyReference.class.getName()}, topologyProviderService, properties);
-        final ClusterSingletonServiceRegistration registerClusterSingletonService = registerSingletonService(topologyProviderService);
+        properties.put("topology-id", topologyProviderService.getInstanceIdentifier()
+                .firstKeyOf(Topology.class).getTopologyId().getValue());
+        final ServiceRegistration<?> registerService = this.context
+                .registerService(new String[]{TopologyReference.class.getName()},
+                        topologyProviderService, properties);
+        final ClusterSingletonServiceRegistration registerClusterSingletonService =
+                registerSingletonService(topologyProviderService);
         return new AbstractRegistration() {
             @Override
             protected void removeRegistration() {
@@ -127,53 +138,33 @@ public final class BgpTopologyDeployerImpl implements AutoCloseable, ClusteredDa
                     registerClusterSingletonService.close();
                 } catch (final Exception e) {
                     LOG.warn("Failed to close ClusterSingletonServiceRegistration {} for TopologyBuilder {}",
-                        registerClusterSingletonService, topologyProviderService.getInstanceIdentifier(), e);
+                            registerClusterSingletonService, topologyProviderService.getInstanceIdentifier(), e);
                 }
                 registerService.unregister();
             }
         };
     }
 
-    @Override
-    public void createInstance(final Topology topology) {
-        final Function<Topology, Void> writeFunction = topology1 -> {
-            final WriteTransaction wTx = this.dataBroker.newWriteOnlyTransaction();
-            final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIIdKeyed =
-                InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, topology1.getKey());
-            wTx.put(LogicalDatastoreType.CONFIGURATION, topologyIIdKeyed, topology1, true);
-            wTx.submit();
-            return null;
-        };
-
-        filterTopologyBuilders(topology).forEach(provider -> provider.onTopologyBuilderCreated(topology, writeFunction));
-    }
-
-    @Override
-    public void removeInstance(final Topology topology) {
-        filterTopologyBuilders(topology).forEach(provider -> provider.onTopologyBuilderRemoved(topology));
-    }
-
-    @Override
-    public InstanceIdentifier<Topology> getInstanceIdentifier() {
-        return TOPOLOGY_IID;
-    }
-
     @Override
     public synchronized void close() {
-        this.registration.close();
+        if (this.registration != null) {
+            this.registration.close();
+            this.registration = null;
+        }
+
         LOG.info("BGP topology deployer stopped.");
         this.closed = true;
     }
 
     private Iterable<BgpTopologyProvider> filterTopologyBuilders(final Topology topology) {
         return this.topologyProviders.stream().filter(input -> input.topologyTypeFilter(topology))
-            .collect(Collectors.toList());
+                .collect(Collectors.toList());
     }
 
     private ClusterSingletonServiceRegistration registerSingletonService(
-        final ClusterSingletonService clusterSingletonService) {
+            final ClusterSingletonService clusterSingletonService) {
         return ClusterSingletonServiceRegistrationHelper
-            .registerSingletonService(this.singletonProvider, clusterSingletonService);
+                .registerSingletonService(this.singletonProvider, clusterSingletonService);
     }
 
 }
index f1a535a4c54f0392139472daa0953c96752b5afb..633e38e32385023a3bfa65e79f621de7177b1b12 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.bgpcep.bgp.topology.provider.config;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.function.Function;
 import org.opendaylight.bgpcep.bgp.topology.provider.AbstractTopologyBuilder;
 import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
 import org.opendaylight.bgpcep.bgp.topology.provider.spi.TopologyReferenceSingletonService;
@@ -27,11 +26,9 @@ final class TopologyReferenceSingletonServiceImpl implements TopologyReferenceSi
     private final AbstractTopologyBuilder<?> topologyBuilder;
     private final AbstractRegistration serviceRegistration;
     private final Topology configuration;
-    private final Function<Topology, Void> writeFunction;
 
     TopologyReferenceSingletonServiceImpl(final AbstractTopologyBuilder<?> topologyBuilder, final BgpTopologyDeployer deployer,
-            final Topology configuration, final Function<Topology, Void> writeFunction) {
-        this.writeFunction = writeFunction;
+            final Topology configuration) {
         this.configuration = requireNonNull(configuration);
         this.topologyBuilder = requireNonNull(topologyBuilder);
         this.serviceRegistration = deployer.registerService(this);
@@ -51,9 +48,6 @@ final class TopologyReferenceSingletonServiceImpl implements TopologyReferenceSi
     public void instantiateServiceInstance() {
         LOG.info("Topology Singleton Service {} instantiated", getIdentifier());
         this.topologyBuilder.start();
-        if (this.writeFunction != null) {
-            this.writeFunction.apply(this.configuration);
-        }
     }
 
     @Override
index 7605ff1732b6229ffe261fd2e25c1668efa4eac9..89027fe805acdfdace2ec3181f3df3c235f572f1 100644 (file)
@@ -8,11 +8,13 @@
 
 package org.opendaylight.bgpcep.bgp.topology.provider.spi;
 
+import com.google.common.annotations.Beta;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+@Beta
 public interface BgpTopologyDeployer {
 
     AbstractRegistration registerTopologyProvider(BgpTopologyProvider topologyBuilder);
@@ -20,10 +22,4 @@ public interface BgpTopologyDeployer {
     DataBroker getDataBroker();
 
     AbstractRegistration registerService(TopologyReferenceSingletonService topologyProviderService);
-
-    void createInstance(Topology topology);
-
-    void removeInstance(Topology topology);
-
-    InstanceIdentifier<Topology> getInstanceIdentifier();
 }
index b7ed01a5f636892770b93312f79c28496d552c28..529298356861952adcf4e8d6595550f34a9c4988 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.bgpcep.bgp.topology.provider.spi;
 
-import java.util.function.Function;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 
 
@@ -18,6 +17,6 @@ public interface BgpTopologyProvider {
 
     void onTopologyBuilderRemoved(Topology topology);
 
-    void onTopologyBuilderCreated(Topology topology, Function<Topology, Void> writeFunction);
+    void onTopologyBuilderCreated(Topology topology);
 
 }
index 55ff1dc903ca55d3fbb410a55428bacd476021ec..75fc0987217fd9b8b8c92ded3d33c7d52be5313b 100644 (file)
@@ -5,7 +5,9 @@
   <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
   <reference id="clusterSingletonServiceProvider" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
 
-  <bean id="bgpTopologyDeployer" class="org.opendaylight.bgpcep.bgp.topology.provider.config.BgpTopologyDeployerImpl" destroy-method="close">
+  <bean id="bgpTopologyDeployer" class="org.opendaylight.bgpcep.bgp.topology.provider.config.BgpTopologyDeployerImpl"
+        init-method="init"
+        destroy-method="close">
     <argument ref="blueprintBundleContext"/>
     <argument ref="dataBroker"/>
     <argument ref="clusterSingletonServiceProvider"/>
index 5744621d7d8a2b98e4e59ed9204d297f7b5d95c6..34cf9e315270dfbaa960ce17e78d2ce6735d3336 100644 (file)
@@ -138,6 +138,7 @@ public class BmpDeployerImpl implements ClusteredDataTreeChangeListener<OdlBmpMo
     public synchronized void close() {
         if (this.registration != null) {
             this.registration.close();
+            this.registration = null;
         }
     }
 }