Search in sources :

Example 11 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.

the class StateSynchronizationAvoidanceProcedureTest method testStateSynchronizationPerformed.

@Test
public void testStateSynchronizationPerformed() throws Exception {
    PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
    this.listener.onSessionUp(session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1L)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(1L)).build()).setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName("test".getBytes())).build()).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.absent(), createPath(Collections.emptyList()));
    this.listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onSessionDown(session, new IllegalArgumentException("Simulate Exception"));
    this.listener = (Stateful07TopologySessionListener) getSessionListener();
    // session up - expect sync (LSP-DBs do not match)
    final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
    session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
    this.listener.onSessionUp(session);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - not synchronized
        assertEquals(PccSyncState.InitialResync, pcc.getStateSync());
        // check reported LSP - persisted from previous session
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build()).build()).build()), true, false), Optional.absent(), createPath(Collections.emptyList()));
    this.listener.onMessage(session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is empty, LSP state from previous session was purged
        assertTrue(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder) Collections(java.util.Collections) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) Test(org.junit.Test)

Example 12 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.

the class StateSynchronizationAvoidanceProcedureTest method testNodePersisted.

@Test
public void testNodePersisted() throws ReadFailedException {
    final PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
    this.listener.onSessionUp(session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(1L)), null);
    this.listener.onMessage(session, pcRpt);
    // check topology
    readDataOperational(getDataBroker(), this.pathComputationClientIId.builder().augmentation(PathComputationClient1.class).child(LspDbVersion.class).build(), dbVersion -> {
        assertEquals(1L, dbVersion.getLspDbVersionValue().longValue());
        return dbVersion;
    });
    // drop session
    this.listener.onSessionDown(session, new IllegalStateException());
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertFalse(topology.getNode().isEmpty());
        return topology;
    });
// check topology - node is persisted
}
Also used : Collections(java.util.Collections) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PathComputationClient1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.PathComputationClient1) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) Test(org.junit.Test)

Example 13 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method updateLsp.

/**
 * Update an LSP in the data store.
 *
 * @param ctx       Message context
 * @param id        Revision-specific LSP identifier
 * @param lspName   LSP name
 * @param rlb       Reported LSP builder
 * @param solicited True if the update was solicited
 * @param remove    True if this is an LSP path removal
 */
protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName, final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
    final String name;
    if (lspName == null) {
        name = this.lsps.get(id);
        if (name == null) {
            LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
            return;
        }
    } else {
        name = lspName;
    }
    LOG.debug("Saved LSP {} with name {}", id, name);
    this.lsps.put(id, name);
    final ReportedLsp previous = this.lspData.get(name);
    // if no previous report about the lsp exist, just proceed
    if (previous != null) {
        final List<Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
        // if all paths or the last path were deleted, delete whole tunnel
        if (updatedPaths.isEmpty()) {
            LOG.debug("All paths were removed, removing LSP with {}.", id);
            removeLsp(ctx, id);
            return;
        }
        rlb.setPath(updatedPaths);
    }
    rlb.setKey(new ReportedLspKey(name));
    rlb.setName(name);
    // If this is an unsolicited update. We need to make sure we retain the metadata already present
    if (solicited) {
        this.nodeState.setLspMetadata(name, rlb.getMetadata());
    } else {
        rlb.setMetadata(this.nodeState.getLspMetadata(name));
    }
    final ReportedLsp rl = rlb.build();
    ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.getKey()), rl);
    LOG.debug("LSP {} updated to MD-SAL", name);
    this.lspData.put(name, rl);
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspKey)

Example 14 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method makeBeforeBreak.

private List<Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
    // just one path should be reported
    Preconditions.checkState(rlb.getPath().size() == 1);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = rlb.getPath().get(0).getLspId();
    final List<Path> updatedPaths;
    // remove existing tunnel's paths now, as explicit path remove will not come
    if (!remove && reportedLspId.getValue() == 0) {
        updatedPaths = new ArrayList<>();
        LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
    } else {
        // check previous report for existing paths
        updatedPaths = new ArrayList<>(previous.getPath());
        LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
        for (final Path path : previous.getPath()) {
            // we found reported path in previous reports
            if (path.getLspId().getValue() == 0 || path.getLspId().equals(reportedLspId)) {
                LOG.debug("Match on lsp-id {}", path.getLspId().getValue());
                // path that was reported previously and does have the same lsp-id, path will be updated
                final boolean r = updatedPaths.remove(path);
                LOG.trace("Request removed? {}", r);
            }
        }
    }
    // if the path does not exist in previous report, add it to path list, it's a new ERO
    // only one path will be added
    // lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
    LOG.trace("Adding new path {} to {}", rlb.getPath(), updatedPaths);
    updatedPaths.addAll(rlb.getPath());
    if (remove) {
        if (reportedLspId.getValue() == 0) {
            // if lsp-id also 0, remove all paths
            LOG.debug("Removing all paths.");
            updatedPaths.clear();
        } else {
            // path is marked to be removed
            LOG.debug("Removing path {} from {}", rlb.getPath(), updatedPaths);
            final boolean r = updatedPaths.removeAll(rlb.getPath());
            LOG.trace("Request removed? {}", r);
        }
    }
    LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
    return updatedPaths;
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path)

Example 15 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method onSessionUp.

@Override
public final synchronized void onSessionUp(final PCEPSession psession) {
    /*
         * 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());
    // 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 {}", 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;
    this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
    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(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
    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.getAugmentation(Node1.class).getPathComputationClient().getReportedLsp());
    }
    state.storeNode(topologyAugment, new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
    this.listenerState.init(psession);
    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.rev171025.Node1) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1Builder) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.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.rev171025.pcep.client.attributes.PathComputationClientBuilder) InetAddress(java.net.InetAddress)

Aggregations

PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)20 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)18 Test (org.junit.Test)14 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)14 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)12 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)11 ByteBuf (io.netty.buffer.ByteBuf)8 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder)8 SrpIdNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SrpIdNumber)7 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder)7 UpdatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.UpdatesBuilder)6 Srp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp)6 Collections (java.util.Collections)5 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)5 LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion)5 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)5 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)5 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)4 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder)4 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)4