Exemplo n.º 1
0
  public static void main(final String[] args) throws Exception {

    log.info("init");
    TrafficControl.delay(0);

    final AtomicBoolean isOn = new AtomicBoolean(true);

    final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
    final InetSocketAddress addr2 = UnitHelp.localSocketAddress();

    final ChannelHandler handler1 = new EchoMessageHandler(rate, size);
    final ChannelHandler handler2 = new EchoMessageHandler(null, size);

    final Bootstrap peerBoot1 = BootHelp.messagePeerBoot(addr1, addr2, handler1);
    final Bootstrap peerBoot2 = BootHelp.messagePeerBoot(addr2, addr1, handler2);

    final ChannelFuture peerFuture1 = peerBoot1.connect();
    final ChannelFuture peerFuture2 = peerBoot2.connect();

    CustomReporter.enable(3, TimeUnit.SECONDS);

    Thread.sleep(time);

    isOn.set(false);

    Thread.sleep(1000);

    peerFuture1.channel().close().sync();
    peerFuture2.channel().close().sync();

    Thread.sleep(1000);

    peerBoot1.shutdown();
    peerBoot2.shutdown();

    Metrics.defaultRegistry().shutdown();

    TrafficControl.delay(0);
    log.info("done");
  }
Exemplo n.º 2
0
 /** UDT test assumptions. */
 @BeforeClass
 public static void assumeConditions() {
   assumeTrue(UnitHelp.canLoadAndInitClass("com.barchart.udt.SocketUDT"));
 }