Search in sources :

Example 1 with JobChainBuilder

use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.

the class JobChainBuilderTest method setUp.

@Before
public void setUp() {
    this.counter = new JobCounter(4);
    this.builder = new JobChainBuilder(createJob("Job 1", counter));
    createJobs(3, null, builder, counter);
    counter.setBuilder(builder);
}
Also used : JobChainBuilder(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder) Before(org.junit.Before)

Example 2 with JobChainBuilder

use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.

the class JobChainBuilderTest method should_schedule_4_jobs_given_null_condition_wont_stop_scheduling.

@Test
public void should_schedule_4_jobs_given_null_condition_wont_stop_scheduling() {
    // given
    JobCounter counter = new JobCounter(4);
    JobChainBuilder builder = new JobChainBuilder(createJob("Job 1", counter));
    counter.setBuilder(builder);
    createJobs(3, new ISchedulingCondition[] { null, null, null }, builder, counter);
    // when
    builder.schedule();
    // then
    assertThat(counter.getDone()).isEqualTo(4);
}
Also used : JobChainBuilder(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder) Test(org.junit.Test)

Example 3 with JobChainBuilder

use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.

the class OpenShiftServerEditorSection method loadResources.

private void loadResources(final Composite container, DataBindingContext dbc) {
    IServerWorkingCopy server = input.getServer();
    Cursor busyCursor = new Cursor(container.getDisplay(), SWT.CURSOR_WAIT);
    IProgressMonitor chainProgressMonitor = new NullProgressMonitor() {

        @Override
        public boolean isCanceled() {
            return container.isDisposed();
        }
    };
    new JobChainBuilder(new DisableAllWidgetsJobFixed(true, container, busyCursor, dbc), chainProgressMonitor).runWhenDone(new LoadResourcesJob(server)).runWhenDone(new DisableAllWidgetsJobFixed(false, container, false, busyCursor, dbc)).runWhenDone(new InitializeWidgetsJob()).schedule();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Cursor(org.eclipse.swt.graphics.Cursor) JobChainBuilder(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder)

Example 4 with JobChainBuilder

use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.

the class DeployImageWizard method getJobChain.

/**
 * Gets the Job to run as a chain of smaller jobs, depending on the use-case
 * @param model the wizard model
 * @param shell the current shell
 * @return
 */
private Job getJobChain(final IDeployImageParameters model, final Shell shell) {
    final DeployImageJob deployJob = getDeployImageJob(getModel(), getShell());
    final boolean pushImageToRegistry = model.isPushImageToRegistry();
    if (pushImageToRegistry) {
        final PushImageToRegistryJob pushImageToRegistryJob = getPushImageToRegistryJob(model);
        return new JobChainBuilder(pushImageToRegistryJob).runWhenSuccessfullyDone(deployJob).runWhenSuccessfullyDone(new RefreshResourcesJob(deployJob, true)).build();
    }
    return new JobChainBuilder(deployJob).runWhenSuccessfullyDone(new RefreshResourcesJob(deployJob, true)).build();
}
Also used : RefreshResourcesJob(org.jboss.tools.openshift.internal.ui.job.RefreshResourcesJob) DeployImageJob(org.jboss.tools.openshift.internal.ui.job.DeployImageJob) PushImageToRegistryJob(org.jboss.tools.openshift.internal.core.docker.PushImageToRegistryJob) JobChainBuilder(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder)

Example 5 with JobChainBuilder

use of org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder in project jbosstools-openshift by jbosstools.

the class JobChainBuilderTest method should_schedule_2_jobs_given_condition_that_stops_after_2.

@Test
public void should_schedule_2_jobs_given_condition_that_stops_after_2() {
    // given
    JobCounter counter = new JobCounter(4);
    JobChainBuilder builder = new JobChainBuilder(createJob("Job 1", counter));
    counter.setBuilder(builder);
    createJobs(3, new ISchedulingCondition[] { new JobChainBuilder.NullCondition(), new JobChainBuilder.ISchedulingCondition() {

        @Override
        public boolean isFullfilled(Job preceedingJob) {
            return false;
        }
    }, new JobChainBuilder.NullCondition() }, builder, counter);
    // when
    builder.schedule();
    // then
    assertThat(counter.getDone()).isEqualTo(2);
}
Also used : ISchedulingCondition(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder.ISchedulingCondition) Job(org.eclipse.core.runtime.jobs.Job) JobChainBuilder(org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder) Test(org.junit.Test)

Aggregations

JobChainBuilder (org.jboss.tools.openshift.internal.common.core.job.JobChainBuilder)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)3 UIJob (org.eclipse.ui.progress.UIJob)3 Test (org.junit.Test)3 IResource (com.openshift.restclient.model.IResource)2 List (java.util.List)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)2 Connection (org.jboss.tools.openshift.core.connection.Connection)2 RefreshResourcesJob (org.jboss.tools.openshift.internal.ui.job.RefreshResourcesJob)2 OpenShiftException (com.openshift.restclient.OpenShiftException)1 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IProject (com.openshift.restclient.model.IProject)1 IReplicationController (com.openshift.restclient.model.IReplicationController)1 IService (com.openshift.restclient.model.IService)1 IRoute (com.openshift.restclient.model.route.IRoute)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1