Package org.apache.flink.runtime.io.network.netty

Examples of org.apache.flink.runtime.io.network.netty.NettyConnectionManager


    // --------------------------------------------------------------------
    ChannelManager channelManager = mock(ChannelManager.class);
    doAnswer(new VerifyEnvelopes(latch, numToSendPerSubtask))
        .when(channelManager).dispatchFromNetwork(Matchers.<Envelope>anyObject());

    final NettyConnectionManager senderConnManager = new NettyConnectionManager(localhost, BIND_PORT, BUFFER_SIZE,
        numInThreads, numOutThreads, -1, -1);
    senderConnManager.start(channelManager);

    NettyConnectionManager receiverConnManager = new NettyConnectionManager(localhost, BIND_PORT + 1, BUFFER_SIZE,
        numInThreads, numOutThreads, -1, -1);
    receiverConnManager.start(channelManager);

    // --------------------------------------------------------------------
    // start sender threads
    // --------------------------------------------------------------------
    RemoteReceiver[] receivers = new RemoteReceiver[numChannels];

    for (int i = 0; i < numChannels; i++) {
      receivers[i] = new RemoteReceiver(new InetSocketAddress(localhost, BIND_PORT + 1), i);
    }

    for (int i = 0; i < numSubtasks; i++) {
      final RemoteReceiver receiver = receivers[random.nextInt(numChannels)];

      final AtomicInteger seqNum = new AtomicInteger(0);
      final JobID jobId = new JobID();
      final ChannelID channelId = new ChannelID();

      new Thread(new Runnable() {
        @Override
        public void run() {
          // enqueue envelopes with ascending seq numbers
          while (seqNum.get() < numToSendPerSubtask) {
            try {
              Envelope env = new Envelope(seqNum.getAndIncrement(), jobId, channelId);
              senderConnManager.enqueue(env, receiver);
            } catch (IOException e) {
              throw new RuntimeException("Unexpected exception while enqueuing envelope.");
            }
          }
        }
      }).start();
    }

    latch.await();

    senderConnManager.shutdown();
    receiverConnManager.shutdown();
  }
View Full Code Here


              ConfigConstants.DEFAULT_TASK_MANAGER_NET_NETTY_LOW_WATER_MARK);
 
          int highWaterMark = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_NET_NETTY_HIGH_WATER_MARK,
              ConfigConstants.DEFAULT_TASK_MANAGER_NET_NETTY_HIGH_WATER_MARK);
 
          networkConnectionManager = new NettyConnectionManager(localInstanceConnectionInfo.address(),
              localInstanceConnectionInfo.dataPort(), bufferSize, numInThreads, numOutThreads, lowWaterMark, highWaterMark);
          break;
      }

      channelManager = new ChannelManager(lookupService, localInstanceConnectionInfo, numBuffers, bufferSize, networkConnectionManager);
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.io.network.netty.NettyConnectionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.