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


Java OioEventLoopGroup类代码示例

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


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

示例1: main

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static void main(String[] args)
{
	Executor executor = Executors.newFixedThreadPool(200);
	ServerBootstrap bootstrap = new ServerBootstrap();
	EventLoopGroup bossGroup = new OioEventLoopGroup();
	EventLoopGroup childGroup = new OioEventLoopGroup();
	bootstrap.group(bossGroup, childGroup);
	bootstrap.channel(OioServerSocketChannel.class);

	bootstrap.childHandler(new RPCServerSessionPipelineFactory(
			new RPCServerMixinPipelineFactory(executor, childGroup)));

	// Bind and start to accept incoming connections.
	bootstrap.bind(new InetSocketAddress(8080));

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:17,代码来源:Server.java

示例2: init

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public void init(ChannelPipelineFactory factory) throws Exception
{
	id = String.format("%1$020d",
			Math.abs(new Random(System.currentTimeMillis()).nextLong()))
			.getBytes();

	group = new OioEventLoopGroup();
	connectionlessBootstrap = new Bootstrap();
	connectionlessBootstrap.group(group);
	connectionlessBootstrap.option(ChannelOption.SO_BROADCAST, true);
	connectionlessBootstrap.handler(factory);
	connectionlessBootstrap.channel(OioDatagramChannel.class);
	;
	datagramChannel = (DatagramChannel) connectionlessBootstrap
			.bind(new InetSocketAddress(mcastGroupPort)).sync().channel();
	multicastAddress = new InetSocketAddress(mcastGroupIp, mcastGroupPort);
	NetworkInterface networkInterface = NetworkInterface
			.getByInetAddress(InetAddress.getByName(bindAddress));
	// for (Enumeration nifs = NetworkInterface.getNetworkInterfaces();
	// nifs.hasMoreElements(); )
	datagramChannel.joinGroup(multicastAddress, null);// (NetworkInterface)
														// nifs.nextElement());
	init = true;
	if (debug)
		factory.debug();
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:27,代码来源:MulticastEndpoint.java

示例3: JVMController

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
/**
 * Instantiates a new controller.
 * 
 * @param wrappedJavaProcess
 *            the wrapped java process
 */
public JVMController(WrappedProcess wrappedJavaProcess)
{
	super(wrappedJavaProcess);
	_bossGroup = new OioEventLoopGroup();
	_workerGroup = new OioEventLoopGroup();
	ControllerPipelineFactory pipelineFactory = new ControllerPipelineFactory(
			this);

	setDebug(((WrappedJavaProcess)wrappedJavaProcess).getDebug());
	pipelineFactory.setDebug(_debug > 2);
	_acceptor = new ServerBootstrap().group(_bossGroup, _workerGroup)
			.channel(OioServerSocketChannel.class)
			.childOption(ChannelOption.TCP_NODELAY, true)
			// .option(ChannelOption.SO_BACKLOG, 128)
			.childHandler(pipelineFactory);

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:24,代码来源:JVMController.java

示例4: main

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    EventLoopGroup group = new OioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
         .channel(RxtxChannel.class)
         .handler(new ChannelInitializer<RxtxChannel>() {
             @Override
             public void initChannel(RxtxChannel ch) throws Exception {
                 ch.pipeline().addLast(
                     new LineBasedFrameDecoder(32768),
                     new StringEncoder(),
                     new StringDecoder(),
                     new RxtxClientHandler()
                 );
             }
         });

        ChannelFuture f = b.connect(new RxtxDeviceAddress(PORT)).sync();

        f.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:26,代码来源:RxtxClient.java

示例5: main

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    EventLoopGroup bossGroup = new OioEventLoopGroup(1);
    EventLoopGroup workerGroup = new OioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
        .channel(OioServerSocketChannel.class)
        .childHandler(new ChannelInitializer<SocketChannel>() {
           @Override
           public void initChannel(SocketChannel ch) {
               ChannelPipeline p = ch.pipeline();
               p.addLast(new EchoServerHandler());
           }
        });

        ChannelFuture f = b.bind(8888).sync();

        f.channel().closeFuture().sync();
    }
    finally {
        workerGroup.shutdownGracefully();
        bossGroup.shutdownGracefully();
    }
}
 
开发者ID:krisjey,项目名称:netty.book.kor,代码行数:25,代码来源:BlockingEchoServer.java

示例6: main

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    EventLoopGroup group = new OioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
                .channel(RxtxChannel.class)
                .handler(new ChannelInitializer<RxtxChannel>() {
                    @Override
                    public void initChannel(RxtxChannel ch) throws Exception {
                        ch.pipeline().addLast(
                                new LineBasedFrameDecoder(32768),
                                new StringEncoder(),
                                new StringDecoder(),
                                new RxtxClientHandler()
                        );
                    }
                });

        ChannelFuture f = b.connect(new RxtxDeviceAddress(PORT)).sync();

        f.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully();
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:26,代码来源:RxtxClient.java

示例7: main

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    EventLoopGroup group = new OioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
         .channel(RxtxChannel.class)
         .handler(new ChannelInitializer<RxtxChannel>() {
             @Override
             public void initChannel(RxtxChannel ch) throws Exception {
                 ch.pipeline().addLast(
                     new LineBasedFrameDecoder(32768),
                     new StringEncoder(),
                     new StringDecoder(),
                     new RxtxClientHandler()
                 );
             }
         });

        ChannelFuture f = b.connect(new RxtxDeviceAddress("/dev/ttyUSB0")).sync();

        f.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully();
    }
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:26,代码来源:RxtxClient.java

