*/
package org.opendaylight.mdsal.replicate.netty;
+import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Verify.verify;
import java.net.InetAddress;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.concepts.Registration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class NettyReplication {
+ private static final Logger LOG = LoggerFactory.getLogger(NettyReplication.class);
+
private static final class Disabled extends AbstractRegistration {
@Override
protected void removeRegistration() {
public static Registration createSink(final BootstrapSupport bootstrapSupport, final DOMDataBroker dataBroker,
final ClusterSingletonServiceProvider singletonService, final boolean enabled,
- final InetAddress sourceAddress, final int sourcePort, final Duration reconnectDelay) {
+ final InetAddress sourceAddress, final int sourcePort, final Duration reconnectDelay,
+ final Duration keepaliveInterval, final int maxMissedKeepalives) {
+ LOG.debug("Sink {}", enabled ? "enabled" : "disabled");
+ checkArgument(maxMissedKeepalives > 0, "max-missed-keepalives %s must be greater than 0", maxMissedKeepalives);
return enabled ? singletonService.registerClusterSingletonService(new SinkSingletonService(bootstrapSupport,
- dataBroker, new InetSocketAddress(sourceAddress, sourcePort), reconnectDelay)) : new Disabled();
+ dataBroker, new InetSocketAddress(sourceAddress, sourcePort), reconnectDelay, keepaliveInterval,
+ maxMissedKeepalives)) : new Disabled();
}
public static Registration createSource(final BootstrapSupport bootstrapSupport, final DOMDataBroker dataBroker,
- final ClusterSingletonServiceProvider singletonService, final boolean enabled, final int listenPort) {
+ final ClusterSingletonServiceProvider singletonService, final boolean enabled, final int listenPort,
+ final Duration keepaliveInterval, final int maxMissedKeepalives) {
+ LOG.debug("Source {}", enabled ? "enabled" : "disabled");
final DOMDataTreeChangeService dtcs = dataBroker.getExtensions().getInstance(DOMDataTreeChangeService.class);
verify(dtcs != null, "Missing DOMDataTreeChangeService in broker %s", dataBroker);
-
+ checkArgument(maxMissedKeepalives > 0, "max-missed-keepalives %s must be greater than 0", maxMissedKeepalives);
return enabled ? singletonService.registerClusterSingletonService(new SourceSingletonService(bootstrapSupport,
- dtcs, listenPort)) : new Disabled();
+ dtcs, listenPort, keepaliveInterval, maxMissedKeepalives)) : new Disabled();
}
}