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