Search in sources :

Example 46 with Close

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

the class AbstractPCEPSessionTest method setUp.

@Before
public final void setUp() {
    MockitoAnnotations.initMocks(this);
    final ChannelFuture future = new DefaultChannelPromise(this.channel);
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        AbstractPCEPSessionTest.this.msgsSend.add((Notification) args[0]);
        return future;
    }).when(this.channel).writeAndFlush(any(Notification.class));
    doReturn(this.channelFuture).when(this.channel).closeFuture();
    doReturn(this.channelFuture).when(this.channelFuture).addListener(any(GenericFutureListener.class));
    doReturn("TestingChannel").when(this.channel).toString();
    doReturn(this.pipeline).when(this.channel).pipeline();
    doReturn(this.address).when(this.channel).localAddress();
    doReturn(this.address).when(this.channel).remoteAddress();
    doReturn(this.eventLoop).when(this.channel).eventLoop();
    doReturn(true).when(this.future).cancel(false);
    doReturn(this.future).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
    doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
    doReturn(this.pipeline).when(this.pipeline).addFirst(any(ChannelHandler.class));
    doReturn(true).when(this.channel).isActive();
    doReturn(mock(ChannelFuture.class)).when(this.channel).close();
    doReturn(new InetSocketAddress(this.ipAddress, this.port)).when(this.channel).remoteAddress();
    doReturn(new InetSocketAddress(this.ipAddress, this.port)).when(this.channel).localAddress();
    this.openMsg = new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setDeadTimer(DEADTIMER).setKeepalive(KEEP_ALIVE).setSessionId((short) 0).build()).build()).build();
    this.kaMsg = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build();
    this.startTlsMsg = new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build()).build();
    this.closeMsg = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(new CCloseBuilder().setReason((short) 6).build()).build()).build();
    this.listener = new SimpleSessionListener();
}
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) MockitoAnnotations(org.mockito.MockitoAnnotations) InetSocketAddress(java.net.InetSocketAddress) ChannelHandler(io.netty.channel.ChannelHandler) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder) Notification(org.opendaylight.yangtools.yang.binding.Notification) OpenMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder) TimeUnit(java.util.concurrent.TimeUnit) KeepaliveMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) ChannelFuture(io.netty.channel.ChannelFuture) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder) StartTlsMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.start.tls.message.StartTlsMessageBuilder) StarttlsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.StarttlsBuilder) Mockito.doReturn(org.mockito.Mockito.doReturn) CCloseMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) Before(org.junit.Before)

Example 47 with Close

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

the class PCEPCloseMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    Preconditions.checkArgument(message instanceof CloseMessage, "Wrong instance of Message. Passed instance of %s. Need CloseMessage.", message.getClass());
    final CCloseMessage close = ((CloseMessage) message).getCCloseMessage();
    Preconditions.checkArgument(close.getCClose() != null, "Close Object must be present in Close Message.");
    final ByteBuf buffer = Unpooled.buffer();
    serializeObject(close.getCClose(), buffer);
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : CCloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessage) CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage) CCloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessage) ByteBuf(io.netty.buffer.ByteBuf)

Example 48 with Close

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

the class ServerSessionManager method takeNodeState.

synchronized TopologyNodeState takeNodeState(final InetAddress address, final TopologySessionListener sessionListener, final boolean retrieveNode) {
    final NodeId id = createNodeId(address);
    if (this.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 = this.state.get(id);
    if (ret == null) {
        ret = new TopologyNodeState(this.dependenciesProvider.getDataBroker(), this.topology, id, DEFAULT_HOLD_STATE_NANOS);
        LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
        this.state.put(id, ret);
    }
    // if another listener requests the same session, close it
    final TopologySessionListener existingSessionListener = this.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);
    this.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)

Example 49 with Close

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

the class OpenflowpluginTestServiceProvider method register.

public ObjectRegistration<OpenflowpluginTestServiceProvider> register(final ProviderContext ctx) {
    RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx.<SalFlowService>addRoutedRpcImplementation(SalFlowService.class, this);
    setFlowRegistration(addRoutedRpcImplementation);
    InstanceIdentifierBuilder<Nodes> builderII = InstanceIdentifier.<Nodes>builder(Nodes.class);
    NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifierBuilder<Node> nodeIdentifier = builderII.<Node, NodeKey>child(Node.class, nodeKey);
    InstanceIdentifier<Node> instance = nodeIdentifier.build();
    flowRegistration.registerPath(NodeContext.class, instance);
    RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
    return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {

        @Override
        protected void removeRegistration() {
            flowRegistration2.close();
        }
    };
}
Also used : AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) SalFlowService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 50 with Close

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

the class OpendaylightFlowStatisticsServiceImpl2Test method setUp.

public void setUp() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
    rqContextMp = new AbstractRequestContext<List<MultipartReply>>(42L) {

        @Override
        public void close() {
        // NOOP
        }
    };
    Mockito.when(rqContextStack.<List<MultipartReply>>createRequestContext()).thenReturn(rqContextMp);
    Mockito.when(translatorLibrary.<MultipartReply, AggregatedFlowStatistics>lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) List(java.util.List) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager)

Aggregations

Test (org.junit.Test)23 InetSocketAddress (java.net.InetSocketAddress)12 Before (org.junit.Before)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)9 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)8 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)8 TimeUnit (java.util.concurrent.TimeUnit)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 Optional (com.google.common.base.Optional)6 ChannelFuture (io.netty.channel.ChannelFuture)6 ChannelHandler (io.netty.channel.ChannelHandler)6 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)6 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 Channel (io.netty.channel.Channel)4 List (java.util.List)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4