java类org.jboss.netty.channel.socket.DatagramChannelFactory的实例源码

SimpleUdpServer.java 文件源码 项目:hadoop 阅读 34 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  server = new ConnectionlessBootstrap(f);
  server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  server.setOption("broadcast", "false");
  server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  ch = server.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:aliyun-oss-hadoop-fs 阅读 29 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  server = new ConnectionlessBootstrap(f);
  server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  server.setOption("broadcast", "false");
  server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  ch = server.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:big-c 阅读 33 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  server = new ConnectionlessBootstrap(f);
  server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  server.setOption("broadcast", "false");
  server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  ch = server.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:hadoop-2.6.0-cdh5.4.3 阅读 36 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  Channel ch = b.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:hadoop-plus 阅读 25 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  ChannelPipeline p = b.getPipeline();
  p.addLast("handler", new SimpleUdpServerHandler(rpcProgram));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  b.bind(new InetSocketAddress(port));

  LOG.info("Started listening to UDP requests at port " + port + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:hops 阅读 26 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  server = new ConnectionlessBootstrap(f);
  server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  server.setOption("broadcast", "false");
  server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  ch = server.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:hadoop-TCP 阅读 31 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  b.bind(new InetSocketAddress(port));

  LOG.info("Started listening to UDP requests at port " + port + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
NettyUdpReceiverTest.java 文件源码 项目:pinpoint 阅读 25 收藏 0 点赞 0 评论 0
private ConnectionlessBootstrap createUdpServer() {
        DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4);
        ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() throws Exception {
                ChannelPipeline pipeline = Channels.pipeline();
                pipeline.addLast("test", new SimpleChannelHandler() {
                    @Override
                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
                        String name = Thread.currentThread().getName();
                        logger.debug("sleep:{}", name);
                        Thread.sleep(10000);
//                        if (!name.equals("New I/O worker #1")) {
                            logger.debug("messageReceived thread-{} message:", Thread.currentThread().getName());
//                        }
                    }
                });
                return pipeline;
            }
        };
        ConnectionlessBootstrap udpBootstrap = new ConnectionlessBootstrap(udpFactory);
        udpBootstrap.setPipelineFactory(pipelineFactory);
        return udpBootstrap;
    }
SimpleUdpServer.java 文件源码 项目:hardfs 阅读 37 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  b.bind(new InetSocketAddress(port));

  LOG.info("Started listening to UDP requests at port " + port + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
SimpleUdpServer.java 文件源码 项目:hadoop-on-lustre2 阅读 31 收藏 0 点赞 0 评论 0
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  Channel ch = b.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
UdpMeta.java 文件源码 项目:parallec 阅读 35 收藏 0 点赞 0 评论 0
public UdpMeta(String command, int udpPort, int udpIdleTimeoutSec,
        DatagramChannelFactory channelFactory) {
    super();
    this.command = command;
    this.udpPort = udpPort;
    this.udpIdleTimeoutSec = udpIdleTimeoutSec;
    this.channelFactory = channelFactory;

}
ClusterStatusListener.java 文件源码 项目:HIndex 阅读 35 收藏 0 点赞 0 评论 0
@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);
}
ClusterStatusListener.java 文件源码 项目:c5 阅读 33 收藏 0 点赞 0 评论 0
@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);
}
TcpUdpSshPingResourceStore.java 文件源码 项目:parallec 阅读 28 收藏 0 点赞 0 评论 0
public DatagramChannelFactory getDatagramChannelFactory() {
    return datagramChannelFactory;
}
TcpUdpSshPingResourceStore.java 文件源码 项目:parallec 阅读 33 收藏 0 点赞 0 评论 0
public void setDatagramChannelFactory(DatagramChannelFactory datagramChannelFactory) {
    this.datagramChannelFactory = datagramChannelFactory;
}
UdpMeta.java 文件源码 项目:parallec 阅读 31 收藏 0 点赞 0 评论 0
public void setChannelFactory(DatagramChannelFactory channelFactory) {
    this.channelFactory = channelFactory;
}
ClientSimulatorV6.java 文件源码 项目:dhcp 阅读 58 收藏 0 点赞 0 评论 0
/**
   * 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);
    }
  }
ClientSimulatorV4.java 文件源码 项目:dhcp 阅读 27 收藏 0 点赞 0 评论 0
/**
   * Start sending DHCPv4 DISCOVERs.
   */
  public void start()
  {
    DatagramChannelFactory factory = 
        new NioDatagramChannelFactory(Executors.newCachedThreadPool());

    server = new InetSocketAddress(serverAddr, serverPort);
    client = new InetSocketAddress(clientPort);

ChannelPipeline pipeline = Channels.pipeline();
      pipeline.addLast("logger", new LoggingHandler());
      pipeline.addLast("encoder", new DhcpV4ChannelEncoder());
      pipeline.addLast("decoder", new DhcpV4ChannelDecoder(client, false));
      pipeline.addLast("executor", new ExecutionHandler(
            new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
      pipeline.addLast("handler", this);

      channel = factory.newChannel(pipeline);
    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: discoversSent=" + discoversSent +
        " offersReceived=" + offersReceived +
        " requestsSent=" + requestsSent +
        " acksReceived=" + acksReceived +
        " releasesSent=" + releasesSent +
        " elapsedTime=" + (endTime - startTime) + "ms");

    log.info("Shutting down executor...");
    executor.shutdownNow();
    log.info("Closing channel...");
    channel.close();
    log.info("Done.");
    if ((discoversSent.get() == offersReceived.get()) &&
            (requestsSent.get() == acksReceived.get()) &&
            (releasesSent.get() == numRequests)) {

        System.exit(0);
    }
    else {
        System.exit(1);
    }
  }
SipServer.java 文件源码 项目:elasterix 阅读 24 收藏 0 点赞 0 评论 0
public void setDatagramChannelFactory(DatagramChannelFactory datagramChannelFactory) {
    this.datagramChannelFactory = datagramChannelFactory;
}


问题


面经


文章

微信
公众号

扫码关注公众号