Search in sources :

Example 81 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project genius by opendaylight.

the class HwvtepUtils method putPhysicalLocator.

/**
 * Put physical locator in the transaction.
 *
 * @param transaction
 *            the transaction
 * @param nodeId
 *            the node id
 * @param phyLocator
 *            the phy locator
 */
public static void putPhysicalLocator(final WriteTransaction transaction, final NodeId nodeId, final HwvtepPhysicalLocatorAugmentation phyLocator) {
    InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocator);
    TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocator)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocator).build();
    transaction.put(LogicalDatastoreType.CONFIGURATION, iid, terminationPoint, true);
}
Also used : HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 82 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project controller by opendaylight.

the class CarProvider method registerCommitCohort.

@Override
public synchronized ListenableFuture<RpcResult<RegisterCommitCohortOutput>> registerCommitCohort(final RegisterCommitCohortInput input) {
    if (commitCohortReg.get() != null) {
        return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
    }
    final DOMDataTreeCommitCohortRegistry commitCohortRegistry = domDataBroker.getExtensions().getInstance(DOMDataTreeCommitCohortRegistry.class);
    if (commitCohortRegistry == null) {
        // Shouldn't happen
        return RpcResultBuilder.<RegisterCommitCohortOutput>failed().withError(ErrorType.APPLICATION, "DOMDataTreeCommitCohortRegistry not found").buildFuture();
    }
    // Note: it may look strange that we specify the CarEntry.QNAME twice in the path below. This must be done in
    // order to register the commit cohort for CarEntry instances. In the underlying data tree, a yang list is
    // represented as a MapNode with MapEntryNodes representing the child list entries. Therefore, in order to
    // address a list entry, you must specify the path argument for the MapNode and the path argument for the
    // MapEntryNode. In the path below, the first CarEntry.QNAME argument addresses the MapNode and, since we want
    // to address all list entries, the second path argument is wild-carded by specifying just the CarEntry.QNAME.
    final YangInstanceIdentifier carEntryPath = YangInstanceIdentifier.builder(YangInstanceIdentifier.of(Cars.QNAME)).node(CarEntry.QNAME).node(CarEntry.QNAME).build();
    commitCohortReg.set(commitCohortRegistry.registerCommitCohort(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, carEntryPath), new CarEntryDataTreeCommitCohort()));
    LOG_CAR_PROVIDER.info("Registered commit cohort");
    return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
}
Also used : RegisterCommitCohortOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterCommitCohortOutputBuilder) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) DOMDataTreeCommitCohortRegistry(org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) RegisterCommitCohortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterCommitCohortOutput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 83 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project controller by opendaylight.

the class AkkaEntityOwnershipServiceTest method testEntityRetrievalWithYiid.

@Test
public void testEntityRetrievalWithYiid() throws Exception {
    final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
    final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
    final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
    verifyEntityOwnershipCandidateRegistration(entity, reg);
    verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
    RpcResult<GetEntityOutput> getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
    assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
    assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
    // we should not be able to retrieve the entity when using string
    final String entityPathEncoded = "/network-topology:network-topology/topology[topology-id='test']/node[node-id='test://test-node']";
    getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(entityPathEncoded)).setType(new EntityType(ENTITY_TYPE)).build()).get();
    assertNull(getEntityResult.getResult().getOwnerNode());
    assertTrue(getEntityResult.getResult().getCandidateNodes().isEmpty());
    final GetEntitiesOutput getEntitiesResult = service.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
    assertEquals(getEntitiesResult.getEntities().size(), 1);
    assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
    assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
    final GetEntityOwnerOutput getOwnerResult = service.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
    assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
}
Also used : GetEntityOwnerInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerInputBuilder) DOMEntityOwnershipCandidateRegistration(org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration) EntityName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName) NodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName) DOMEntity(org.opendaylight.mdsal.eos.dom.api.DOMEntity) EntitiesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesKey) GetEntityOwnerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerOutput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) GetEntityInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityInputBuilder) EntityType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType) GetEntityOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOutput) GetEntitiesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) GetEntitiesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesOutput) Test(org.junit.Test)

Example 84 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project controller by opendaylight.

the class EntityRpcHandlerTest method testEntityRetrievalWithUnavailableSupervisor.

/*
     * Tests entity rpcs handled both by the owner supervisor(service1) and with an idle supervisor(falling
     * back to distributed-data in an inactive datacenter). This covers both the available cases, datacenters and case
     * in which the node with active akka-singleton is shutdown and another one takes over.
     */
