}
@Override
- public final void channelInactive(final ChannelHandlerContext ctx) {
+ public synchronized final void channelInactive(final ChannelHandlerContext ctx) {
LOG.debug("Channel {} inactive.", ctx.channel());
- this.endOfInput();
+ endOfInput();
try {
super.channelInactive(ctx);
}
@Override
- protected final void channelRead0(final ChannelHandlerContext ctx, final Message msg) {
+ protected synchronized final void channelRead0(final ChannelHandlerContext ctx, final Message msg) {
LOG.debug("Message was received: {}", msg);
- this.handleMessage(msg);
+ handleMessage(msg);
}
@Override
- public final void handlerAdded(final ChannelHandlerContext ctx) {
+ public synchronized final void handlerAdded(final ChannelHandlerContext ctx) {
this.sessionUp();
}
@Override
- public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
+ public synchronized void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
handleException(cause);
}
Futures.addCallback(ctx.trans.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
- LOG.trace("Internal state for session {} updated successfully", psession);
- ctx.notifyRequests();
+ synchronized (AbstractTopologySessionListener.this) {
+ LOG.trace("Internal state for session {} updated successfully", psession);
+ ctx.notifyRequests();
+ }
}
@Override
public void onFailure(final Throwable throwable) {
- LOG.error("Failed to update internal state for session {}, closing it", psession, throwable);
- ctx.notifyRequests();
- psession.close(TerminationReason.UNKNOWN);
+ synchronized (AbstractTopologySessionListener.this) {
+ LOG.error("Failed to update internal state for session {}, closing it", psession, throwable);
+ ctx.notifyRequests();
+ psession.close(TerminationReason.UNKNOWN);
+ }
}
}, MoreExecutors.directExecutor());
}
LOG.error("Session Manager has already been closed.");
return Futures.immediateFuture(null);
}
- this.nodes.values().iterator().forEachRemaining(TopologySessionListener::close);
+ for (final TopologySessionListener node : this.nodes.values()) {
+ node.close();
+ }
this.nodes.clear();
- this.state.values().iterator().forEachRemaining(TopologyNodeState::close);
+ for (final TopologyNodeState topologyNodeState : this.state.values()) {
+ topologyNodeState.close();
+ }
this.state.clear();
final WriteTransaction t = this.dependenciesProvider.getDataBroker().newWriteOnlyTransaction();
package org.opendaylight.bgpcep.pcep.topology.provider.config;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProviderUtil.closeTopology;
import static org.opendaylight.bgpcep.pcep.topology.provider.config.PCEPTopologyProviderUtil.filterPcepTopologies;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyDeployerImpl.class);
+ private static final long TIMEOUT_NS = TimeUnit.SECONDS.toNanos(5);
private final BlueprintContainer container;
private final InstanceIdentifier<NetworkTopology> networTopology;
private final DataBroker dataBroker;
this.listenerRegistration.close();
this.listenerRegistration = null;
}
- this.pcepTopologyServices.entrySet().iterator()
- .forEachRemaining(entry -> closeTopology(entry.getValue(), entry.getKey()));
+ for (Map.Entry<TopologyId, PCEPTopologyProviderBean> entry:this.pcepTopologyServices.entrySet()) {
+ closeTopology(entry.getValue(), entry.getKey());
+ }
this.pcepTopologyServices.clear();
LOG.info("PCEP Topology Deployer closed");
}
+
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private synchronized void closeTopology(final PCEPTopologyProviderBean topology, final TopologyId topologyId) {
+ if (topology == null) {
+ return;
+ }
+ LOG.info("Removing Topology {}", topologyId);
+ try {
+ topology.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
+ topology.close();
+ } catch (final Exception e) {
+ LOG.error("Topology {} instance failed to close service instance", topologyId, e);
+ }
+ }
}
\ No newline at end of file
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
-import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepNodeConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TopologyTypes1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev171025.PcepNodeSyncConfig;
-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.topology.TopologyTypes;
import org.slf4j.Logger;
private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyProviderUtil.class);
- private static final long TIMEOUT_NS = TimeUnit.SECONDS.toNanos(5);
-
private PCEPTopologyProviderUtil() {
throw new UnsupportedOperationException();
}
return aug != null && aug.getTopologyPcep() != null;
}
- @SuppressWarnings("checkstyle:IllegalCatch")
- static void closeTopology(@Nullable final PCEPTopologyProviderBean topology, @Nonnull final TopologyId topologyId) {
- if (topology == null) {
- return;
- }
- LOG.info("Removing Topology {}", topologyId);
- try {
- topology.closeServiceInstance().get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
- topology.close();
- } catch (final Exception e) {
- LOG.error("Topology {} instance failed to close service instance", topologyId, e);
- }
- }
static SpeakerIdMapping contructSpeakersId(final Topology topology) {
final SpeakerIdMapping ret = SpeakerIdMapping.getSpeakerIdMap();
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
for (final KeyedInstanceIdentifier<Node, NodeKey> statId : this.statsMap.keySet()) {
wTx.delete(LogicalDatastoreType.OPERATIONAL, statId);
- wTx.submit().get();
}
+ wTx.submit().get();
this.statsMap.clear();
this.transactionChain.close();
}