Search in sources :

Example 1 with SessionStateImpl

use of org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method onSessionUp.

@Override
public final void onSessionUp(final PCEPSession psession) {
    synchronized (this.serverSessionManager) {
        synchronized (this) {
            /*
                 * The session went up. Look up the router in Inventory model, create it if it
                 * is not there (marking that fact for later deletion), and mark it as
                 * synchronizing. Also create it in the topology model, with empty LSP list.
                 */
            final InetAddress peerAddress = psession.getRemoteAddress();
            this.syncOptimization = new SyncOptimization(psession);
            final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
            // due to configuration change
            if (state == null) {
                LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", psession);
                psession.close(TerminationReason.UNKNOWN);
                this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
                return;
            }
            if (this.session != null || this.nodeState != null) {
                LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(), psession);
                psession.close(TerminationReason.UNKNOWN);
                this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
                return;
            }
            this.session = psession;
            this.nodeState = state;
            LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
            // Our augmentation in the topology node
            final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
            onSessionUp(psession, pccBuilder);
            this.synced.set(isSynchronized());
            pccBuilder.setIpAddress(IetfInetUtil.INSTANCE.ipAddressNoZoneFor(peerAddress));
            final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
            this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
            final Node initialNodeState = state.getInitialNodeState();
            final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
            if (isNodePresent) {
                loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
                pccBuilder.setReportedLsp(initialNodeState.augmentation(Node1.class).getPathComputationClient().getReportedLsp());
            }
            state.storeNode(topologyAugment, new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
            this.listenerState = new SessionStateImpl(this, psession);
            this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
            LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
        }
    }
}
Also used : PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1Builder) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClient) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder) SessionStateImpl(org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl) InetAddress(java.net.InetAddress)

Aggregations

InetAddress (java.net.InetAddress)1 SessionStateImpl (org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl)1 PCEPCloseTermination (org.opendaylight.protocol.pcep.PCEPCloseTermination)1 Node1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1)1 Node1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1Builder)1 PathComputationClient (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClient)1 PathComputationClientBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder)1 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)1