import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.controller.config.yang.pcep.topology.provider.ListenerStateRuntimeMXBean;
import org.opendaylight.controller.config.yang.pcep.topology.provider.ListenerStateRuntimeRegistration;
+import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderRuntimeRegistration;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PeerCapabilities;
import org.opendaylight.controller.config.yang.pcep.topology.provider.ReplyTime;
import org.opendaylight.controller.config.yang.pcep.topology.provider.SessionState;
private boolean triggeredResyncInProcess;
private ListenerStateRuntimeRegistration registration;
+ @GuardedBy("this")
private final SessionListenerState listenerState;
protected AbstractTopologySessionListener(final ServerSessionManager serverSessionManager) {
final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
// takeNodeState(..) may fail when the server session manager is being restarted due to configuration change
if (state == null) {
+ LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", session);
this.onSessionDown(session, new RuntimeException("Unable to fetch topology node state for PCEP session with " + session.getRemoteAddress()));
return;
}
if (this.session != null || this.nodeState != null) {
+ LOG.error("PCEP session is already up. Closing session {}", session);
this.onSessionDown(session, new IllegalStateException("Session is already up with " + session.getRemoteAddress()));
return;
}
pccBuilder.setReportedLsp(initialNodeState.getAugmentation(Node1.class).getPathComputationClient().getReportedLsp());
}
writeNode(pccBuilder, state, topologyAugment);
- this.listenerState.init(session);
- this.registration = this.serverSessionManager.registerRuntimeRootRegistration(this);
+ register();
if (this.registration == null) {
+ LOG.error("PCEP session fails to register. Closing session {}", session);
this.onSessionDown(session, new RuntimeException("PCEP Session with " + session.getRemoteAddress() + " fails to register."));
return;
}
+ this.listenerState.init(session);
LOG.info("Session with {} attached to topology node {}", session.getRemoteAddress(), state.getNodeId());
}
@Override
public final synchronized void onMessage(final PCEPSession session, final Message message) {
+ if (this.nodeState == null) {
+ LOG.warn("Topology node state is null. Unhandled message {} on session {}", message, session);
+ return;
+ }
final MessageContext ctx = new MessageContext(this.nodeState.beginTransaction());
if (onMessage(ctx, message)) {
- LOG.info("Unhandled message {} on session {}", message, session);
+ LOG.warn("Unhandled message {} on session {}", message, session);
//cancel not supported, submit empty transaction
ctx.trans.submit();
return;
}
}
- private synchronized void unregister() {
+ private final synchronized void unregister() {
if (this.registration != null) {
this.registration.close();
- LOG.trace("PCEP session {} unregistered successfully.", this.session);
+ LOG.trace("PCEP session {} is unregistered successfully.", this.session);
this.registration = null;
} else {
LOG.trace("PCEP session {} was not registered.", this.session);
}
}
+ private final synchronized void register() {
+ Preconditions.checkState(this.registration == null);
+ final PCEPTopologyProviderRuntimeRegistration runtimeReg = this.serverSessionManager.getRuntimeRootRegistration();
+ if (runtimeReg != null) {
+ this.registration = runtimeReg.register(this);
+ LOG.trace("PCEP session {} is successfully registered.", this.session);
+ }
+ }
+
protected final synchronized PCEPRequest removeRequest(final S id) {
final PCEPRequest ret = this.requests.remove(id);
if (ret != null) {
return false;
}
- protected SessionListenerState getSessionListenerState() {
+ protected synchronized SessionListenerState getSessionListenerState() {
return this.listenerState;
}
}
@Override
- public ReplyTime getReplyTime() {
+ public synchronized ReplyTime getReplyTime() {
return this.listenerState.getReplyTime();
}
@Override
- public PeerCapabilities getPeerCapabilities() {
+ public synchronized PeerCapabilities getPeerCapabilities() {
return this.listenerState.getPeerCapabilities();
}
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.ListenerStateRuntimeMXBean;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.ListenerStateRuntimeRegistration;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderRuntimeMXBean;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderRuntimeRegistration;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderRuntimeRegistrator;
}
}
- ListenerStateRuntimeRegistration registerRuntimeRootRegistration(final ListenerStateRuntimeMXBean bean) {
- final PCEPTopologyProviderRuntimeRegistration runtimeReg = this.runtimeRootRegistration.get();
- if (runtimeReg != null) {
- final ListenerStateRuntimeRegistration reg = runtimeReg.register(bean);
- LOG.trace("Bean {} is successfully registered.", bean.getPeerId());
- return reg;
- }
- return null;
+ PCEPTopologyProviderRuntimeRegistration getRuntimeRootRegistration() {
+ return this.runtimeRootRegistration.get();
}
- @Override
public void setPeerSpecificProposal(final InetSocketAddress address, final TlvsBuilder openBuilder) {
Preconditions.checkNotNull(address);
this.peerProposal.setPeerProposal(createNodeId(address.getAddress()), openBuilder);