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());
}
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;
}
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());
}
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);
}
}
}
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);
}
Aggregations