当前位置: 首页>>代码示例>>Java>>正文


Java NioUdtProvider类代码示例

本文整理汇总了Java中io.netty.channel.udt.nio.NioUdtProvider的典型用法代码示例。如果您正苦于以下问题:Java NioUdtProvider类的具体用法?Java NioUdtProvider怎么用?Java NioUdtProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NioUdtProvider类属于io.netty.channel.udt.nio包,在下文中一共展示了NioUdtProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public void run() throws Exception {
    final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
            connectFactory, NioUdtProvider.BYTE_PROVIDER);
    try {
        final Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(connectGroup)
                .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    protected void initChannel(UdtChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new ByteEchoPeerHandler(messageSize));
                    }
                });
        final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
        future.channel().closeFuture().sync();
    } finally {
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:23,代码来源:ByteEchoPeerBase.java

示例2: provideFactory

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
/**
 * verify factory
 */
@Test
public void provideFactory() {
    // bytes
    assertNotNull(NioUdtProvider.BYTE_ACCEPTOR.newChannel());
    assertNotNull(NioUdtProvider.BYTE_CONNECTOR.newChannel());
    assertNotNull(NioUdtProvider.BYTE_RENDEZVOUS.newChannel());

    // message
    assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel());
    assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel());
    assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel());

    // acceptor types
    assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel() instanceof UdtServerChannel);
    assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel() instanceof UdtServerChannel);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:20,代码来源:NioUdtProviderTest.java

示例3: run

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public void run() throws Exception {
    final ThreadFactory connectFactory = new UtilThreadFactory("rendezvous");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
            connectFactory, NioUdtProvider.BYTE_PROVIDER);
    try {
        final Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(connectGroup)
                .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    protected void initChannel(UdtChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new ByteEchoPeerHandler(messageSize));
                    }
                });
        final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
        future.channel().closeFuture().sync();
    } finally {
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:23,代码来源:ByteEchoPeerBase.java

示例4: provideFactory

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
/**
 * verify factory
 */
@Test
public void provideFactory() {

    EventLoop loop = new NioEventLoopGroup().next();
    EventLoopGroup childGroup = new NioEventLoopGroup();

    // bytes
    assertNotNull(NioUdtProvider.BYTE_ACCEPTOR.newChannel(loop, childGroup));
    assertNotNull(NioUdtProvider.BYTE_CONNECTOR.newChannel(loop));
    assertNotNull(NioUdtProvider.BYTE_RENDEZVOUS.newChannel(loop));

    // message
    assertNotNull(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel(loop, childGroup));
    assertNotNull(NioUdtProvider.MESSAGE_CONNECTOR.newChannel(loop));
    assertNotNull(NioUdtProvider.MESSAGE_RENDEZVOUS.newChannel(loop));

    // acceptor types
    assertTrue(NioUdtProvider.BYTE_ACCEPTOR.newChannel(loop, childGroup) instanceof UdtServerChannel);
    assertTrue(NioUdtProvider.MESSAGE_ACCEPTOR.newChannel(loop, childGroup) instanceof UdtServerChannel);
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:24,代码来源:NioUdtProviderTest.java

示例5: getChannelFactory

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
@Override
public ChannelFactory<? extends Channel> getChannelFactory() {
    if (CC.mp.net.tcpGateway()) return super.getChannelFactory();
    if (CC.mp.net.udtGateway()) return NioUdtProvider.BYTE_CONNECTOR;
    if (CC.mp.net.sctpGateway()) return NioSctpChannel::new;
    return super.getChannelFactory();
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:8,代码来源:GatewayClient.java

示例6: getSelectorProvider

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
@Override
public SelectorProvider getSelectorProvider() {
    if (CC.mp.net.tcpGateway()) return super.getSelectorProvider();
    if (CC.mp.net.udtGateway()) return NioUdtProvider.BYTE_PROVIDER;
    if (CC.mp.net.sctpGateway()) return super.getSelectorProvider();
    return super.getSelectorProvider();
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:8,代码来源:GatewayClient.java

示例7: getChannelFactory

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
@Override
public ChannelFactory<? extends ServerChannel> getChannelFactory() {
    if (CC.mp.net.tcpGateway()) return super.getChannelFactory();
    if (CC.mp.net.udtGateway()) return NioUdtProvider.BYTE_ACCEPTOR;
    if (CC.mp.net.sctpGateway()) return NioSctpServerChannel::new;
    return super.getChannelFactory();
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:8,代码来源:GatewayServer.java

示例8: main

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        // Configure the client.
        final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
        final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
                connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
        try {
            final Bootstrap boot = new Bootstrap();
            boot.group(connectGroup)
                    .channelFactory(NioUdtProvider.MESSAGE_CONNECTOR)
                    .handler(new ChannelInitializer<UdtChannel>() {
                        @Override
                        public void initChannel(final UdtChannel ch)
                                throws Exception {
                            ch.pipeline().addLast(
                                    new LoggingHandler(LogLevel.INFO),
                                    new MsgEchoClientHandler());
                        }
                    });
            // Start the client.
            final ChannelFuture f = boot.connect(HOST, PORT).sync();
            // Wait until the connection is closed.
            f.channel().closeFuture().sync();
        } finally {
            // Shut down the event loop to terminate all threads.
            connectGroup.shutdownGracefully();
        }
    }
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:29,代码来源:MsgEchoClient.java

示例9: main

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final ThreadFactory acceptFactory = new DefaultThreadFactory("accept");
    final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
    final NioEventLoopGroup acceptGroup =
            new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER);
    final NioEventLoopGroup connectGroup =
            new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER);

    // Configure the server.
    try {
        final ServerBootstrap boot = new ServerBootstrap();
        boot.group(acceptGroup, connectGroup)
                .channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR)
                .option(ChannelOption.SO_BACKLOG, 10)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    public void initChannel(final UdtChannel ch)
                            throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new MsgEchoServerHandler());
                    }
                });
        // Start the server.
        final ChannelFuture future = boot.bind(PORT).sync();
        // Wait until the server socket is closed.
        future.channel().closeFuture().sync();
    } finally {
        // Shut down all event loops to terminate all threads.
        acceptGroup.shutdownGracefully();
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:35,代码来源:MsgEchoServer.java

示例10: main

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure the client.
    final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
            connectFactory, NioUdtProvider.BYTE_PROVIDER);
    try {
        final Bootstrap boot = new Bootstrap();
        boot.group(connectGroup)
                .channelFactory(NioUdtProvider.BYTE_CONNECTOR)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    public void initChannel(final UdtChannel ch)
                            throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new ByteEchoClientHandler());
                    }
                });
        // Start the client.
        final ChannelFuture f = boot.connect(HOST, PORT).sync();
        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:28,代码来源:ByteEchoClient.java

