Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-15058

Application Wizard: Embed Wizard: wizard jobs should not get cancelled autom. if a given time is exceeded.

XMLWordPrintable

      The current implementation of WizardUtils#runInWizard will always cancel the job it is running if it exceeds a given timeout. If the caller is not providing a timeout a default timeout of 2 minutes is applied:

      org.jboss.tools.common.ui.WizardUtils#runInWizard
      public static IStatus runInWizard(final Job job, final DelegatingProgressMonitor delegatingMonitor,
      			final IWizardContainer container) throws InvocationTargetException, InterruptedException {
      		return runInWizard(job, delegatingMonitor, container, DEFAULT_TIMEOUT);
      	}
      

      All Jobs in OpenShiftApplicationWizard are thus using timeouts. Once the timeouts are reached the WizardUtils#runInWizard will cancel them. We should offer #runInWizard that never timeouts and cancels and use these in the OpenShiftApplicationWizard and all other jobs that use this facility:

      Unable to find source-code formatter for language: embedcartridgewizardpage. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      EmbedCartridgesJob job = new EmbedCartridgesJob(
      		new ArrayList<IEmbeddableCartridge>(pageModel.getSelectedEmbeddableCartridges()), 
      		pageModel.getApplication());
      IStatus result = WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer(), EMBED_CARTRIDGES_TIMEOUT);
      
      Unable to find source-code formatter for language: openshiftapplicationwizard. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      	private IStatus createApplication() {
      		try {
      			CreateApplicationJob job = new CreateApplicationJob(
      					model.getApplicationName()
      					, model.getApplicationCartridge()
      					, model.getApplicationScale()
      					, model.getApplicationGearProfile()
      					, model.getInitialGitUrl()
      					, model.getConnection().getDefaultDomain());
      			IStatus status = WizardUtils.runInWizard(
      					job, job.getDelegatingProgressMonitor(), getContainer(), APP_CREATE_TIMEOUT);
      			IApplication application = job.getApplication();
      			model.setApplication(application);
      			if (status.isOK()) {
      				openLogDialog(application, job.isTimeouted(status));
      			}
      			return status;
      		} catch (Exception e) {
      			return OpenShiftUIActivator.createErrorStatus(
      					NLS.bind("Could not create application {0}", model.getApplicationName()), e);
      		}
      	}
      
      	private IStatus addCartridges(final IApplication application, final Set<IEmbeddableCartridge> selectedCartridges) {
      		try {
      			EmbedCartridgesJob job = new EmbedCartridgesJob(
      					new ArrayList<IEmbeddableCartridge>(model.getSelectedEmbeddableCartridges()),
      					true, // dont remove cartridges
      					model.getApplication());
      			IStatus result = WizardUtils.runInWizard(
      					job, job.getDelegatingProgressMonitor(), getContainer(), EMBED_CARTRIDGES_TIMEOUT);
      			if (result.isOK()) {
      				openLogDialog(job.getAddedCartridges(), job.isTimeouted(result));
      			}
      			return result;
      		} catch (Exception e) {
      			return OpenShiftUIActivator.createErrorStatus(
      					NLS.bind("Could not add/remove cartridges for application {0}", application.getName()), e);
      		}
      	}
      
      	private IStatus waitForApplication(IApplication application) {
      		try {
      			AbstractDelegatingMonitorJob job = new WaitForApplicationJob(application, getShell());
      			IStatus status = WizardUtils.runInWizard(
      					job, job.getDelegatingProgressMonitor(), getContainer(), APP_WAIT_TIMEOUT);
      			return status;
      		} catch (Exception e) {
      			return OpenShiftUIActivator.createErrorStatus(
      					NLS.bind("Could not wait for application {0} to become reachable", application.getName()), e);
      		}
      	}
      
      	private boolean importProject() {
      		try {
      			final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
      			IStatus jobResult = WizardUtils.runInWizard(
      					new ImportJob(delegatingMonitor), delegatingMonitor, getContainer(), IMPORT_TIMEOUT);
      			return JobUtils.isOk(jobResult);
      		} catch (Exception e) {
      			ErrorDialog.openError(getShell(), "Error", "Could not create local git repository.", OpenShiftUIActivator
      					.createErrorStatus("An exception occurred while creating local git repository.", e));
      			return false;
      		}
      	}
      

              adietish@redhat.com André Dietisheim
              adietish@redhat.com André Dietisheim
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: