Remove deprecated methods under BMP API 62/65262/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 7 Nov 2017 10:31:58 +0000 (11:31 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Tue, 7 Nov 2017 15:07:51 +0000 (16:07 +0100)
Change-Id: I6ffe7f210331f08539a260cb0871be77b7f1ec8a
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitoringStationImpl.java
bmp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/session/BmpDispatcherImplTest.java
bmp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/api/BmpDispatcher.java

index b5a6329387c5a86d49fc0b1da64a9d0a27d639a4..f67f1408f841c3031e6966deceaa155b005477b6 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.protocol.bmp.impl.app;
 import static java.util.Objects.requireNonNull;
 import static org.opendaylight.protocol.bmp.impl.app.KeyConstructorUtil.constructKeys;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.net.InetAddresses;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -22,13 +21,13 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.List;
 import javax.annotation.Nonnull;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.protocol.bmp.api.BmpDispatcher;
 import org.opendaylight.protocol.bmp.impl.config.BmpDeployerDependencies;
 import org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation;
@@ -52,7 +51,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
 
     private static final QName MONITOR_ID_QNAME = QName.create(Monitor.QNAME, "monitor-id").intern();
     private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
-        ServiceGroupIdentifier.create("bmp-monitors-service-group");
+            ServiceGroupIdentifier.create("bmp-monitors-service-group");
 
     private final DOMDataBroker domDataBroker;
     private final InetSocketAddress address;
@@ -65,8 +64,8 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
     private ClusterSingletonServiceRegistration singletonServiceRegistration;
 
     public BmpMonitoringStationImpl(final BmpDeployerDependencies bmpDeployerDependencies,
-        final BmpDispatcher dispatcher, final MonitorId monitorId, final InetSocketAddress address,
-        final List<MonitoredRouter> mrs) {
+            final BmpDispatcher dispatcher, final MonitorId monitorId, final InetSocketAddress address,
+            final List<MonitoredRouter> mrs) {
         this.domDataBroker = requireNonNull(bmpDeployerDependencies.getDomDataBroker());
         this.dispatcher = requireNonNull(dispatcher);
         this.monitorId = monitorId;
@@ -74,25 +73,25 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
         this.address = requireNonNull(address);
 
         this.yangMonitorId = YangInstanceIdentifier.builder()
-            .node(BmpMonitor.QNAME).node(Monitor.QNAME)
-            .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, monitorId.getValue()).build();
+                .node(BmpMonitor.QNAME).node(Monitor.QNAME)
+                .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, monitorId.getValue()).build();
 
         this.sessionManager = new RouterSessionManager(this.yangMonitorId, this.domDataBroker,
-            bmpDeployerDependencies.getExtensions(), bmpDeployerDependencies.getTree());
+                bmpDeployerDependencies.getExtensions(), bmpDeployerDependencies.getTree());
 
         LOG.info("BMP Monitor Singleton Service {} registered, Monitor Id {}",
-            getIdentifier().getValue(), this.monitorId.getValue());
+                getIdentifier().getValue(), this.monitorId.getValue());
         this.singletonServiceRegistration = bmpDeployerDependencies.getClusterSingletonProvider()
-            .registerClusterSingletonService(this);
+                .registerClusterSingletonService(this);
     }
 
     @Override
     public synchronized void instantiateServiceInstance() {
         LOG.info("BMP Monitor Singleton Service {} instantiated, Monitor Id {}",
-            getIdentifier().getValue(), this.monitorId.getValue());
+                getIdentifier().getValue(), this.monitorId.getValue());
 
         final ChannelFuture channelFuture = this.dispatcher.createServer(this.address, this.sessionManager,
-            constructKeys(this.monitoredRouters));
+                constructKeys(this.monitoredRouters));
         try {
             this.channel = channelFuture.sync().channel();
             createEmptyMonitor();
@@ -109,7 +108,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
     @Override
     public synchronized ListenableFuture<Void> closeServiceInstance() {
         LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}",
-            getIdentifier().getValue(), this.monitorId.getValue());
+                getIdentifier().getValue(), this.monitorId.getValue());
         this.channel.close().addListener((ChannelFutureListener) future -> {
             Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause());
             BmpMonitoringStationImpl.this.sessionManager.close();
@@ -139,7 +138,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
                     final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
                     ret = KeyMapping.getKeyMapping(addr, rfc2385KeyPassword.getValue());
                     dispatcher.createClient(Ipv4Util.toInetSocketAddress(mr.getAddress(), mr.getPort()),
-                        this.sessionManager, Optional.fromNullable(ret));
+                            this.sessionManager, ret);
                 }
             }
         }