@Test
public void testEntityRetrievalWithUnavailableSupervisor() throws Exception {
    final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
    final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
    final DOMEntityOwnershipCandidateRegistration reg = service1.registerCandidate(entity);
    await().untilAsserted(() -> {
        final RpcResult<GetEntityOutput> getEntityResult = service1.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
        assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
        assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
    });
    // keep this under ask timeout to make sure the singleton actor in the inactive datacenter responds with failure
    // immediately, so that the rpc actor retries with distributed-data asap
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntitiesOutput getEntitiesResult = service2.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
        assertEquals(getEntitiesResult.getEntities().size(), 1);
        assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
        assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
    });
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntityOutput getEntityResult = service2.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
        assertEquals(getEntityResult.getOwnerNode().getValue(), "member-1");
        assertEquals(getEntityResult.getCandidateNodes().get(0).getValue(), "member-1");
    });
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
        final GetEntityOwnerOutput getOwnerResult = service2.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
        assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
    });
}
Also used : GetEntityOwnerInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerInputBuilder) DOMEntityOwnershipCandidateRegistration(org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration) EntityName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName) NodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.NodeName) DOMEntity(org.opendaylight.mdsal.eos.dom.api.DOMEntity) EntitiesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesKey) GetEntityOwnerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOwnerOutput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) GetEntityInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityInputBuilder) EntityType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType) GetEntityOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntityOutput) GetEntitiesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) GetEntitiesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesOutput) Test(org.junit.Test)

Example 85 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project controller by opendaylight.

the class ClusterAdminRpcService method makeLeaderLocal.

@Override
public ListenableFuture<RpcResult<MakeLeaderLocalOutput>> makeLeaderLocal(final MakeLeaderLocalInput input) {
    final String shardName = input.getShardName();
    if (Strings.isNullOrEmpty(shardName)) {
        return newFailedRpcResultFuture("A valid shard name must be specified");
    }
    DataStoreType dataStoreType = input.getDataStoreType();
    if (dataStoreType == null) {
        return newFailedRpcResultFuture("A valid DataStoreType must be specified");
    }
    ActorUtils actorUtils = dataStoreType == DataStoreType.Config ? configDataStore.getActorUtils() : operDataStore.getActorUtils();
    LOG.info("Moving leader to local node {} for shard {}, datastoreType {}", actorUtils.getCurrentMemberName().getName(), shardName, dataStoreType);
    final Future<ActorRef> localShardReply = actorUtils.findLocalShardAsync(shardName);
    final scala.concurrent.Promise<Object> makeLeaderLocalAsk = akka.dispatch.Futures.promise();
    localShardReply.onComplete(new OnComplete<ActorRef>() {

        @Override
        public void onComplete(final Throwable failure, final ActorRef actorRef) {
            if (failure != null) {
                LOG.warn("No local shard found for {} datastoreType {} - Cannot request leadership transfer to" + " local shard.", shardName, dataStoreType, failure);
                makeLeaderLocalAsk.failure(failure);
            } else {
                makeLeaderLocalAsk.completeWith(actorUtils.executeOperationAsync(actorRef, MakeLeaderLocal.INSTANCE, makeLeaderLocalTimeout));
            }
        }
    }, actorUtils.getClientDispatcher());
    final SettableFuture<RpcResult<MakeLeaderLocalOutput>> future = SettableFuture.create();
    makeLeaderLocalAsk.future().onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object success) {
            if (failure != null) {
                LOG.error("Leadership transfer failed for shard {}.", shardName, failure);
                future.set(RpcResultBuilder.<MakeLeaderLocalOutput>failed().withError(ErrorType.APPLICATION, "leadership transfer failed", failure).build());
                return;
            }
            LOG.debug("Leadership transfer complete");
            future.set(RpcResultBuilder.success(new MakeLeaderLocalOutputBuilder().build()).build());
        }
    }, actorUtils.getClientDispatcher());
    return future;
}
Also used : ActorRef(akka.actor.ActorRef) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MakeLeaderLocalOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.MakeLeaderLocalOutputBuilder) DataStoreType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType) MakeLeaderLocalOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.MakeLeaderLocalOutput) ActorUtils(org.opendaylight.controller.cluster.datastore.utils.ActorUtils)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)220 ArrayList (java.util.ArrayList)160 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)160 Test (org.junit.Test)115 ExecutionException (java.util.concurrent.ExecutionException)108 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)108 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)105 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)93 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)89 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)88 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)81 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)61 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)60 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)60 List (java.util.List)59 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)57 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)54 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)53 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)53 Logger (org.slf4j.Logger)52