Search in sources :

Example 16 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project netvirt by opendaylight.

the class InterVpnLinkUtil method updateInterVpnLinkState.

/**
 * Updates inter-VPN link state.
 *
 * @param broker dataBroker service reference
 * @param vpnLinkName The name of the InterVpnLink
 * @param state Sets the state of the InterVpnLink to Active or Error
 * @param newFirstEndpointState Updates the lportTag and/or DPNs of the 1st endpoint of the InterVpnLink
 * @param newSecondEndpointState Updates the lportTag and/or DPNs of the 2nd endpoint of the InterVpnLink
 * @param interVpnLinkCache the InterVpnLinkCache
 */
public static void updateInterVpnLinkState(DataBroker broker, String vpnLinkName, InterVpnLinkState.State state, FirstEndpointState newFirstEndpointState, SecondEndpointState newSecondEndpointState, InterVpnLinkCache interVpnLinkCache) {
    Optional<InterVpnLinkState> optOldVpnLinkState = getInterVpnLinkState(broker, vpnLinkName);
    if (optOldVpnLinkState.isPresent()) {
        InterVpnLinkState newVpnLinkState = new InterVpnLinkStateBuilder(optOldVpnLinkState.get()).setState(state).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).build();
        VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newVpnLinkState);
    } else {
        InterVpnLinkState newIVpnLinkState = new InterVpnLinkStateBuilder().setKey(new InterVpnLinkStateKey(vpnLinkName)).setInterVpnLinkName(vpnLinkName).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).setState(InterVpnLinkState.State.Active).build();
        VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newIVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newIVpnLinkState);
    }
}
Also used : InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState) InterVpnLinkStateKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateKey) InterVpnLinkStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateBuilder)

Example 17 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method update.

@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
        return;
    }
    if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
        LOG.trace("Interface operstatus {} is same", update.getOperStatus());
        return;
    }
    if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
        LOG.trace("New/old interface state is unknown not handling");
        return;
    }
    List<String> ofportIds = update.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    String interfaceName = update.getName();
    DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceUpdateJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceUpdateJob)

Example 18 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project controller by opendaylight.

the class ClusterAdminRpcService method changeMemberVotingStatesForShard.

@Override
public Future<RpcResult<Void>> changeMemberVotingStatesForShard(ChangeMemberVotingStatesForShardInput 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");
    }
    List<MemberVotingState> memberVotingStates = input.getMemberVotingState();
    if (memberVotingStates == null || memberVotingStates.isEmpty()) {
        return newFailedRpcResultFuture("No member voting state input was specified");
    }
    ChangeShardMembersVotingStatus changeVotingStatus = toChangeShardMembersVotingStatus(shardName, memberVotingStates);
    LOG.info("Change member voting states for shard {}: {}", shardName, changeVotingStatus.getMeberVotingStatusMap());
    final SettableFuture<RpcResult<Void>> returnFuture = SettableFuture.create();
    ListenableFuture<Success> future = sendMessageToShardManager(dataStoreType, changeVotingStatus);
    Futures.addCallback(future, new FutureCallback<Success>() {

        @Override
        public void onSuccess(Success success) {
            LOG.info("Successfully changed member voting states for shard {}", shardName);
            returnFuture.set(newSuccessfulResult());
        }

        @Override
        public void onFailure(Throwable failure) {
            onMessageFailure(String.format("Failed to change member voting states for shard %s", shardName), returnFuture, failure);
        }
    }, MoreExecutors.directExecutor());
    return returnFuture;
}
Also used : ChangeShardMembersVotingStatus(org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus) MemberVotingState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Success(akka.actor.Status.Success) DataStoreType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType)

Example 19 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.

the class IncrementalSynchronizationProcedureTest 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 = getPcrpt(1L, "test");
    this.listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onSessionDown(session, new IllegalArgumentException());
    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 - IncrementalSync state
        assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
        // check reported LSP - persisted from previous session
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // report LSP2 + LSP-DB version number 2
    final Pcrpt pcRpt2 = getPcrpt(2L, "testsecond");
    this.listener.onMessage(session, pcRpt2);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
        // check reported LSP is not empty
        assertEquals(2, pcc.getReportedLsp().size());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = getSyncPcrt();
    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
        assertEquals(2, pcc.getReportedLsp().size());
        return pcc;
    });
    // report LSP3 + LSP-DB version number 4
    final Pcrpt pcRpt3 = getPcrpt(3L, "testthird");
    this.listener.onMessage(session, pcRpt3);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        assertEquals(3, pcc.getReportedLsp().size());
        return pcc;
    });
}
Also used : 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) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Test(org.junit.Test)

Example 20 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.

the class PCEPTriggeredReSynchronizationProcedureTest method testTriggeredResynchronization.

@Test
public void testTriggeredResynchronization() throws Exception {
    // session up - sync skipped (LSP-DBs match)
    this.session = getPCEPSession(getOpen(), getOpen());
    this.listener.onSessionUp(this.session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = getPcrt();
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // PCEP Trigger Full Resync
    this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).build());
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(PccSyncState.PcepTriggeredResync, pcc.getStateSync());
        return pcc;
    });
    // end of sync
    final Pcrpt syncMsg = getSyncMsg();
    this.listener.onMessage(this.session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        return pcc;
    });
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(1, pcc.getReportedLsp().size());
        return pcc;
    });
    // Trigger Full Resync
    this.listener.triggerSync(new TriggerSyncInputBuilder().setNode(this.nodeId).build());
    this.listener.onMessage(this.session, pcRpt);
    // end of sync
    this.listener.onMessage(this.session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is not empty, Stale LSP state were purged
        assertEquals(1, pcc.getReportedLsp().size());
        return pcc;
    });
}
Also used : TriggerSyncInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncInputBuilder) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)31 Test (org.junit.Test)28 BigInteger (java.math.BigInteger)27 List (java.util.List)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 Collections (java.util.Collections)13 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Optional (com.google.common.base.Optional)11 Inject (javax.inject.Inject)11 Singleton (javax.inject.Singleton)11 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)10 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)10 FutureCallback (com.google.common.util.concurrent.FutureCallback)9 ByteBuf (io.netty.buffer.ByteBuf)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9