Search in sources :

Example 41 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project bgpcep by opendaylight.

the class PCEPSessionImpl method close.

/**
 * Closes PCEP session, cancels all timers, returns to state Idle, sends the Close Message. KeepAlive and DeadTimer
 * are cancelled if the state of the session changes to IDLE. This method is used to close the PCEP session from
 * inside the session or from the listener, therefore the parent of this session should be informed.
 */
@Override
public synchronized void close(final TerminationReason reason) {
    if (this.closed.getAndSet(true)) {
        LOG.debug("Session is already closed.");
        return;
    }
    // only send close message when the reason is provided
    if (reason != null) {
        LOG.info("Closing PCEP session with reason {}: {}", reason, this);
        sendMessage(new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(new CCloseBuilder().setReason(reason.getShortValue()).build()).build()).build());
    } else {
        LOG.info("Closing PCEP session: {}", this);
    }
    closeChannel();
}
Also used : CloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder) CCloseMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder)

Example 42 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslator method processUpdatedConnector.

private void processUpdatedConnector(final DataTreeModification<T> modification) {
    final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
    InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier.firstIdentifierOf(NodeConnector.class);
    if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
        FlowCapableNodeConnector flowConnector = (FlowCapableNodeConnector) modification.getRootNode().getDataAfter();
        if (isPortDown(flowConnector)) {
            notifyNodeConnectorDisappeared(nodeConnectorInstanceId);
        } else {
            notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowConnector);
        }
    } else if (compareIITail(identifier, II_TO_STATE)) {
        FlowCapableNodeConnector flowNodeConnector = iiToDownFlowCapableNodeConnectors.get(nodeConnectorInstanceId);
        if (flowNodeConnector != null) {
            State state = (State) modification.getRootNode().getDataAfter();
            if (!state.isLinkDown()) {
                FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder(flowNodeConnector);
                flowCapableNodeConnectorBuilder.setState(state);
                notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowCapableNodeConnectorBuilder.build());
                iiToDownFlowCapableNodeConnectors.remove(nodeConnectorInstanceId);
            }
        }
    }
}
Also used : FlowCapableNodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) State(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)

Example 43 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorUpdateToLinkDown.

/**
 * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
 * for each FlowCapableNodeConnector item that have link down state removed in
 * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
 */
@Test
public void testNodeConnectorUpdateToLinkDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED, NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verify(eventsObserver).nodeConnectorRemoved(ID);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Example 44 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorCreationLinkDown.

/**
 * Test that checks that nothing is called when port appeared in inventory in link down state.
 */
@Test
public void testNodeConnectorCreationLinkDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verifyZeroInteractions(eventsObserver);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Test(org.junit.Test)

Example 45 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorCreationAdminDown.

/**
 * Test that checks that nothing is called when port appeared in inventory in admin down state.
 */
@Test
public void testNodeConnectorCreationAdminDown() {
    FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
    translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
    verifyZeroInteractions(eventsObserver);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) 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