Search in sources :

Example 6 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method removeLsp.

@Override
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH", justification = "SB does not grok TYPE_USE")
public synchronized ListenableFuture<OperationResult> removeLsp(final RemoveLspArgs input) {
    checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
    LOG.trace("RemoveLspArgs {}", input);
    // Make sure the LSP exists, we need it for PLSP-ID
    final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
    final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
    return f == null ? OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future() : Futures.transformAsync(f, rep -> {
        final Lsp reportedLsp = validateReportedLsp(rep, input);
        if (reportedLsp == null) {
            return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
        }
        final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
        final Requests rb = buildRequest(rep, reportedLsp);
        ib.setRequests(Collections.singletonList(rb));
        return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
    }, MoreExecutors.directExecutor());
}
Also used : SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType) Srps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcerr.pcerr.message.error.type.stateful._case.stateful.Srps) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) InetAddress(java.net.InetAddress) Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Stateful1) Arguments3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Arguments3) AddLspArgs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspArgs) Arguments2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Arguments2) Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1Builder) Map(java.util.Map) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports) Arguments1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Arguments1) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) StandardCharsets(java.nio.charset.StandardCharsets) PSTUtil(org.opendaylight.protocol.pcep.spi.PSTUtil) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber) RequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.request._case.RequestBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder) UpdateLspArgs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.UpdateLspArgs) GuardedBy(org.checkerframework.checker.lock.qual.GuardedBy) StatefulCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcerr.pcerr.message.error.type.StatefulCase) OperationResult(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.OperationResult) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion) NonNull(org.eclipse.jdt.annotation.NonNull) Pcreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq) PcreqMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) Lsp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Lsp1) ArrayList(java.util.ArrayList) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) 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) Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) TriggerSyncArgs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.TriggerSyncArgs) AtomicLong(java.util.concurrent.atomic.AtomicLong) PathComputationClient1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.PathComputationClient1Builder) Futures(com.google.common.util.concurrent.Futures) Holding(org.checkerframework.checker.lock.qual.Holding) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr) LoggerFactory(org.slf4j.LoggerFactory) Srp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1) PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessageBuilder) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) ByteBuffer(java.nio.ByteBuffer) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PcupdMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.PcupdMessageBuilder) Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathNameBuilder) StatefulTlvBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.StatefulTlvBuilder) Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.Path) PceServerProvider(org.opendaylight.bgpcep.pcep.server.PceServerProvider) Path1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1Builder) Arguments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.ensure.lsp.operational.args.Arguments) BindingMap(org.opendaylight.yangtools.yang.binding.util.BindingMap) PathComputation(org.opendaylight.bgpcep.pcep.server.PathComputation) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) List(java.util.List) OperationalStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.OperationalStatus) Optional(java.util.Optional) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) PcrptMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptMessage) EnsureLspOperationalInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.EnsureLspOperationalInput) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.LspId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RemoveLspArgs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.RemoveLspArgs) RequestCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.RequestCaseBuilder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClient) Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful) Path1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1) Objects.requireNonNull(java.util.Objects.requireNonNull) RpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.request._case.request.RpsBuilder) PcupdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcupdBuilder) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) StatefulTlv1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.StatefulTlv1Builder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs) PccSyncState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.PccSyncState) Logger(org.slf4j.Logger) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) AsyncFunction(com.google.common.util.concurrent.AsyncFunction) PcerrMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessageBuilder) PcerrBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder) Collections(java.util.Collections) FluentFuture(com.google.common.util.concurrent.FluentFuture) PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessageBuilder) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder) Optional(java.util.Optional) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method buildRequest.

