Search in sources :

Example 66 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class HealthManager method createStateMgrAdaptor.

@VisibleForTesting
SchedulerStateManagerAdaptor createStateMgrAdaptor() throws ReflectiveOperationException {
    String stateMgrClass = Context.stateManagerClass(config);
    IStateManager stateMgr = ReflectionUtils.newInstance(stateMgrClass);
    stateMgr.initialize(config);
    return new SchedulerStateManagerAdaptor(stateMgr, 5000);
}
Also used : IStateManager(com.twitter.heron.spi.statemgr.IStateManager) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 67 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class MetricsCacheMetricsProviderTest method createMetricsProviderSpy.

private MetricsCacheMetricsProvider createMetricsProviderSpy() {
    MetricsCacheLocation location = MetricsCacheLocation.newBuilder().setTopologyName("testTopo").setTopologyId("topoId").setHost("localhost").setControllerPort(0).setMasterPort(0).build();
    SchedulerStateManagerAdaptor stateMgr = Mockito.mock(SchedulerStateManagerAdaptor.class);
    when(stateMgr.getMetricsCacheLocation("testTopo")).thenReturn(location);
    MetricsCacheMetricsProvider metricsProvider = new MetricsCacheMetricsProvider(stateMgr, "testTopo");
    MetricsCacheMetricsProvider spyMetricsProvider = spy(metricsProvider);
    spyMetricsProvider.setClock(new TestClock(70000));
    return spyMetricsProvider;
}
Also used : MetricsCacheLocation(com.twitter.heron.proto.tmaster.TopologyMaster.MetricsCacheLocation) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)

Example 68 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class TopologyProviderTest method fetchesAndCachesPackingFromStateMgr.

@Test
public void fetchesAndCachesPackingFromStateMgr() {
    SchedulerStateManagerAdaptor adaptor = getMockSchedulerStateManagerAdaptor();
    TopologyProvider provider = new TopologyProvider(adaptor, eventManager, topology);
    Assert.assertEquals(2, provider.get().getBoltsCount());
    // once fetched it is cached
    provider.get();
    verify(adaptor, times(1)).getPhysicalPlan(topology);
}
Also used : SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 69 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class PackingPlanProviderTest method fetchesAndCachesPackingFromStateMgr.

@Test
public void fetchesAndCachesPackingFromStateMgr() {
    PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
    PackingPlanProvider provider = new PackingPlanProvider(adaptor, eventManager, topologyName);
    PackingPlan packing = provider.get();
    Assert.assertEquals(1, packing.getContainers().size());
    // once fetched it is cached
    provider.get();
    verify(adaptor, times(1)).getPackingPlan(topologyName);
}
Also used : PackingPlans(com.twitter.heron.proto.system.PackingPlans) RoundRobinPacking(com.twitter.heron.packing.roundrobin.RoundRobinPacking) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 70 with SchedulerStateManagerAdaptor

use of com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor in project incubator-heron by apache.

the class SchedulerUtils method setSchedulerLocation.

/**
 * Set the location of scheduler for other processes to discover
 *
 * @param runtime the runtime configuration
 * @param schedulerEndpoint the endpoint that scheduler listens for receives requests
 * @param scheduler the IScheduler to provide more info
 */
public static boolean setSchedulerLocation(Config runtime, String schedulerEndpoint, IScheduler scheduler) {
    // Set scheduler location to host:port by default. Overwrite scheduler location if behind DNS.
    Scheduler.SchedulerLocation.Builder builder = Scheduler.SchedulerLocation.newBuilder().setTopologyName(Runtime.topologyName(runtime)).setHttpEndpoint(schedulerEndpoint);
    // Set the job link in SchedulerLocation if any
    List<String> jobLinks = scheduler.getJobLinks();
    // Check whether IScheduler provides valid job link
    if (jobLinks != null) {
        builder.addAllJobPageLink(jobLinks);
    }
    Scheduler.SchedulerLocation location = builder.build();
    LOG.log(Level.INFO, "Setting Scheduler locations: {0}", location);
    SchedulerStateManagerAdaptor statemgr = Runtime.schedulerStateManagerAdaptor(runtime);
    Boolean result = statemgr.setSchedulerLocation(location, Runtime.topologyName(runtime));
    if (result == null || !result) {
        LOG.severe("Failed to set Scheduler location");
        return false;
    }
    return true;
}
Also used : Scheduler(com.twitter.heron.proto.scheduler.Scheduler) IScheduler(com.twitter.heron.spi.scheduler.IScheduler) SchedulerStateManagerAdaptor(com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)

Aggregations

SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)82 Test (org.junit.Test)51 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)44 Config (com.twitter.heron.spi.common.Config)27 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)27 Scheduler (com.twitter.heron.proto.scheduler.Scheduler)16 PackingPlans (com.twitter.heron.proto.system.PackingPlans)13 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)13 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)12 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)9 HeronTopology (com.twitter.heron.api.HeronTopology)8 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)8 ExecutionEnvironment (com.twitter.heron.proto.system.ExecutionEnvironment)8 HashSet (java.util.HashSet)8 RoundRobinPacking (com.twitter.heron.packing.roundrobin.RoundRobinPacking)7 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)4 PackingPlanProtoDeserializer (com.twitter.heron.spi.packing.PackingPlanProtoDeserializer)4 IScalable (com.twitter.heron.spi.scheduler.IScalable)4