示例8: createBootstrap

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static Bootstrap createBootstrap(final ChannelType channelType) throws UnsupportedOperationException {
    Bootstrap bootstrap = new Bootstrap();

    switch (channelType) {
        case NIO:
        
            bootstrap.group(new NioEventLoopGroup());
            bootstrap.channel(NioSocketChannel.class);
            return bootstrap;

        case OIO:
 
            bootstrap.group(new OioEventLoopGroup());
            bootstrap.channel(OioSocketChannel.class);
            return bootstrap;

        default:
            throw new UnsupportedOperationException("Failed to create Bootstrap,  " + channelType + " not supported!");
    }
}
 
开发者ID:desperado1992,项目名称:distributeTemplate,代码行数:21,代码来源:BootstrapFactory.java

示例9: createUDPBootstrap

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static Bootstrap createUDPBootstrap(final ChannelType channelType) throws UnsupportedOperationException {
    Bootstrap bootstrap = new Bootstrap();

    switch (channelType) {
        case NIO:
        	
            bootstrap.group(new NioEventLoopGroup());
            bootstrap.channel(NioDatagramChannel.class);
            return bootstrap;

        case OIO:
        	
            bootstrap.group(new OioEventLoopGroup());
            bootstrap.channel(OioDatagramChannel.class);
            return bootstrap;

        default:
            throw new UnsupportedOperationException("Failed to create Bootstrap,  " + channelType + " not supported!");
    }
}
 
开发者ID:desperado1992,项目名称:distributeTemplate,代码行数:21,代码来源:BootstrapFactory.java

示例10: createServerBootstrap

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static Bootstrap createServerBootstrap(final ChannelType channelType) throws UnsupportedOperationException {
    
	Bootstrap serverBootstrap = new Bootstrap();

    switch (channelType) {
        case NIO:
            serverBootstrap.group(new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()));
            serverBootstrap.channel(NioDatagramChannel.class);
           // serverBootstrap.localAddress(new InetSocketAddress(port))
           // .handler(packetHandler);
          
            return serverBootstrap;

        case OIO:
        	 serverBootstrap.group(new OioEventLoopGroup(Runtime.getRuntime().availableProcessors()));
             serverBootstrap.channel(OioDatagramChannel.class);
          
            
            return serverBootstrap;

        default:
            throw new UnsupportedOperationException("Failed to create ServerBootstrap,  " + channelType + " not supported!");
    }
}
 
开发者ID:desperado1992,项目名称:distributeTemplate,代码行数:25,代码来源:ServerUDPBootstrapFactory.java

示例11: createServerBootstrap

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public static ServerBootstrap createServerBootstrap(ChannelType channelType,boolean isUDP) throws UnsupportedOperationException {
    
	ServerBootstrap serverBootstrap = new ServerBootstrap();

    switch (channelType) {
        case NIO:
            serverBootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup());
            serverBootstrap.channel(NioServerSocketChannel.class);
            return serverBootstrap;

        case OIO:
            serverBootstrap.group(new OioEventLoopGroup(), new OioEventLoopGroup());
            serverBootstrap.channel(OioServerSocketChannel.class);
            return serverBootstrap;

        default:
            throw new UnsupportedOperationException("Failed to create ServerBootstrap,  " + channelType + " not supported!");
    }
}
 
开发者ID:desperado1992,项目名称:distributeTemplate,代码行数:20,代码来源:ServerBootstrapFactory.java

示例12: start

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public void start() {
        apiBootstrap = new ServerBootstrap();
        try {
            // the hub will only have a few connections, so OIO is likely to be faster than NIO in this case!
            ThreadFactory threadFactory = new NamedThreadFactory("kha-rest-api");
            EventLoopGroup commonGroup = new OioEventLoopGroup(0, threadFactory);
            apiBootstrap.group(commonGroup, commonGroup)
                    .channel(OioServerSocketChannel.class)
                    .localAddress(port)
                    .childOption(ChannelOption.SO_KEEPALIVE, true)
                    .childHandler(channelInitializer);

            apiBootstrap.bind();
//            ChannelFuture f = apiBootstrap.bind().sync();
            LOGGER.info("REST API available on http://{}:{}", InetAddress.getLocalHost().getCanonicalHostName(), port);
            LOGGER.info("WebSockets API available on ws://{}:{}", InetAddress.getLocalHost().getCanonicalHostName(), port);
//            f.channel().closeFuture().sync();
        } catch (Exception e) {
            LOGGER.error("Can't start API server", e);
        }
    }
 
