Search in sources :

Example 6 with PhysicalPlanHelper

use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project heron by twitter.

the class InstanceExecutorTest method testCreatePhysicalPlanHelper.

/**
   * Method: createPhysicalPlanHelper(PhysicalPlans.PhysicalPlan physicalPlan, String instanceId, MetricsCollector metricsCollector)
   */
@Test
public void testCreatePhysicalPlanHelper() throws Exception {
    PhysicalPlanHelper physicalPlanHelper = instanceExecutor.createPhysicalPlanHelper(plan, instanceId, Mockito.mock(MetricsCollector.class));
    Assert.assertNotNull(physicalPlanHelper.getTopologyContext());
}
Also used : MetricsCollector(com.twitter.heron.common.utils.metrics.MetricsCollector) PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) Test(org.junit.Test) PhysicalPlanUtilTest(com.twitter.heron.simulator.utils.PhysicalPlanUtilTest)

Example 7 with PhysicalPlanHelper

use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.

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 8 with PhysicalPlanHelper

use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.

the class InstanceExecutorTest method testCreatePhysicalPlanHelper.

/**
 * Method: createPhysicalPlanHelper(PhysicalPlans.PhysicalPlan physicalPlan, String instanceId, MetricsCollector metricsCollector)
 */
@Test
public void testCreatePhysicalPlanHelper() throws Exception {
    PhysicalPlanHelper physicalPlanHelper = instanceExecutor.createPhysicalPlanHelper(plan, instanceId, Mockito.mock(MetricsCollector.class));
    Assert.assertNotNull(physicalPlanHelper.getTopologyContext());
}
Also used : MetricsCollector(com.twitter.heron.common.utils.metrics.MetricsCollector) PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) Test(org.junit.Test) TopologyManagerTest(com.twitter.heron.simulator.utils.TopologyManagerTest)

Example 9 with PhysicalPlanHelper

use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.

the class Slave method handleNewPhysicalPlan.

private void handleNewPhysicalPlan(InstanceControlMsg instanceControlMsg) {
    PhysicalPlanHelper newHelper = instanceControlMsg.getNewPhysicalPlanHelper();
    // Bind the MetricsCollector with topologyContext
    newHelper.setTopologyContext(metricsCollector);
    if (helper == null) {
        helper = newHelper;
        handleNewAssignment();
    } else {
        TopologyAPI.TopologyState oldTopologyState = helper.getTopologyState();
        // Update the PhysicalPlanHelper
        helper = newHelper;
        instance.update(helper);
        // Handle the state changing
        if (!oldTopologyState.equals(helper.getTopologyState())) {
            switch(helper.getTopologyState()) {
                case RUNNING:
                    if (!isInstanceStarted) {
                        // Start the instance if it has not yet started
                        startInstanceIfNeeded();
                    }
                    instance.activate();
                    break;
                case PAUSED:
                    instance.deactivate();
                    break;
                default:
                    throw new RuntimeException("Unexpected TopologyState is updated for spout: " + helper.getTopologyState());
            }
        } else {
            LOG.info("Topology state remains the same in Slave: " + oldTopologyState);
        }
    }
}
Also used : PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI)

Example 10 with PhysicalPlanHelper

use of com.twitter.heron.common.utils.misc.PhysicalPlanHelper in project incubator-heron by apache.

the class StreamManagerClient method handleAssignmentMessage.

private void handleAssignmentMessage(PhysicalPlans.PhysicalPlan pplan) {
    LOG.fine("Physical Plan: " + pplan);
    PhysicalPlanHelper newHelper = new PhysicalPlanHelper(pplan, instance.getInstanceId());
    if (helper != null && (!helper.getMyComponent().equals(newHelper.getMyComponent()) || helper.getMyTaskId() != newHelper.getMyTaskId())) {
        // we will get the new assignment
        throw new RuntimeException("Our Assignment has changed. We will die to pick it");
    }
    if (helper == null) {
        LOG.info("We received a new Physical Plan.");
    } else {
        LOG.info("We received a new Physical Plan with same assignment. Should be state changes.");
        LOG.info(String.format("Old state: %s; new sate: %s.", helper.getTopologyState(), newHelper.getTopologyState()));
    }
    helper = newHelper;
    LOG.info("Push to Slave");
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(helper).build();
    inControlQueue.offer(instanceControlMsg);
}
Also used : PhysicalPlanHelper(com.twitter.heron.common.utils.misc.PhysicalPlanHelper) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg)

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