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


Java OioDatagramChannelFactory类代码示例

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


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

示例1: start

import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; //导入依赖的package包/类
@Override
public void start() {
  // setup Netty server
  ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap(
      new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
  final syslogHandler handler = new syslogHandler();
  handler.setFormater(formaterProp);
  handler.setKeepFields(keepFields);
  serverBootstrap.setOption("receiveBufferSizePredictorFactory",
      new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE,
          DEFAULT_INITIAL_SIZE, maxsize));
  serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() {
      return Channels.pipeline(handler);
    }
  });

  if (host == null) {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(port));
  } else {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port));
  }

  sourceCounter.start();
  super.start();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:28,代码来源:SyslogUDPSource.java

示例2: connect

import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; //导入依赖的package包/类
@Override
public void connect(Configuration conf) throws IOException {
  // Can't be NiO with Netty today => not implemented in Netty.
  DatagramChannelFactory f = new OioDatagramChannelFactory(service);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
      new ProtobufDecoder(ClusterStatusProtos.ClusterStatus.getDefaultInstance()),
      new ClusterStatusHandler()));

  String mcAddress = conf.get(HConstants.STATUS_MULTICAST_ADDRESS,
      HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
  String bindAddress = conf.get(HConstants.STATUS_MULTICAST_BIND_ADDRESS,
    HConstants.DEFAULT_STATUS_MULTICAST_BIND_ADDRESS);
  int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,
      HConstants.DEFAULT_STATUS_MULTICAST_PORT);

  channel = (DatagramChannel) b.bind(new InetSocketAddress(bindAddress, port));

  channel.getConfig().setReuseAddress(true);

  InetAddress ina;
  try {
    ina = InetAddress.getByName(mcAddress);
  } catch (UnknownHostException e) {
    throw new IOException("Can't connect to " + mcAddress, e);
  }
  channel.joinGroup(ina);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:ClusterStatusListener.java

示例3: start

import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; //导入依赖的package包/类
/**
   * Start sending DHCPv6 SOLICITs.
   */
  public void start()
  {
  	DatagramChannelFactory factory = 
  		new OioDatagramChannelFactory(Executors.newCachedThreadPool());
  	
  	server = new InetSocketAddress(serverAddr, serverPort);
  	client = new InetSocketAddress(clientPort);
  	
ChannelPipeline pipeline = Channels.pipeline();
      pipeline.addLast("logger", new LoggingHandler());
      pipeline.addLast("encoder", new DhcpV6ChannelEncoder());
      pipeline.addLast("decoder", new DhcpV6ChannelDecoder(client, false));
      pipeline.addLast("executor", new ExecutionHandler(
      		new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
      pipeline.addLast("handler", this);
  	
      channel = factory.newChannel(pipeline);
channel.getConfig().setNetworkInterface(mcastNetIf);
  	channel.bind(client);

  	for (int i=1; i<=numRequests; i++) {
  		executor.execute(new ClientMachine(i));
  	}

  	synchronized (syncDone) {
  		long ms = timeout * 1000;
      	try {
      		log.info("Waiting total of " + timeout + " milliseconds for completion");
      		syncDone.wait(ms);
      	}
      	catch (InterruptedException ex) {
      		log.error("Interrupted", ex);
      	}
}

log.info("Complete: solicitsSent=" + solicitsSent +
		" advertisementsReceived=" + advertisementsReceived +
		" requestsSent=" + requestsSent +
		" requestRepliesReceived=" + requestRepliesReceived +
		" releasesSent=" + releasesSent +
		" releaseRepliesReceived=" + releaseRepliesReceived +
		" elapsedTime=" + (endTime - startTime) + "ms");

  	log.info("Shutting down executor...");
  	executor.shutdownNow();
  	log.info("Closing channel...");
  	channel.close();
  	log.info("Done.");
  	if ((solicitsSent.get() == advertisementsReceived.get()) &&
  			(requestsSent.get() == requestRepliesReceived.get()) &&
  			(releasesSent.get() == releaseRepliesReceived.get())) {
  		
  		System.exit(0);
  	}
  	else {
  		System.exit(1);
  	}
  }
 
开发者ID:jagornet,项目名称:dhcp,代码行数:62,代码来源:ClientSimulatorV6.java


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