Search in sources :

Example 6 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class EchoTest method runServer.

private void runServer() {
    Runnable server = new Runnable() {

        @Override
        public void run() {
            NIOLooper looper;
            try {
                looper = new NIOLooper();
                EchoServer s = new EchoServer(looper, serverPort, 1000);
                s.start();
            } catch (IOException e) {
                throw new RuntimeException("Some error instantiating server");
            }
            looper.loop();
        }
    };
    threadsPool.execute(server);
}
Also used : NIOLooper(com.twitter.heron.common.basics.NIOLooper) IOException(java.io.IOException)

Example 7 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class HandleTMasterLocationTest method before.

@Before
public void before() throws Exception {
    // Get an available port
    serverPort = SysUtils.getFreePort();
    threadsPool = Executors.newFixedThreadPool(2);
    HeronSocketOptions serverSocketOptions = new HeronSocketOptions(100 * 1024 * 1024, 100, 100 * 1024 * 1024, 100, 5 * 1024 * 1024, 5 * 1024 * 1024);
    serverLooper = new NIOLooper();
    // Spy it for unit test
    metricsManagerServer = Mockito.spy(new MetricsManagerServer(serverLooper, SERVER_HOST, serverPort, serverSocketOptions, new MultiCountMetric()));
}
Also used : NIOLooper(com.twitter.heron.common.basics.NIOLooper) HeronSocketOptions(com.twitter.heron.common.network.HeronSocketOptions) MultiCountMetric(com.twitter.heron.api.metric.MultiCountMetric) Before(org.junit.Before)

Example 8 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class HandleTMasterLocationTest method runClient.

private void runClient() {
    Runnable runClient = new Runnable() {

        private NIOLooper looper;

        @Override
        public void run() {
            try {
                looper = new NIOLooper();
                simpleLocationPublisher = new SimpleTMasterLocationPublisher(looper, SERVER_HOST, serverPort);
                simpleLocationPublisher.start();
                looper.loop();
            } catch (IOException e) {
                throw new RuntimeException("Some error instantiating client");
            } finally {
                simpleLocationPublisher.stop();
                if (looper != null) {
                    looper.exitLoop();
                }
            }
        }
    };
    threadsPool.execute(runClient);
}
Also used : NIOLooper(com.twitter.heron.common.basics.NIOLooper) IOException(java.io.IOException)

Example 9 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class MetricsManagerServerTest method runClient.

private void runClient() {
    Runnable runClient = new Runnable() {

        @Override
        public void run() {
            try {
                NIOLooper looper = new NIOLooper();
                simpleMetricsClient = new SimpleMetricsClient(looper, SERVER_HOST, serverPort, MESSAGE_SIZE);
                simpleMetricsClient.start();
                looper.loop();
            } catch (IOException e) {
                throw new RuntimeException("Some error instantiating client");
            } finally {
                simpleMetricsClient.stop();
            }
        }
    };
    threadsPool.execute(runClient);
}
Also used : NIOLooper(com.twitter.heron.common.basics.NIOLooper) IOException(java.io.IOException)

Example 10 with NIOLooper

use of com.twitter.heron.common.basics.NIOLooper in project heron by twitter.

the class MetricsManagerServerTest method before.

@Before
public void before() throws Exception {
    // Get an available port
    serverPort = SysUtils.getFreePort();
    threadsPool = Executors.newFixedThreadPool(2);
    HeronSocketOptions serverSocketOptions = new HeronSocketOptions(100 * 1024 * 1024, 100, 100 * 1024 * 1024, 100, 5 * 1024 * 1024, 5 * 1024 * 1024);
    serverLooper = new NIOLooper();
    metricsManagerServer = new MetricsManagerServer(serverLooper, SERVER_HOST, serverPort, serverSocketOptions, new MultiCountMetric());
}
Also used : NIOLooper(com.twitter.heron.common.basics.NIOLooper) HeronSocketOptions(com.twitter.heron.common.network.HeronSocketOptions) MultiCountMetric(com.twitter.heron.api.metric.MultiCountMetric) Before(org.junit.Before)

Aggregations

NIOLooper (com.twitter.heron.common.basics.NIOLooper)11 Before (org.junit.Before)6 IOException (java.io.IOException)4 SlaveLooper (com.twitter.heron.common.basics.SlaveLooper)3 InstanceControlMsg (com.twitter.heron.instance.InstanceControlMsg)3 GatewayMetrics (com.twitter.heron.metrics.GatewayMetrics)3 MultiCountMetric (com.twitter.heron.api.metric.MultiCountMetric)2 HeronSocketOptions (com.twitter.heron.common.network.HeronSocketOptions)2 SystemConfig (com.twitter.heron.common.config.SystemConfig)1 MetricsSinksConfig (com.twitter.heron.metricsmgr.MetricsSinksConfig)1 TopologyMaster (com.twitter.heron.proto.tmaster.TopologyMaster)1 Test (org.junit.Test)1