[jbosstools-commits] JBoss Tools SVN: r39770 - branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Mar 22 10:43:08 EDT 2012


Author: xcoulon
Date: 2012-03-22 10:43:08 -0400 (Thu, 22 Mar 2012)
New Revision: 39770

Modified:
   branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
   branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
Log:
Fixed - JBIDE-11361
Increase OpenShift wizards timeouts

Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java	2012-03-22 14:00:11 UTC (rev 39769)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java	2012-03-22 14:43:08 UTC (rev 39770)
@@ -187,12 +187,14 @@
 	private boolean createApplication() {
 		try {
 			final String applicationName = wizardModel.getApplicationName();
+			final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
 			IStatus status = WizardUtils.runInWizard(
 					new Job(NLS.bind("Creating application \"{0}\"...", applicationName)) {
 						@Override
 						protected IStatus run(IProgressMonitor monitor) {
 							try {
-								getWizardModel().createApplication(monitor);
+								delegatingMonitor.add(monitor);
+								getWizardModel().createApplication(delegatingMonitor);
 								return Status.OK_STATUS;
 							} catch (OpenShiftEndpointException e) {
 								// TODO: refresh user
@@ -205,7 +207,7 @@
 							}
 						}
 
-					}, null, getContainer(), 300);
+					}, delegatingMonitor, getContainer(), 300);
 			return status.isOK();
 		} catch (Exception e) {
 			return false;

Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java	2012-03-22 14:00:11 UTC (rev 39769)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java	2012-03-22 14:43:08 UTC (rev 39770)
@@ -8,6 +8,10 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -24,6 +28,7 @@
 import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
 import org.jboss.tools.openshift.express.internal.core.console.UserModel;
 import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
 import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureGitSharedProject;
 import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureUnsharedProject;
 import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportNewProject;
@@ -40,7 +45,7 @@
 
 	protected HashMap<String, Object> dataModel = new HashMap<String, Object>();
 
-	private static final int APP_CREATION_TIMEOUT = 120;
+	private static final int APP_CREATION_TIMEOUT = 180;
 	private static final String KEY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
 
 	public OpenShiftExpressApplicationWizardModel(UserDelegate user, IProject project, IApplication application, boolean useExistingApplication) {
@@ -343,15 +348,45 @@
 		}
 	}
 
-	protected IApplication createApplication(String name, ICartridge cartridge, IProgressMonitor monitor)
+	protected IApplication createApplication(final String name, final ICartridge cartridge, final IProgressMonitor monitor)
 			throws OpenShiftApplicationNotAvailableException, OpenShiftException {
-		IUser user = getUser();
+		final IUser user = getUser();
 		if (user == null) {
 			throw new OpenShiftException("Could not create application, have no valid user credentials");
 		}
-		IApplication application = user.createApplication(name, cartridge);
-		waitForAccessible(application, monitor);
-		return application;
+		ExecutorService executor = Executors.newFixedThreadPool(1);
+		try {
+			FutureTask<IApplication> future = new FutureTask<IApplication>(
+					new Callable<IApplication>() {
+						@Override
+						public IApplication call() throws Exception {
+							monitor.setTaskName("Creating application \"" + name + "\"...");
+							Logger.debug("creating application...");
+							final IApplication application
+							= user.createApplication(name, cartridge);
+							monitor.beginTask("Waiting for application to be reachable...",
+									IProgressMonitor.UNKNOWN);
+							Logger.debug("Waiting for application to be reachable...");
+							waitForAccessible(application, monitor);
+							return application;
+						}
+					});
+			executor.execute(future);
+			while (!future.isDone()) {
+				if(monitor.isCanceled()) {
+					throw new OpenShiftException("Operation was cancelled by user.");
+				}
+				Thread.sleep(1000);
+			}
+			final IApplication application = future.get();
+			return application;
+		} catch (Exception e) { // InterruptedException and ExecutionException
+			Throwable cause = e.getCause() !=null ?e.getCause() : e;
+			Logger.error("Failed to create application", cause);
+			throw new OpenShiftException("Failed to create application: {0}", cause.getMessage());
+		} finally {
+			executor.shutdown();
+		}
 	}
 
 	public void createApplication(IProgressMonitor monitor) throws OpenShiftApplicationNotAvailableException,



More information about the jbosstools-commits mailing list