use of org.apache.heron.spi.scheduler.IScalable in project heron by twitter.
the class KubernetesScheduler method initialize.
@Override
public void initialize(Config config, Config runtime) {
// validate the topology name before moving forward
if (!topologyNameIsValid(Runtime.topologyName(runtime))) {
throw new RuntimeException(getInvalidTopologyNameMessage(Runtime.topologyName(runtime)));
}
// validate that the image pull policy has been set correctly
if (!imagePullPolicyIsValid(KubernetesContext.getKubernetesImagePullPolicy(config))) {
throw new RuntimeException(getInvalidImagePullPolicyMessage(KubernetesContext.getKubernetesImagePullPolicy(config)));
}
final Config.Builder builder = Config.newBuilder().putAll(config);
if (config.containsKey(Key.TOPOLOGY_BINARY_FILE)) {
builder.put(Key.TOPOLOGY_BINARY_FILE, FileUtils.getBaseName(Context.topologyBinaryFile(config)));
}
this.configuration = builder.build();
this.runtimeConfiguration = runtime;
this.controller = getController();
this.updateTopologyManager = new UpdateTopologyManager(configuration, runtimeConfiguration, Optional.<IScalable>of(this));
}
use of org.apache.heron.spi.scheduler.IScalable in project heron by twitter.
the class AuroraScheduler method initialize.
@Override
public void initialize(Config mConfig, Config mRuntime) {
this.config = Config.toClusterMode(mConfig);
this.runtime = mRuntime;
try {
this.controller = getController();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
LOG.severe("AuroraController initialization failed " + e.getMessage());
}
this.updateTopologyManager = new UpdateTopologyManager(config, runtime, Optional.<IScalable>of(this));
}
use of org.apache.heron.spi.scheduler.IScalable in project heron by twitter.
the class LocalScheduler method initialize.
@Override
public void initialize(Config mConfig, Config mRuntime) {
this.config = mConfig;
this.runtime = mRuntime;
this.updateTopologyManager = new UpdateTopologyManager(config, runtime, Optional.<IScalable>of(this));
}
use of org.apache.heron.spi.scheduler.IScalable in project heron by twitter.
the class UpdateTopologyManagerTest method requestsToAddAndRemoveContainers.
/**
* Test scalable scheduler invocation
*/
@Test
@PrepareForTest(TManagerUtils.class)
public void requestsToAddAndRemoveContainers() throws Exception {
Lock lock = mockLock(true);
SchedulerStateManagerAdaptor mockStateMgr = mockStateManager(testTopology, this.currentProtoPlan, lock);
IScalable mockScheduler = mock(IScalable.class);
HashSet<PackingPlan.ContainerPlan> mockRetrunSet = new HashSet<>();
mockRetrunSet.add(new PackingPlan.ContainerPlan(0, new HashSet<>(), new Resource(5, ByteAmount.ZERO, ByteAmount.ZERO)));
mockRetrunSet.add(new PackingPlan.ContainerPlan(1, new HashSet<>(), new Resource(6, ByteAmount.ZERO, ByteAmount.ZERO)));
when(mockScheduler.addContainers(any())).thenReturn(mockRetrunSet);
UpdateTopologyManager spyUpdateManager = spyUpdateManager(mockStateMgr, mockScheduler, testTopology);
PowerMockito.spy(TManagerUtils.class);
PowerMockito.doNothing().when(TManagerUtils.class, "sendToTManager", any(String.class), eq(TOPOLOGY_NAME), eq(mockStateMgr), any(NetworkUtils.TunnelConfig.class));
// reactivation won't happen since topology state is still running due to mock state manager
PowerMockito.doNothing().when(TManagerUtils.class, "transitionTopologyState", eq(TOPOLOGY_NAME), eq(TManagerUtils.TManagerCommand.ACTIVATE), eq(mockStateMgr), eq(TopologyAPI.TopologyState.PAUSED), eq(TopologyAPI.TopologyState.RUNNING), any(NetworkUtils.TunnelConfig.class));
spyUpdateManager.updateTopology(currentProtoPlan, proposedProtoPlan);
verify(spyUpdateManager).deactivateTopology(eq(mockStateMgr), eq(testTopology), eq(proposedPacking));
verify(spyUpdateManager).reactivateTopology(eq(mockStateMgr), eq(testTopology), eq(2));
verify(mockScheduler).addContainers(expectedContainersToAdd);
verify(mockScheduler).removeContainers(expectedContainersToRemove);
verify(lock).tryLock(any(Long.class), any(TimeUnit.class));
verify(lock).unlock();
PowerMockito.verifyStatic(times(1));
TManagerUtils.transitionTopologyState(eq(TOPOLOGY_NAME), eq(TManagerUtils.TManagerCommand.DEACTIVATE), eq(mockStateMgr), eq(TopologyAPI.TopologyState.RUNNING), eq(TopologyAPI.TopologyState.PAUSED), any(NetworkUtils.TunnelConfig.class));
PowerMockito.verifyStatic(times(1));
TManagerUtils.transitionTopologyState(eq(TOPOLOGY_NAME), eq(TManagerUtils.TManagerCommand.ACTIVATE), eq(mockStateMgr), eq(TopologyAPI.TopologyState.PAUSED), eq(TopologyAPI.TopologyState.RUNNING), any(NetworkUtils.TunnelConfig.class));
}
Aggregations