Search in sources :

Example 1 with TransportProtocol

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol in project openflowplugin by opendaylight.

the class SwitchConnectionProviderImpl method createAndConfigureServer.

private ServerFacade createAndConfigureServer() {
    LOG.debug("Configuring ..");
    ServerFacade server = null;
    final ChannelInitializerFactory factory = new ChannelInitializerFactory();
    factory.setSwitchConnectionHandler(switchConnectionHandler);
    factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
    factory.setTlsConfig(connConfig.getTlsConfiguration());
    factory.setSerializationFactory(serializationFactory);
    factory.setDeserializationFactory(deserializationFactory);
    factory.setUseBarrier(connConfig.useBarrier());
    factory.setChannelOutboundQueueSize(connConfig.getChannelOutboundQueueSize());
    final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol();
    // Check if Epoll native transport is available.
    // TODO : Add option to disable Epoll.
    boolean isEpollEnabled = Epoll.isAvailable();
    if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
        server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
        final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
        ((TcpHandler) server).setChannelInitializer(channelInitializer);
        ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
        final EventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup();
        connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled);
        connectionInitializer.setChannelInitializer(channelInitializer);
        connectionInitializer.run();
    } else if (TransportProtocol.UDP.equals(transportProtocol)) {
        server = new UdpHandler(connConfig.getAddress(), connConfig.getPort());
        ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
        ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
    } else {
        throw new IllegalStateException("Unknown transport protocol received: " + transportProtocol);
    }
    server.setThreadConfig(connConfig.getThreadConfiguration());
    return server;
}
Also used : EventLoopGroup(io.netty.channel.EventLoopGroup) TransportProtocol(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol)

Aggregations

EventLoopGroup (io.netty.channel.EventLoopGroup)1 TransportProtocol (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol)1