use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testTopologyFile.
@Test
public void testTopologyFile() throws Exception {
Config config = Config.toLocalMode(getDefaultConfig());
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(config);
Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), LocalFileSystemContext.getFileSystemDirectory(config));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemContextTest method testGetFileSystemDirectory.
@Test
public void testGetFileSystemDirectory() {
String fileSystemDirectory = "${HOME}/.herondata/topologies/${CLUSTER}";
Config config = Config.newBuilder().put(Key.CLUSTER, "cluster").put(Key.ROLE, "role").put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), fileSystemDirectory).build();
// get actual file system directory set by the user
String actualFileSystemDirectory = LocalFileSystemContext.getFileSystemDirectory(config);
String expectedFileSystemDirectory = Paths.get("${HOME}", ".herondata", "topologies", "${CLUSTER}").toString();
Assert.assertEquals(expectedFileSystemDirectory, actualFileSystemDirectory);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class ScaleUpResolverTest method testResolve.
@Test
public void testResolve() {
TopologyAPI.Topology topology = createTestTopology();
Config config = createConfig(topology);
PackingPlan currentPlan = createPacking(topology, config);
PackingPlanProvider packingPlanProvider = mock(PackingPlanProvider.class);
when(packingPlanProvider.get()).thenReturn(currentPlan);
ISchedulerClient scheduler = mock(ISchedulerClient.class);
when(scheduler.updateTopology(any(UpdateTopologyRequest.class))).thenReturn(true);
Instant now = Instant.now();
Collections.singletonList(new Measurement("bolt", "i1", METRIC_BACK_PRESSURE.text(), now, 123));
List<String> assignments = Collections.singletonList("bolt");
Diagnosis diagnoses = new Diagnosis(DIAGNOSIS_UNDER_PROVISIONING.text(), now, assignments, null);
List<Diagnosis> diagnosis = Collections.singletonList(diagnoses);
ExecutionContext context = mock(ExecutionContext.class);
when(context.checkpoint()).thenReturn(now);
ScaleUpResolver resolver = new ScaleUpResolver(null, packingPlanProvider, scheduler, eventManager, null);
resolver.initialize(context);
ScaleUpResolver spyResolver = spy(resolver);
doReturn(2).when(spyResolver).computeScaleUpFactor("bolt");
doReturn(currentPlan).when(spyResolver).buildNewPackingPlan(any(HashMap.class), eq(currentPlan));
Collection<Action> result = spyResolver.resolve(diagnosis);
verify(scheduler, times(1)).updateTopology(any(UpdateTopologyRequest.class));
assertEquals(1, result.size());
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class ScaleUpResolverTest method testBuildPackingPlan.
@Test
public void testBuildPackingPlan() {
TopologyAPI.Topology topology = createTestTopology();
PhysicalPlanProvider topologyProvider = createPhysicalPlanProvider(topology);
Config config = createConfig(topology);
PackingPlan currentPlan = createPacking(topology, config);
Map<String, Integer> changeRequest = new HashMap<>();
changeRequest.put("bolt-2", 4);
Map<String, Integer> deltaChange = new HashMap<>();
deltaChange.put("bolt-2", 3);
IRepacking repacking = mock(IRepacking.class);
when(repacking.repack(currentPlan, deltaChange)).thenReturn(currentPlan);
ScaleUpResolver resolver = new ScaleUpResolver(topologyProvider, null, null, eventManager, config);
ScaleUpResolver spyResolver = spy(resolver);
doReturn(repacking).when(spyResolver).getRepackingClass("Repacking");
PackingPlan newPlan = spyResolver.buildNewPackingPlan(changeRequest, currentPlan);
assertEquals(currentPlan, newPlan);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemStateManager method main.
public static void main(String[] args) throws ExecutionException, InterruptedException, IllegalAccessException, ClassNotFoundException, InstantiationException {
Config config = Config.newBuilder().put(Key.STATEMGR_ROOT_PATH, System.getProperty("user.home") + "/.herondata/repository/state/local").build();
LocalFileSystemStateManager stateManager = new LocalFileSystemStateManager();
stateManager.doMain(args, config);
}
Aggregations