Search in sources :

Example 16 with PhysicalPlanHelper

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();
}
Also used : PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) Test(org.junit.Test)

Example 17 with PhysicalPlanHelper

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();
}
Also used : Metrics(com.twitter.heron.proto.system.Metrics) PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) ByteString(com.google.protobuf.ByteString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with PhysicalPlanHelper

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;
}
Also used : PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper)

Example 19 with PhysicalPlanHelper

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());
}
Also used : PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) PhysicalPlans(com.twitter.heron.proto.system.PhysicalPlans)

Example 20 with PhysicalPlanHelper

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);
    }
}
Also used : ServerSocketChannel(java.nio.channels.ServerSocketChannel) SocketChannel(java.nio.channels.SocketChannel) ClosedChannelException(java.nio.channels.ClosedChannelException) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) InetSocketAddress(java.net.InetSocketAddress) REQID(com.twitter.heron.common.network.REQID) ServerSocketChannel(java.nio.channels.ServerSocketChannel) OutgoingPacket(com.twitter.heron.common.network.OutgoingPacket) Test(org.junit.Test)

Aggregations

PhysicalPlanHelper (com.twitter.heron.common.utils.misc.PhysicalPlanHelper)22 InstanceControlMsg (com.twitter.heron.instance.InstanceControlMsg)14 Test (org.junit.Test)14 HeronTuples (com.twitter.heron.proto.system.HeronTuples)5 ByteString (com.google.protobuf.ByteString)4 PhysicalPlans (com.twitter.heron.proto.system.PhysicalPlans)3 OutgoingPacket (com.twitter.heron.common.network.OutgoingPacket)2 REQID (com.twitter.heron.common.network.REQID)2 MetricsCollector (com.twitter.heron.common.utils.metrics.MetricsCollector)2 InetSocketAddress (java.net.InetSocketAddress)2 ClosedChannelException (java.nio.channels.ClosedChannelException)2 ServerSocketChannel (java.nio.channels.ServerSocketChannel)2 SocketChannel (java.nio.channels.SocketChannel)2 Message (com.google.protobuf.Message)1 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)1 IncomingPacket (com.twitter.heron.common.network.IncomingPacket)1 Metrics (com.twitter.heron.proto.system.Metrics)1 PhysicalPlanUtilTest (com.twitter.heron.simulator.utils.PhysicalPlanUtilTest)1 TopologyManagerTest (com.twitter.heron.simulator.utils.TopologyManagerTest)1 HashSet (java.util.HashSet)1