Search in sources :

Example 1 with IScalable

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

Example 2 with IScalable

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

Example 3 with IScalable

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

Example 4 with IScalable

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));
}
Also used : PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) IScalable(org.apache.heron.spi.scheduler.IScalable) Lock(org.apache.heron.spi.statemgr.Lock) SchedulerStateManagerAdaptor(org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor) TimeUnit(java.util.concurrent.TimeUnit) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

IScalable (org.apache.heron.spi.scheduler.IScalable)4 UpdateTopologyManager (org.apache.heron.scheduler.UpdateTopologyManager)3 HashSet (java.util.HashSet)1 TimeUnit (java.util.concurrent.TimeUnit)1 Config (org.apache.heron.spi.common.Config)1 PackingPlan (org.apache.heron.spi.packing.PackingPlan)1 Resource (org.apache.heron.spi.packing.Resource)1 Lock (org.apache.heron.spi.statemgr.Lock)1 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1