private Requests buildRequest(final Optional<ReportedLsp> rep, final Lsp reportedLsp) {
    // Build the request and send it
    final RequestsBuilder rb = new RequestsBuilder();
    final SrpBuilder srpBuilder = new SrpBuilder().addAugmentation(new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE);
    final Optional<PathSetupType> maybePST = getPST(rep);
    if (maybePST.isPresent()) {
        srpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.srp.TlvsBuilder().setPathSetupType(maybePST.get()).build());
    }
    rb.setSrp(srpBuilder.build());
    rb.setLsp(new LspBuilder().setRemove(Boolean.FALSE).setPlspId(reportedLsp.getPlspId()).setDelegate(reportedLsp.getDelegate()).build());
    return rb.build();
}
Also used : SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) Collections(java.util.Collections) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1Builder)

Example 8 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method redelegate.

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp, final UpdateLspArgs input) {
    // the D bit that was reported decides the type of PCE message sent
    final boolean isDelegate = requireNonNull(reportedLsp.getDelegate());
    final Message msg;
    if (isDelegate) {
        // we already have delegation, send update
        final UpdatesBuilder rb = new UpdatesBuilder();
        rb.setSrp(srp);
        rb.setLsp(lsp);
        final PathBuilder pb = new PathBuilder();
        pb.fieldsFrom(input.getArguments());
        rb.setPath(pb.build());
        final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
        ub.setUpdates(Collections.singletonList(rb.build()));
        msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
    } else {
        final Lsp1 lspCreateFlag = reportedLsp.augmentation(Lsp1.class);
        // we only retake delegation for PCE initiated tunnels
        if (lspCreateFlag != null && !lspCreateFlag.getCreate()) {
            LOG.warn("Unable to retake delegation of PCC-initiated tunnel: {}", reportedLsp);
            return OperationResults.createUnsent(PCEPErrors.UPDATE_REQ_FOR_NON_LSP).future();
        }
        // we want to revoke delegation, different type of message
        // is sent because of specification by Siva
        // this message is also sent, when input delegate bit is set to 0
        // generating an error in PCC
        final List<Requests> reqs = new ArrayList<>();
        reqs.add(new RequestsBuilder().setSrp(srp).setLsp(lsp).build());
        final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder();
        ib.setRequests(reqs);
        msg = new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build();
    }
    return sendMessage(msg, srp.getOperationId(), input.getArguments().getMetadata());
}
Also used : PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) PcreqMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage) PcrptMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptMessage) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) ArrayList(java.util.ArrayList) Lsp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Lsp1) PcupdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcupdBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessageBuilder) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder) PcupdMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.PcupdMessageBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 9 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class NodeChangedListener method remove.

