use of org.apache.heron.common.basics.NIOLooper in project heron by twitter.
the class HeronServerTest method before.
@Before
public void before() throws IOException {
// Get an available port
int serverPort = SysUtils.getFreePort();
serverOnConnectSignal = new CountDownLatch(1);
serverOnMessageSignal = new CountDownLatch(TOTAL_MESSAGES);
serverOnRequestSignal = new CountDownLatch(1);
clientOnConnectSignal = new CountDownLatch(1);
clientOnResponseSignal = new CountDownLatch(1);
heronServer = new SimpleHeronServer(new NIOLooper(), HeronServerTester.SERVER_HOST, serverPort, serverOnConnectSignal, serverOnMessageSignal, serverOnRequestSignal);
heronClient = new SimpleHeronClient(new NIOLooper(), HeronServerTester.SERVER_HOST, serverPort, clientOnConnectSignal, clientOnResponseSignal);
heronServerTester = new HeronServerTester(heronServer, heronClient);
}
use of org.apache.heron.common.basics.NIOLooper in project heron by twitter.
the class MetricsCacheTest method testMetricCache.
@Test
public void testMetricCache() throws IOException {
// prepare config files
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(CONFIG_SYSTEM_PATH, true).build();
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(CONFIG_SINK_PATH, null);
// initialize metric cache, except looper
MetricsCache mc = new MetricsCache(systemConfig, sinksConfig, new NIOLooper());
mc.addMetrics(TopologyManager.PublishMetrics.newBuilder().addMetrics(TopologyManager.MetricDatum.newBuilder().setComponentName("c1").setInstanceId("i1").setName("__jvm-uptime-secs").setTimestamp(System.currentTimeMillis()).setValue("0.1")).addExceptions(TopologyManager.TmanagerExceptionLog.newBuilder().setComponentName("c1").setHostname("h1").setInstanceId("i1").setStacktrace("s1").setLogging("l1").setCount(1).setFirsttime(String.valueOf(System.currentTimeMillis())).setLasttime(String.valueOf(System.currentTimeMillis()))).build());
// query last 10 seconds
TopologyManager.MetricResponse response = mc.getMetrics(TopologyManager.MetricRequest.newBuilder().setComponentName("c1").addInstanceId("i1").setInterval(10).addMetric("__jvm-uptime-secs").build());
assertEquals(response.getMetricCount(), 1);
assertEquals(response.getMetric(0).getInstanceId(), "i1");
assertEquals(response.getMetric(0).getMetricCount(), 1);
assertEquals(response.getMetric(0).getMetric(0).getName(), "__jvm-uptime-secs");
assertEquals(response.getMetric(0).getMetric(0).getValue(), "0.1");
}
use of org.apache.heron.common.basics.NIOLooper in project heron by twitter.
the class AbstractNetworkTest method runStreamManagerClient.
StreamManagerClient runStreamManagerClient() {
SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);
HeronSocketOptions socketOptions = new HeronSocketOptions(systemConfig.getInstanceNetworkWriteBatchSize(), systemConfig.getInstanceNetworkWriteBatchTime(), systemConfig.getInstanceNetworkReadBatchSize(), systemConfig.getInstanceNetworkReadBatchTime(), systemConfig.getInstanceNetworkOptionsSocketSendBufferSize(), systemConfig.getInstanceNetworkOptionsSocketReceivedBufferSize(), systemConfig.getInstanceNetworkOptionsMaximumPacketSize());
final NIOLooper nioLooper = (NIOLooper) communicatorTester.getTestLooper();
streamManagerClient = new StreamManagerClient(nioLooper, HOST, serverPort, "topology-name", "topologyId", UnitTestHelper.getInstance("bolt-id"), communicatorTester.getInStreamQueue(), communicatorTester.getOutStreamQueue(), communicatorTester.getInControlQueue(), socketOptions, gatewayMetrics);
Runnable r = new Runnable() {
@Override
public void run() {
try {
streamManagerClient.start();
nioLooper.loop();
} finally {
streamManagerClient.stop();
nioLooper.exitLoop();
}
}
};
threadPool.execute(r);
return streamManagerClient;
}
use of org.apache.heron.common.basics.NIOLooper in project heron by twitter.
the class EchoTest method before.
@Before
public void before() throws IOException {
int serverPort = SysUtils.getFreePort();
serverRequestsReceivedLatch = new CountDownLatch(MAX_REQUESTS);
server = new EchoServer(new NIOLooper(), serverPort, MAX_REQUESTS, serverRequestsReceivedLatch);
client = new EchoClient(new NIOLooper(), serverPort, MAX_REQUESTS);
heronServerTester = new HeronServerTester(server, client);
heronServerTester.start();
}
use of org.apache.heron.common.basics.NIOLooper in project heron by twitter.
the class HandleTManagerLocationTest method before.
@Before
public void before() throws IOException {
// MetricsManagerServer increments this counter every time a location refresh message is
// received, so we can await this counter getting to 4 before proceeding with the test
serverMetrics = new LatchedMultiCountMetric("tmanager-location-received", 4L);
// Spy it for unit test
metricsManagerServer = spy(new MetricsManagerServer(new NIOLooper(), HeronServerTester.SERVER_HOST, SysUtils.getFreePort(), HeronServerTester.TEST_SOCKET_OPTIONS, serverMetrics));
heronServerTester = new HeronServerTester(metricsManagerServer, new TestRequestHandler(), new HeronServerTester.SuccessResponseHandler(Metrics.MetricPublisherRegisterResponse.class, new TestResponseHandler()), RESPONSE_RECEIVED_TIMEOUT);
heronServerTester.start();
}
Aggregations