Search in sources :

Example 71 with Config

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));
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 72 with 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);
}
Also used : Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Example 73 with Config

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());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) Action(com.microsoft.dhalion.core.Action) HashMap(java.util.HashMap) Config(org.apache.heron.spi.common.Config) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Instant(java.time.Instant) PackingPlanProvider(org.apache.heron.healthmgr.common.PackingPlanProvider) TopologyAPI(org.apache.heron.api.generated.TopologyAPI) UpdateTopologyRequest(org.apache.heron.proto.scheduler.Scheduler.UpdateTopologyRequest) ExecutionContext(com.microsoft.dhalion.policy.PoliciesExecutor.ExecutionContext) ISchedulerClient(org.apache.heron.scheduler.client.ISchedulerClient) Diagnosis(com.microsoft.dhalion.core.Diagnosis) Test(org.junit.Test)

Example 74 with Config

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);
}
Also used : PhysicalPlanProvider(org.apache.heron.healthmgr.common.PhysicalPlanProvider) HashMap(java.util.HashMap) IRepacking(org.apache.heron.spi.packing.IRepacking) Config(org.apache.heron.spi.common.Config) PackingPlan(org.apache.heron.spi.packing.PackingPlan) TopologyAPI(org.apache.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 75 with Config

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);
}
Also used : Config(org.apache.heron.spi.common.Config)

Aggregations

Config (org.apache.heron.spi.common.Config)140 Test (org.junit.Test)75 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 PackingPlan (org.apache.heron.spi.packing.PackingPlan)22 HashMap (java.util.HashMap)18 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)18 Pair (org.apache.heron.common.basics.Pair)16 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)15 IOException (java.io.IOException)11 LauncherUtils (org.apache.heron.scheduler.utils.LauncherUtils)11 Map (java.util.Map)10 V1Volume (io.kubernetes.client.openapi.models.V1Volume)9 URI (java.net.URI)9 IScheduler (org.apache.heron.spi.scheduler.IScheduler)9 IStateManager (org.apache.heron.spi.statemgr.IStateManager)9 Before (org.junit.Before)9 File (java.io.File)7 LinkedList (java.util.LinkedList)7 Resource (org.apache.heron.spi.packing.Resource)7 CommandLine (org.apache.commons.cli.CommandLine)6