Search in sources :

Example 61 with Close

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project bgpcep by opendaylight.

the class ServerSessionManager method takeNodeState.

final synchronized TopologyNodeState takeNodeState(final InetAddress address, final TopologySessionListener sessionListener, final boolean retrieveNode) {
    final NodeId id = createNodeId(address);
    if (isClosed.get()) {
        LOG.error("Server Session Manager is closed. Unable to create topology node {} with listener {}", id, sessionListener);
        return null;
    }
    LOG.debug("Node {} requested by listener {}", id, sessionListener);
    TopologyNodeState ret = state.get(id);
    if (ret == null) {
        ret = new TopologyNodeState(dependencies.getDataBroker(), topology, id, DEFAULT_HOLD_STATE_NANOS);
        LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
        state.put(id, ret);
    }
    // if another listener requests the same session, close it
    final TopologySessionListener existingSessionListener = nodes.get(id);
    if (existingSessionListener != null && !sessionListener.equals(existingSessionListener)) {
        LOG.error("New session listener {} is in conflict with existing session listener {} on node {}," + " closing the existing one.", existingSessionListener, sessionListener, id);
        existingSessionListener.close();
    }
    ret.taken(retrieveNode);
    nodes.put(id, sessionListener);
    LOG.debug("Node {} bound to listener {}", id, sessionListener);
    return ret;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)

Aggregations

Test (org.junit.Test)25 InetSocketAddress (java.net.InetSocketAddress)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Before (org.junit.Before)8 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Optional (com.google.common.base.Optional)5 ChannelFuture (io.netty.channel.ChannelFuture)5 ChannelHandler (io.netty.channel.ChannelHandler)5 TimeUnit (java.util.concurrent.TimeUnit)5 Channel (io.netty.channel.Channel)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 Notification (org.opendaylight.yangtools.yang.binding.Notification)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4