use of com.twitter.heron.spi.packing.PackingPlanProtoSerializer in project heron by twitter.
the class SchedulerUtils method persistUpdatedPackingPlan.
/**
* Replaces persisted packing plan in state manager.
*/
public static void persistUpdatedPackingPlan(String topologyName, PackingPlan updatedPackingPlan, SchedulerStateManagerAdaptor stateManager) {
LOG.log(Level.INFO, "Updating scheduled-resource in packing plan: {0}", topologyName);
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
if (!stateManager.updatePackingPlan(serializer.toProto(updatedPackingPlan), topologyName)) {
throw new RuntimeException(String.format("Failed to update packing plan for topology %s", topologyName));
}
}
use of com.twitter.heron.spi.packing.PackingPlanProtoSerializer in project heron by twitter.
the class UpdateTopologyManagerTest method init.
@Before
public void init() {
Integer[] instanceIndexA = new Integer[] { 37, 48, 59 };
Integer[] instanceIndexB = new Integer[] { 17, 22 };
currentContainerPlan = buildContainerSet(new Integer[] { 1, 2, 3, 4 }, instanceIndexA);
proposedContainerPlan = buildContainerSet(new Integer[] { 1, 3, 5, 6 }, instanceIndexB);
expectedContainersToAdd = buildContainerSet(new Integer[] { 5, 6 }, instanceIndexB);
expectedContainersToRemove = buildContainerSet(new Integer[] { 2, 4 }, instanceIndexA);
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
PackingPlan currentPacking = new PackingPlan("current", currentContainerPlan);
proposedPacking = new PackingPlan("proposed", proposedContainerPlan);
currentProtoPlan = serializer.toProto(currentPacking);
proposedProtoPlan = serializer.toProto(proposedPacking);
testTopology = TopologyTests.createTopology(TOPOLOGY_NAME, new com.twitter.heron.api.Config(), "spoutname", "boltname", 1, 1);
assertEquals(TopologyAPI.TopologyState.RUNNING, testTopology.getState());
}
use of com.twitter.heron.spi.packing.PackingPlanProtoSerializer in project heron by twitter.
the class RuntimeManagerRunner method buildNewPackingPlan.
@VisibleForTesting
PackingPlans.PackingPlan buildNewPackingPlan(PackingPlans.PackingPlan currentProtoPlan, Map<String, Integer> changeRequests, TopologyAPI.Topology topology) throws PackingException {
PackingPlanProtoDeserializer deserializer = new PackingPlanProtoDeserializer();
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
PackingPlan currentPackingPlan = deserializer.fromProto(currentProtoPlan);
Map<String, Integer> componentCounts = currentPackingPlan.getComponentCounts();
Map<String, Integer> componentChanges = parallelismDelta(componentCounts, changeRequests);
// Create an instance of the packing class
String repackingClass = Context.repackingClass(config);
IRepacking packing;
try {
// create an instance of the packing class
packing = ReflectionUtils.newInstance(repackingClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new IllegalArgumentException("Failed to instantiate packing instance: " + repackingClass, e);
}
LOG.info("Updating packing plan using " + repackingClass);
try {
packing.initialize(config, topology);
PackingPlan packedPlan = packing.repack(currentPackingPlan, componentChanges);
return serializer.toProto(packedPlan);
} finally {
SysUtils.closeIgnoringExceptions(packing);
}
}
use of com.twitter.heron.spi.packing.PackingPlanProtoSerializer in project incubator-heron by apache.
the class RuntimeManagerRunner method buildNewPackingPlan.
@VisibleForTesting
PackingPlans.PackingPlan buildNewPackingPlan(PackingPlans.PackingPlan currentProtoPlan, Map<String, Integer> changeRequests, TopologyAPI.Topology topology) throws PackingException {
PackingPlanProtoDeserializer deserializer = new PackingPlanProtoDeserializer();
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
PackingPlan currentPackingPlan = deserializer.fromProto(currentProtoPlan);
Map<String, Integer> componentCounts = currentPackingPlan.getComponentCounts();
Map<String, Integer> componentChanges = parallelismDelta(componentCounts, changeRequests);
// Create an instance of the packing class
String repackingClass = Context.repackingClass(config);
IRepacking packing;
try {
// create an instance of the packing class
packing = ReflectionUtils.newInstance(repackingClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new IllegalArgumentException("Failed to instantiate packing instance: " + repackingClass, e);
}
LOG.info("Updating packing plan using " + repackingClass);
try {
packing.initialize(config, topology);
PackingPlan packedPlan = packing.repack(currentPackingPlan, componentChanges);
return serializer.toProto(packedPlan);
} finally {
SysUtils.closeIgnoringExceptions(packing);
}
}
use of com.twitter.heron.spi.packing.PackingPlanProtoSerializer in project incubator-heron by apache.
the class UpdateTopologyManagerTest method init.
@Before
public void init() {
Integer[] instanceIndexA = new Integer[] { 37, 48, 59 };
Integer[] instanceIndexB = new Integer[] { 17, 22 };
currentContainerPlan = buildContainerSet(new Integer[] { 1, 2, 3, 4 }, instanceIndexA);
proposedContainerPlan = buildContainerSet(new Integer[] { 1, 3, 5, 6 }, instanceIndexB);
expectedContainersToAdd = buildContainerSet(new Integer[] { 5, 6 }, instanceIndexB);
expectedContainersToRemove = buildContainerSet(new Integer[] { 2, 4 }, instanceIndexA);
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
PackingPlan currentPacking = new PackingPlan("current", currentContainerPlan);
proposedPacking = new PackingPlan("proposed", proposedContainerPlan);
currentProtoPlan = serializer.toProto(currentPacking);
proposedProtoPlan = serializer.toProto(proposedPacking);
testTopology = TopologyTests.createTopology(TOPOLOGY_NAME, new com.twitter.heron.api.Config(), "spoutname", "boltname", 1, 1);
assertEquals(TopologyAPI.TopologyState.RUNNING, testTopology.getState());
}
Aggregations