示例11: main

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final ThreadFactory acceptFactory = new DefaultThreadFactory("accept");
    final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
    final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.BYTE_PROVIDER);
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.BYTE_PROVIDER);

    // Configure the server.
    try {
        final ServerBootstrap boot = new ServerBootstrap();
        boot.group(acceptGroup, connectGroup)
                .channelFactory(NioUdtProvider.BYTE_ACCEPTOR)
                .option(ChannelOption.SO_BACKLOG, 10)
                .handler(new LoggingHandler(LogLevel.INFO))
                .childHandler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    public void initChannel(final UdtChannel ch)
                            throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new ByteEchoServerHandler());
                    }
                });
        // Start the server.
        final ChannelFuture future = boot.bind(PORT).sync();
        // Wait until the server socket is closed.
        future.channel().closeFuture().sync();
    } finally {
        // Shut down all event loops to terminate all threads.
        acceptGroup.shutdownGracefully();
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:33,代码来源:ByteEchoServer.java

示例12: run

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
public void run() throws Exception {
    // Configure the peer.
    final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
            connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
    try {
        final Bootstrap boot = new Bootstrap();
        boot.group(connectGroup)
                .channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    public void initChannel(final UdtChannel ch)
                            throws Exception {
                        ch.pipeline().addLast(
                                new LoggingHandler(LogLevel.INFO),
                                new MsgEchoPeerHandler(messageSize));
                    }
                });
        // Start the peer.
        final ChannelFuture f = boot.connect(peer, self).sync();
        // Wait until the connection is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down the event loop to terminate all threads.
        connectGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:28,代码来源:MsgEchoPeerBase.java

示例13: execute

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
@Override
protected Future<?> execute() {
    Bootstrap cb = new Bootstrap().group(proxyServer.getProxyToServerWorkerFor(transportProtocol));

    switch (transportProtocol) {
    case TCP:
        LOG.debug("Connecting to server with TCP");
        cb.channelFactory(new ChannelFactory<Channel>() {
            @Override
            public Channel newChannel() {
                return new NioSocketChannel();
            }
        });
        break;
    case UDT:
        LOG.debug("Connecting to server with UDT");
        cb.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
                .option(ChannelOption.SO_REUSEADDR, true);
        break;
    default:
        throw new UnknownTransportProtocolException(transportProtocol);
    }

    cb.handler(new ChannelInitializer<Channel>() {
        protected void initChannel(Channel ch) throws Exception {
            initChannelPipeline(ch.pipeline(), initialRequest);
        };
    });
    cb.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
            proxyServer.getConnectTimeout());

    if (localAddress != null) {
        return cb.connect(remoteAddress, localAddress);
    } else {
        return cb.connect(remoteAddress);
    }
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:38,代码来源:ProxyToServerConnection.java

示例14: isUdtAvailable

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
/**
 * Determines if UDT is available on the classpath.
 *
 * @return true if UDT is available
 */
public static boolean isUdtAvailable() {
    try {
        return NioUdtProvider.BYTE_PROVIDER != null;
    } catch (NoClassDefFoundError e) {
        return false;
    }
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:13,代码来源:ProxyUtils.java

示例15: execute

import io.netty.channel.udt.nio.NioUdtProvider; //导入依赖的package包/类
@Override
protected Future<?> execute() {
    Bootstrap cb = new Bootstrap().group(proxyServer
            .getProxyToServerWorkerFor(transportProtocol));

    switch (transportProtocol) {
    case TCP:
        LOG.debug("Connecting to server with TCP");
        cb.channelFactory(new ChannelFactory<Channel>() {
            @Override
            public Channel newChannel() {
                return new NioSocketChannel();
            }
        });
        break;
    case UDT:
        LOG.debug("Connecting to server with UDT");
        cb.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
                .option(ChannelOption.SO_REUSEADDR, true);
        break;
    default:
        throw new UnknownTransportProtocolError(transportProtocol);
    }

    cb.handler(new ChannelInitializer<Channel>() {
        protected void initChannel(Channel ch) throws Exception {
            initChannelPipeline(ch.pipeline(), initialRequest);
        };
    });
    cb.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
            proxyServer.getConnectTimeout());

    if (localAddress != null) {
        return cb.connect(remoteAddress, localAddress);
    } else {
        return cb.connect(remoteAddress);
    }
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:39,代码来源:ProxyToServerConnection.java


注:本文中的io.netty.channel.udt.nio.NioUdtProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。