ServiceGroupIdentifier should be a record
[mdsal.git] / replicate / mdsal-replicate-netty / src / main / java / org / opendaylight / mdsal / replicate / netty / SinkSingletonService.java
index 98e154e3d8f7a6f58983474d4552c7316c09f3d0..975d75f6bf4163c14e57455ef5efd3b69621d0b9 100644 (file)
@@ -42,11 +42,10 @@ import org.slf4j.LoggerFactory;
 
 final class SinkSingletonService extends ChannelInitializer<SocketChannel> implements ClusterSingletonService {
     private static final Logger LOG = LoggerFactory.getLogger(SinkSingletonService.class);
-    private static final ServiceGroupIdentifier SGID =
-            ServiceGroupIdentifier.create(SinkSingletonService.class.getName());
+    private static final ServiceGroupIdentifier SGID = new ServiceGroupIdentifier(SinkSingletonService.class.getName());
     // TODO: allow different trees?
     private static final DOMDataTreeIdentifier TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
-        YangInstanceIdentifier.empty());
+        YangInstanceIdentifier.of());
     private static long CHANNEL_CLOSE_TIMEOUT_S = 10;
     private static final ByteBuf TREE_REQUEST;
 
@@ -90,7 +89,7 @@ final class SinkSingletonService extends ChannelInitializer<SocketChannel> imple
     @Override
     public synchronized void instantiateServiceInstance() {
         LOG.info("Replication sink started with source {}", sourceAddress);
-        this.bs = bootstrapSupport.newBootstrap();
+        bs = bootstrapSupport.newBootstrap();
         doConnect();
     }
 
@@ -170,14 +169,10 @@ final class SinkSingletonService extends ChannelInitializer<SocketChannel> imple
     }
 
     private synchronized void channelClosed(final ChannelFuture completedFuture, final ScheduledExecutorService group) {
-        if (futureChannel != null && futureChannel.channel() == completedFuture.channel()) {
-            if (!closingInstance) {
-                LOG.info("Channel {} lost connection to source {}, reconnecting in {}", completedFuture.channel(),
-                    sourceAddress, reconnectDelay.getSeconds());
-                group.schedule(() -> {
-                    reconnect();
-                }, reconnectDelay.toNanos(), TimeUnit.NANOSECONDS);
-            }
+        if (futureChannel != null && futureChannel.channel() == completedFuture.channel() && !closingInstance) {
+            LOG.info("Channel {} lost connection to source {}, reconnecting in {}", completedFuture.channel(),
+                sourceAddress, reconnectDelay.getSeconds());
+            group.schedule(this::reconnect, reconnectDelay.toNanos(), TimeUnit.NANOSECONDS);
         }
     }