*/
package org.opendaylight.bgpcep.pcep.topology.provider;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
private final InstanceIdentifier<Topology> topology;
private final DataBroker broker;
private final PCEPStatefulPeerProposal peerProposal;
- private final AtomicBoolean isClosed = new AtomicBoolean(false);
private final short rpcTimeout;
private final AtomicReference<PCEPTopologyProviderRuntimeRegistration> runtimeRootRegistration = new AtomicReference<>();
+ @VisibleForTesting
+ public final AtomicBoolean isClosed = new AtomicBoolean(false);
+
public ServerSessionManager(final DataBroker broker, final InstanceIdentifier<Topology> topology,
final TopologySessionListenerFactory listenerFactory, final short rpcTimeout) {
this.broker = Preconditions.checkNotNull(broker);
@Override
public void onSuccess(final Void result) {
LOG.debug("PCEP Topology {} created successfully.", topologyId.getValue());
+ ServerSessionManager.this.isClosed.set(false);
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Failed to create PCEP Topology {}.", topologyId.getValue(), t);
+ ServerSessionManager.this.isClosed.set(true);
}
}, MoreExecutors.directExecutor());
return future;
}
synchronized void releaseNodeState(final TopologyNodeState nodeState, final PCEPSession session, final boolean persistNode) {
+ if (this.isClosed.get()) {
+ LOG.error("Session Manager has already been closed.");
+ return;
+ }
this.nodes.remove(createNodeId(session.getRemoteAddress()));
if (nodeState != null) {
LOG.debug("Node {} unbound", nodeState.getNodeId());