Search in sources :

Example 1 with Revision

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision 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 Map<PathKey, 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.withKey(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.key()), 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.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.Path) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey)

Example 2 with Revision

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision in project mdsal by opendaylight.

the class MountPointContextFactoryImpl method fillSource.

private static void fillSource(final List<SourceReference> sources, final YangIdentifier sourceName, final Optional<Revision> revision, final Set<Uri> uris) {
    final var sourceId = RevisionSourceIdentifier.create(sourceName.getValue(), revision);
    final SourceReference sourceRef;
    if (uris != null && uris.isEmpty()) {
        final var locations = new ArrayList<URL>();
        for (Uri uri : uris) {
            try {
                locations.add(new URL(uri.getValue()));
            } catch (MalformedURLException e) {
                LOG.debug("Ignoring invalid schema location {}", uri, e);
            }
        }
        sourceRef = SourceReference.of(sourceId, locations);
    } else {
        sourceRef = SourceReference.of(sourceId);
    }
    sources.add(sourceRef);
}
Also used : MalformedURLException(java.net.MalformedURLException) SourceReference(org.opendaylight.mdsal.yanglib.api.SourceReference) ArrayList(java.util.ArrayList) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) URL(java.net.URL)

Example 3 with Revision

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision in project netconf by opendaylight.

the class ModuleBuilderTest method testModuleBuilder.

@Test
public void testModuleBuilder() {
    final ModuleBuilder moduleBuilder = new ModuleBuilder();
    final Module.Revision revision = new Module.Revision(new RevisionIdentifier("2016-10-11"));
    final YangIdentifier yangIdentifierOne = new YangIdentifier("YangIdentifier1");
    final YangIdentifier yangIdentifierTwo = new YangIdentifier("YangIdentifier2");
    final Uri namespace = new Uri("namespace");
    final List<YangIdentifier> yangIdentifierList = ImmutableList.of(yangIdentifierOne, yangIdentifierTwo);
    final ModuleKey moduleKeyOne = new ModuleKey(yangIdentifierOne, revision);
    final ModuleKey moduleKeyTwo = new ModuleKey(moduleKeyOne);
    moduleBuilder.setRevision(revision);
    moduleBuilder.setDeviation(yangIdentifierList);
    moduleBuilder.setFeature(yangIdentifierList);
    moduleBuilder.setName(yangIdentifierOne);
    moduleBuilder.setNamespace(namespace);
    moduleBuilder.withKey(moduleKeyOne);
    final Module moduleOne = moduleBuilder.build();
    final Module moduleTwo = new ModuleBuilder(moduleOne).build();
    assertNotNull(moduleBuilder);
    assertNotNull(revision);
    assertNotNull(yangIdentifierOne);
    assertNotNull(yangIdentifierTwo);
    assertNotNull(namespace);
    assertNotNull(yangIdentifierList);
    assertNotNull(moduleKeyOne);
    assertNotNull(moduleKeyOne.hashCode());
    assertNotNull(moduleKeyOne.toString());
    assertNotNull(moduleBuilder.toString());
    assertNotNull(moduleBuilder.hashCode());
    assertEquals(moduleKeyOne, moduleKeyTwo);
    assertEquals(revision, moduleKeyOne.getRevision());
    assertEquals(yangIdentifierOne, moduleKeyOne.getName());
    assertEquals(revision, moduleBuilder.getRevision());
    assertEquals(yangIdentifierList, moduleBuilder.getDeviation());
    assertEquals(yangIdentifierList, moduleBuilder.getFeature());
    assertEquals(yangIdentifierOne, moduleBuilder.getName());
    assertEquals(namespace, moduleBuilder.getNamespace());
    assertEquals(moduleKeyOne, moduleBuilder.key());
    assertEquals(moduleOne.toString(), moduleTwo.toString());
    assertEquals(moduleKeyOne.toString(), moduleKeyTwo.toString());
    assertTrue(moduleOne.equals(moduleTwo));
    assertTrue(moduleKeyOne.equals(moduleKeyTwo));
}
Also used : RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) YangIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier) Test(org.junit.Test)

Example 4 with Revision

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision in project netconf by opendaylight.

the class ModuleRevisionBuilderTest method testModuleRevisionBuilder.

@Test
public void testModuleRevisionBuilder() {
    final ModuleRevisionBuilder moduleRevisionBuilder = new ModuleRevisionBuilder();
    assertNotNull(moduleRevisionBuilder);
    final Revision revision = ModuleRevisionBuilder.getDefaultInstance("");
    assertNotNull(revision);
    assertEquals("", revision.getString());
    assertEquals(null, revision.getRevisionIdentifier());
}
Also used : Revision(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision) Test(org.junit.Test)

Example 5 with Revision

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision in project netconf by opendaylight.

the class RevisionBuilderTest method testEmptyString.

@Test
public void testEmptyString() {
    final RevisionBuilder revisionBuilder = new RevisionBuilder();
    assertNotNull(revisionBuilder);
    final Revision revision = RevisionBuilder.getDefaultInstance("");
    validate(revision, "", null);
}
Also used : Revision(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)3 Revision (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision)3 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 RevisionIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier)2 RevisionIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier)2 Revision (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision)2 ModuleKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey)2 YangIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 Revision (org.opendaylight.yangtools.yang.common.Revision)2 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)2 Preconditions (com.google.common.base.Preconditions)1 HashMultimap (com.google.common.collect.HashMultimap)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1