private void remove(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ExecutionException, InterruptedException {
    final InstanceIdentifier<Link> li = linkForLsp(linkIdForLsp(identifier, value));
    final Optional<Link> ol = trans.read(LogicalDatastoreType.OPERATIONAL, li).get();
    if (!ol.isPresent()) {
        return;
    }
    final Link l = ol.get();
    LOG.debug("Removing link {} (was {})", li, l);
    trans.delete(LogicalDatastoreType.OPERATIONAL, li);
    LOG.debug("Searching for orphan links/nodes");
    final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).get();
    Preconditions.checkState(ot.isPresent());
    final Topology topology = ot.get();
    final NodeId srcNode = l.getSource().getSourceNode();
    final NodeId dstNode = l.getDestination().getDestNode();
    final TpId srcTp = l.getSource().getSourceTp();
    final TpId dstTp = l.getDestination().getDestTp();
    boolean orphSrcNode = true;
    boolean orphDstNode = true;
    boolean orphDstTp = true;
    boolean orphSrcTp = true;
    for (final Link lw : topology.nonnullLink().values()) {
        LOG.trace("Checking link {}", lw);
        final NodeId sn = lw.getSource().getSourceNode();
        final NodeId dn = lw.getDestination().getDestNode();
        final TpId st = lw.getSource().getSourceTp();
        final TpId dt = lw.getDestination().getDestTp();
        // Source node checks
        if (srcNode.equals(sn)) {
            if (orphSrcNode) {
                LOG.debug("Node {} held by source of link {}", srcNode, lw);
                orphSrcNode = false;
            }
            if (orphSrcTp && srcTp.equals(st)) {
                LOG.debug("TP {} held by source of link {}", srcTp, lw);
                orphSrcTp = false;
            }
        }
        if (srcNode.equals(dn)) {
            if (orphSrcNode) {
                LOG.debug("Node {} held by destination of link {}", srcNode, lw);
                orphSrcNode = false;
            }
            if (orphSrcTp && srcTp.equals(dt)) {
                LOG.debug("TP {} held by destination of link {}", srcTp, lw);
                orphSrcTp = false;
            }
        }
        // Destination node checks
        if (dstNode.equals(sn)) {
            if (orphDstNode) {
                LOG.debug("Node {} held by source of link {}", dstNode, lw);
                orphDstNode = false;
            }
            if (orphDstTp && dstTp.equals(st)) {
                LOG.debug("TP {} held by source of link {}", dstTp, lw);
                orphDstTp = false;
            }
        }
        if (dstNode.equals(dn)) {
            if (orphDstNode) {
                LOG.debug("Node {} held by destination of link {}", dstNode, lw);
                orphDstNode = false;
            }
            if (orphDstTp && dstTp.equals(dt)) {
                LOG.debug("TP {} held by destination of link {}", dstTp, lw);
                orphDstTp = false;
            }
        }
    }
    if (orphSrcNode && !orphSrcTp) {
        LOG.warn("Orphan source node {} but not TP {}, retaining the node", srcNode, srcTp);
        orphSrcNode = false;
    }
    if (orphDstNode && !orphDstTp) {
        LOG.warn("Orphan destination node {} but not TP {}, retaining the node", dstNode, dstTp);
        orphDstNode = false;
    }
    if (orphSrcNode) {
        LOG.debug("Removing orphan node {}", srcNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(srcNode));
    } else if (orphSrcTp) {
        LOG.debug("Removing orphan TP {} on node {}", srcTp, srcNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(srcNode, srcTp));
    }
    if (orphDstNode) {
        LOG.debug("Removing orphan node {}", dstNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(dstNode));
    } else if (orphDstTp) {
        LOG.debug("Removing orphan TP {} on node {}", dstTp, dstNode);
        trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(dstNode, dstTp));
    }
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Example 10 with ReportedLsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp in project bgpcep by opendaylight.

the class NodeChangedListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
    final ReadWriteTransaction trans = this.dataProvider.newReadWriteTransaction();
    final Set<InstanceIdentifier<ReportedLsp>> lsps = new HashSet<>();
    final Set<InstanceIdentifier<Node>> nodes = new HashSet<>();
    final Map<InstanceIdentifier<?>, DataObject> original = new HashMap<>();
    final Map<InstanceIdentifier<?>, DataObject> updated = new HashMap<>();
    final Map<InstanceIdentifier<?>, DataObject> created = new HashMap<>();
    for (final DataTreeModification<?> change : changes) {
        final InstanceIdentifier<?> iid = change.getRootPath().getRootIdentifier();
        final DataObjectModification<?> rootNode = change.getRootNode();
        handleChangedNode(rootNode, iid, lsps, nodes, original, updated, created);
    }
    // Now walk all nodes, check for removals/additions and cascade them to LSPs
    for (final InstanceIdentifier<Node> iid : nodes) {
        enumerateLsps(iid, (Node) original.get(iid), lsps);
        enumerateLsps(iid, (Node) updated.get(iid), lsps);
        enumerateLsps(iid, (Node) created.get(iid), lsps);
    }
    // We now have list of all affected LSPs. Walk them create/remove them
    updateTransaction(trans, lsps, original, updated, created);
    trans.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Topology change committed successfully");
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Failed to propagate a topology change, target topology became inconsistent", throwable);
        }
    }, MoreExecutors.directExecutor());
}
Also used : HashMap(java.util.HashMap) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) HashSet(java.util.HashSet)

Aggregations

ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp)9 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)6 Path (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.Path)6 Collections (java.util.Collections)5 Path1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)3 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests)3 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder)3 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)3 ReportedLspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder)3 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)3 Optional (com.google.common.base.Optional)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)2 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)2 PcinitiateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder)2