use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project heron by twitter.
the class SpoutInstanceTest method testLookForTimeouts.
@Test
public void testLookForTimeouts() throws Exception {
physicalPlan = UnitTestHelper.getPhysicalPlan(true, 1);
PhysicalPlanHelper physicalPlanHelper = new PhysicalPlanHelper(physicalPlan, SPOUT_INSTANCE_ID);
InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(physicalPlanHelper).build();
SingletonRegistry.INSTANCE.registerSingleton(Constants.FAIL_COUNT, failCount);
inControlQueue.offer(instanceControlMsg);
Runnable task = new Runnable() {
@Override
public void run() {
for (int i = 0; i < Constants.RETRY_TIMES; i++) {
if (failCount.intValue() != 0) {
break;
}
SysUtils.sleep(Constants.RETRY_INTERVAL_MS);
}
// Wait the bolt's finishing
SysUtils.sleep(Constants.TEST_WAIT_TIME_MS);
Assert.assertEquals(10, failCount.intValue());
testLooper.exitLoop();
}
};
testLooper.addTasksOnWakeup(task);
testLooper.loop();
}
use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project heron by twitter.
the class SpoutInstanceTest method testGatherMetrics.
/**
* Test the gathering of metrics
*/
@Test
public void testGatherMetrics() throws Exception {
physicalPlan = UnitTestHelper.getPhysicalPlan(false, -1);
PhysicalPlanHelper physicalPlanHelper = new PhysicalPlanHelper(physicalPlan, SPOUT_INSTANCE_ID);
InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(physicalPlanHelper).build();
inControlQueue.offer(instanceControlMsg);
Runnable task = new Runnable() {
@Override
public void run() {
for (int i = 0; i < Constants.RETRY_TIMES; i++) {
if (!slaveMetricsOut.isEmpty()) {
Metrics.MetricPublisherPublishMessage msg = slaveMetricsOut.poll();
Set<String> metricsName = new HashSet<String>();
for (Metrics.MetricDatum metricDatum : msg.getMetricsList()) {
metricsName.add(metricDatum.getName());
}
Assert.assertTrue(metricsName.contains("__ack-count/default"));
Assert.assertTrue(metricsName.contains("__complete-latency/default"));
Assert.assertTrue(metricsName.contains("__emit-count/default"));
Assert.assertTrue(metricsName.contains("__next-tuple-latency"));
Assert.assertTrue(metricsName.contains("__next-tuple-count"));
testLooper.exitLoop();
break;
}
SysUtils.sleep(Constants.RETRY_INTERVAL_MS);
}
}
};
testLooper.addTasksOnWakeup(task);
testLooper.loop();
}
use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project heron by twitter.
the class InstanceExecutor method createPhysicalPlanHelper.
protected PhysicalPlanHelper createPhysicalPlanHelper(PhysicalPlans.PhysicalPlan physicalPlan, String instanceId, MetricsCollector metricsCollector) {
PhysicalPlanHelper localPhysicalPlanHelper = new PhysicalPlanHelper(physicalPlan, instanceId);
// Bind the MetricsCollector with topologyContext
localPhysicalPlanHelper.setTopologyContext(metricsCollector);
return localPhysicalPlanHelper;
}
use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.
the class SpoutInstanceTest method initSpout.
private static void initSpout(SlaveTester slaveTester, boolean ackEnabled, int timeout) {
PhysicalPlans.PhysicalPlan physicalPlan = UnitTestHelper.getPhysicalPlan(ackEnabled, timeout);
PhysicalPlanHelper physicalPlanHelper = new PhysicalPlanHelper(physicalPlan, SPOUT_INSTANCE_ID);
slaveTester.getInControlQueue().offer(InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(physicalPlanHelper).build());
}
use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.
the class ConnectTest method testStart.
/**
* Test connection
*/
@Test
public void testStart() throws IOException {
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.socket().bind(new InetSocketAddress(HOST, getServerPort()));
SocketChannel socketChannel = null;
try {
runStreamManagerClient();
socketChannel = acceptSocketChannel(serverSocketChannel);
// Receive request
REQID rid = readIncomingPacket(socketChannel).unpackREQID();
OutgoingPacket outgoingPacket = new OutgoingPacket(rid, UnitTestHelper.getRegisterInstanceResponse());
outgoingPacket.writeToChannel(socketChannel);
HeronServerTester.await(getInControlQueueOfferLatch());
InstanceControlMsg instanceControlMsg = getInControlQueue().poll();
assertNotNull(instanceControlMsg);
getNIOLooper().exitLoop();
getThreadPool().shutdownNow();
PhysicalPlanHelper physicalPlanHelper = instanceControlMsg.getNewPhysicalPlanHelper();
Assert.assertEquals("test-bolt", physicalPlanHelper.getMyComponent());
Assert.assertEquals(InetAddress.getLocalHost().getHostName(), physicalPlanHelper.getMyHostname());
Assert.assertEquals(0, physicalPlanHelper.getMyInstanceIndex());
Assert.assertEquals(1, physicalPlanHelper.getMyTaskId());
} catch (ClosedChannelException ignored) {
} finally {
close(socketChannel);
}
}
Aggregations