@@ -148,12 +147,12 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation, Clu
     private synchronized void createEmptyMonitor() {
         final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
         wTx.put(LogicalDatastoreType.OPERATIONAL,
-            YangInstanceIdentifier.builder().node(BmpMonitor.QNAME).node(Monitor.QNAME)
-                .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue()).build(),
-            ImmutableNodes.mapEntryBuilder(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue())
-                .addChild(ImmutableNodes.leafNode(MONITOR_ID_QNAME, this.monitorId.getValue()))
-                .addChild(ImmutableNodes.mapNodeBuilder(Router.QNAME).build())
-                .build());
+                YangInstanceIdentifier.builder().node(BmpMonitor.QNAME).node(Monitor.QNAME)
+                        .nodeWithKey(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue()).build(),
+                ImmutableNodes.mapEntryBuilder(Monitor.QNAME, MONITOR_ID_QNAME, this.monitorId.getValue())
+                        .addChild(ImmutableNodes.leafNode(MONITOR_ID_QNAME, this.monitorId.getValue()))
+                        .addChild(ImmutableNodes.mapNodeBuilder(Router.QNAME).build())
+                        .build());
         try {
             wTx.submit().checkedGet();
         } catch (final TransactionCommitFailedException e) {
index d48310e4682ba86488e7ebf1d28c7c1ea57ae69d..727d30067c89bc69ed6729c70ca0b741f3b0dd23 100644 (file)
@@ -16,7 +16,6 @@ import static org.mockito.Mockito.verify;
 import static org.opendaylight.protocol.util.CheckUtil.checkEquals;
 import static org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess;
 
-import com.google.common.base.Optional;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandlerContext;
@@ -37,6 +36,7 @@ import org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl;
 import org.opendaylight.protocol.bmp.parser.BmpActivator;
 import org.opendaylight.protocol.bmp.spi.registry.BmpMessageRegistry;
 import org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext;
+import org.opendaylight.protocol.concepts.KeyMapping;
 
 public class BmpDispatcherImplTest {
 
@@ -73,7 +73,7 @@ public class BmpDispatcherImplTest {
         final BmpMessageRegistry messageRegistry = ctx.getBmpMessageRegistry();
 
         this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(),
-            messageRegistry, (channel, sessionListenerFactory) -> BmpDispatcherImplTest.this.mockedSession);
+                messageRegistry, (channel, sessionListenerFactory) -> BmpDispatcherImplTest.this.mockedSession);
     }
 
     @After
@@ -86,18 +86,18 @@ public class BmpDispatcherImplTest {
     @Test
     public void testCreateServer() throws Exception {
         final ChannelFuture futureServer = this.dispatcher.createServer(SERVER,
-            this.mockedListenerFactory, Optional.absent());
+                this.mockedListenerFactory, KeyMapping.getKeyMapping());
         waitFutureSuccess(futureServer);
         final Channel serverChannel = futureServer.channel();
-        checkEquals(()-> assertTrue(serverChannel.isActive()));
+        checkEquals(() -> assertTrue(serverChannel.isActive()));
 
 
         final ChannelFuture futureClient = this.dispatcher.createClient(CLIENT_REMOTE,
-            this.mockedListenerFactory, Optional.absent());
+                this.mockedListenerFactory, KeyMapping.getKeyMapping());
         waitFutureSuccess(futureClient);
 
         final Channel clientChannel = futureClient.channel();
-        checkEquals(()-> assertTrue(clientChannel.isActive()));
+        checkEquals(() -> assertTrue(clientChannel.isActive()));
         verify(this.mockedSession, timeout(500).times(2)).handlerAdded(any(ChannelHandlerContext.class));
         verify(this.mockedSession, timeout(500).times(2)).channelRegistered(any(ChannelHandlerContext.class));
         verify(this.mockedSession, timeout(500).times(2)).channelActive(any(ChannelHandlerContext.class));
index fe004daea9090b60066d3eca3b6121fbcc770703..833967eae890fdf24c2a2fe0524caed6e0c51f38 100644 (file)
@@ -8,48 +8,15 @@
 
 package org.opendaylight.protocol.bmp.api;
 
-import com.google.common.base.Optional;
 import io.netty.channel.ChannelFuture;
 import java.net.InetSocketAddress;
+import javax.annotation.Nonnull;
 import org.opendaylight.protocol.concepts.KeyMapping;
 
 /**
  * Dispatcher class for creating servers and clients.
  */
 public interface BmpDispatcher extends AutoCloseable {
-
-    /**
-     * Creates server. Each server needs three factories to pass their instances to client sessions.
-     *
-     * @param address to be bound with the server
-     * @param slf     bmp session listener factory
-     * @param keys    RFC2385 key mapping
-     * @return instance of BmpServer
-     */
-    @Deprecated
-    default ChannelFuture createServer(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys) {
-        if(keys.isPresent()) {
-            return createServer(address, slf, keys.get());
-        }
-        return createServer(address, slf, KeyMapping.getKeyMapping());
-    }
-
-     /**
-     * Creates reconnect clients. Make connection to all active monitored-routers.
-     *
-     * @param address bmp client to connect to
-     * @param slf     bmp session listener factory
-     * @param keys    RFC2385 key mapping
-     * @return        void
-     */
-     @Deprecated
-     default ChannelFuture createClient(InetSocketAddress address, BmpSessionListenerFactory slf, Optional<KeyMapping> keys) {
-         if(keys.isPresent()) {
-             return createClient(address, slf, keys.get());
-         }
-         return createClient(address, slf, KeyMapping.getKeyMapping());
-     }
-
     /**
      * Creates server. Each server needs three factories to pass their instances to client sessions.
      *
@@ -58,7 +25,8 @@ public interface BmpDispatcher extends AutoCloseable {
      * @param keys    RFC2385 key mapping
      * @return instance of BmpServer
      */
-    ChannelFuture createServer(InetSocketAddress address, BmpSessionListenerFactory slf, KeyMapping keys);
+    ChannelFuture createServer(@Nonnull InetSocketAddress address, @Nonnull BmpSessionListenerFactory slf,
+            @Nonnull KeyMapping keys);
 
     /**
      * Creates reconnect clients. Make connection to all active monitored-routers.
@@ -66,7 +34,8 @@ public interface BmpDispatcher extends AutoCloseable {
      * @param address bmp client to connect to
      * @param slf     bmp session listener factory
      * @param keys    RFC2385 key mapping
-     * @return        void
+     * @return void
      */
-    ChannelFuture createClient(InetSocketAddress address, BmpSessionListenerFactory slf, KeyMapping keys) ;
+    ChannelFuture createClient(@Nonnull InetSocketAddress address, @Nonnull BmpSessionListenerFactory slf,
+            @Nonnull KeyMapping keys);
 }