use of org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
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;
}
use of org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
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 org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class PackingPlanProviderTest method refreshesPackingPlanOnUpdate.
@Test
public void refreshesPackingPlanOnUpdate() {
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());
provider.onEvent(new TopologyUpdate(null, null));
provider.get();
verify(adaptor, times(2)).getPackingPlan(topologyName);
}
use of org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class PackingPlanProviderTest method providesBoltInstanceNames.
@Test
public void providesBoltInstanceNames() {
PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
PackingPlanProvider packing = new PackingPlanProvider(adaptor, eventManager, topologyName);
String[] boltNames = packing.getBoltInstanceNames("testBolt");
assertEquals(3, boltNames.length);
HashSet<String> expectedBoltNames = new HashSet<>();
expectedBoltNames.add("container_1_testBolt_3");
expectedBoltNames.add("container_1_testBolt_4");
expectedBoltNames.add("container_1_testBolt_5");
for (String name : boltNames) {
expectedBoltNames.remove(name);
}
assertEquals(0, expectedBoltNames.size());
}
use of org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor in project heron by twitter.
the class MetricsCacheMetricsProviderTest method createMetricsProviderSpy.
private MetricsCacheMetricsProvider createMetricsProviderSpy() {
MetricsCacheLocation location = MetricsCacheLocation.newBuilder().setTopologyName("testTopo").setTopologyId("topoId").setHost("localhost").setControllerPort(0).setServerPort(0).build();
SchedulerStateManagerAdaptor stateMgr = Mockito.mock(SchedulerStateManagerAdaptor.class);
when(stateMgr.getMetricsCacheLocation("testTopo")).thenReturn(location);
MetricsCacheMetricsProvider metricsProvider = new MetricsCacheMetricsProvider(stateMgr, "testTopo");
return spy(metricsProvider);
}
Aggregations