开发者ID:kalixia,项目名称:kha,代码行数:22,代码来源:ApiServer.java

示例13: SimpleLineBasedSerialChannel

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
public SimpleLineBasedSerialChannel(String port, final SimpleStringChannelHandler stringHandler) {
	group = new OioEventLoopGroup();
       Bootstrap b = new Bootstrap();
       b.group(group)
        .channel(JsscChannel.class)
        .handler(new ChannelInitializer<JsscChannel>() {
            @Override
            public void initChannel(JsscChannel ch) throws Exception {
                ch.pipeline().addLast(
                    new LineBasedFrameDecoder(Integer.MAX_VALUE),
                    new StringDecoder(),
                    new SimpleChannelInboundHandler<String>() {
                   	 @Override
                   	 protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, String msg) throws Exception {
                   		stringHandler.channelRead(ctx, msg); 
                   	 }
				 }
                );
            }
        });

        f = b.connect(new JsscDeviceAddress(port)).syncUninterruptibly();
}
 
开发者ID:jkschneider,项目名称:netty-jssc,代码行数:24,代码来源:SimpleLineBasedSerialChannel.java

示例14: initializeBeacon

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
/**
 * Initializes a new UDPMulticastBeacon.
 * 
 * @param serverConfig
 *            a configuration to use for initializing
 * @return the new UDPMulticastBeacon
 */
private UDPMulticastBeacon initializeBeacon(final AddressBasedServerConfig serverConfig) {
	LOGGER.entry();
	final OioEventLoopGroup networkEventLoopGroup = new OioEventLoopGroup();
	eventExecutorGroups.add(networkEventLoopGroup);

	final UDPMulticastBeacon beacon =
			new UDPMulticastBeacon(OIO_DATAGRAM_CHANNEL_FACTORY, networkEventLoopGroup, scheduledExecutorService,
					serverConfig.getModuleID(), serverConfig.getAnnounceInterval(), TimeUnit.SECONDS);
	beacon.addListener((TCPConnectionManager) getConnectionManager());
	beacon.setAnnounceAddresses(new ArrayList<InetSocketAddress>(serverConfig.getAnnounceAddresses()));

	for (final NetConnection netConnection : serverConfig.getMulticastAddresses()) {
		LOGGER.debug("adding address {} to beacon", netConnection);
		beacon.addAddress(netConnection.getInterface(), netConnection.getAddress());
	}

	return LOGGER.exit(beacon);
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:26,代码来源:TCPUDPServerManager.java

示例15: getServerSocketChannelClass

import io.netty.channel.oio.OioEventLoopGroup; //导入依赖的package包/类
/**
 * Returns a server socket channel class suitable for specified event loop group.
 *
 * @param eventLoopGroup the event loop group for which to identify an appropriate socket channel class; must not
 * be {@code null}
 *
 * @return a server socket channel class suitable for use with the given event loop group
 *
 * @throws IllegalArgumentException in case of null or unrecognized event loop group
 */
@SuppressWarnings("unchecked")
static Class<? extends ServerChannel> getServerSocketChannelClass(final EventLoopGroup eventLoopGroup) {
    Objects.requireNonNull(eventLoopGroup);

    final Class<? extends ServerChannel> serverSocketChannelClass;

    if (eventLoopGroup instanceof NioEventLoopGroup) {
        serverSocketChannelClass = NioServerSocketChannel.class;
    } else if (eventLoopGroup instanceof OioEventLoopGroup) {
        serverSocketChannelClass = OioServerSocketChannel.class;
    } else if (EPOLL_EVENT_LOOP_GROUP_CLASS.equals(eventLoopGroup.getClass().getName())) {
        serverSocketChannelClass = (Class<? extends ServerChannel>) loadSocketChannelClass(EPOLL_SERVER_SOCKET_CHANNEL_CLASS);
    } else if (KQUEUE_EVENT_LOOP_GROUP_CLASS.equals(eventLoopGroup.getClass().getName())) {
        serverSocketChannelClass = (Class<? extends ServerChannel>) loadSocketChannelClass(KQUEUE_SERVER_SOCKET_CHANNEL_CLASS);
    } else {
        throw new IllegalArgumentException("Could not find server socket class for event loop group class: " + eventLoopGroup.getClass().getName());
    }

    return serverSocketChannelClass;
}
 
开发者ID:relayrides,项目名称:pushy,代码行数:31,代码来源:ServerSocketChannelClassUtil.java


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