}
@Override
- public final ServerBootstrap newServerBootstrap() {
+ public final ServerBootstrap newServerBootstrap() {
return new ServerBootstrap().group(bossGroup, workerGroup).channel(serverChannelClass);
}
import java.time.Duration;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
@Reference
private ClusterSingletonServiceProvider singletonService;
- private static final class Disabled extends AbstractRegistration {
- @Override
- protected void removeRegistration() {
- // no-op
- }
- }
-
- private NettyReplicationSink() {
+ private Registration reg;
+ public NettyReplicationSink() {
+ // Visible for DI
}
@Activate
final Duration reconnectDelay = Duration.ofMillis(config.reconnectDelayMillis());
final Duration keepaliveInterval = Duration.ofSeconds(config.keepAliveIntervalSeconds());
- createSink(bootstrapSupport, dataBroker, singletonService, config.enabled(), sourceAddress,
+ reg = createSink(bootstrapSupport, dataBroker, singletonService, config.enabled(), sourceAddress,
config.sourcePort(), reconnectDelay, keepaliveInterval, config.maxMissedKeepalives());
}
+ @Deactivate
+ void deactivate() {
+ reg.close();
+ reg = null;
+ }
+
static Registration createSink(final BootstrapSupport bootstrap, final DOMDataBroker broker,
final ClusterSingletonServiceProvider singleton, final boolean enabled,
final InetAddress sourceAddress, final int sourcePort, final Duration reconnectDelay,
checkArgument(maxMissedKeepalives > 0, "max-missed-keepalives %s must be greater than 0", maxMissedKeepalives);
return enabled ? singleton.registerClusterSingletonService(new SinkSingletonService(bootstrap,
broker, new InetSocketAddress(sourceAddress, sourcePort), reconnectDelay, keepaliveInterval,
- maxMissedKeepalives)) : new Disabled();
+ maxMissedKeepalives)) : new NoOpRegistration();
}
}
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
@Reference
private ClusterSingletonServiceProvider singletonService;
- private static final class Disabled extends AbstractRegistration {
- @Override
- protected void removeRegistration() {
- // no-op
- }
- }
-
- private NettyReplicationSource() {
+ private Registration reg;
+ public NettyReplicationSource() {
+ // Visible for DI
}
@Activate
keepaliveInterval, config.maxMissedKeepalives());
}
+ @Deactivate
+ void deactivate() {
+ reg.close();
+ reg = null;
+ }
+
static Registration createSource(final BootstrapSupport bootstrap, final DOMDataBroker broker,
final ClusterSingletonServiceProvider singleton, final boolean enabled,
final int listenPort, final Duration keepaliveInterval,
verify(dtcs != null, "Missing DOMDataTreeChangeService in broker %s", broker);
checkArgument(maxMissedKeepalives > 0, "max-missed-keepalives %s must be greater than 0", maxMissedKeepalives);
return enabled ? singleton.registerClusterSingletonService(new SourceSingletonService(bootstrap,
- dtcs, listenPort, keepaliveInterval, maxMissedKeepalives)) : new Disabled();
+ dtcs, listenPort, keepaliveInterval, maxMissedKeepalives)) : new NoOpRegistration();
}
}
--- /dev/null
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.mdsal.replicate.netty;
+
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+
+final class NoOpRegistration extends AbstractRegistration {
+ @Override
+ protected void removeRegistration() {
+ // no-op
+ }
+}
\ No newline at end of file
@Component(immediate = true, service = BootstrapSupport.class)
public class OSGiBootstrapSupportProvider implements BootstrapSupport {
-
private AbstractBootstrapSupport delegate = null;
@Activate
}
@Deactivate
- void deactivate() {
+ void deactivate() throws InterruptedException {
+ delegate.close();
delegate = null;
}