Author: adietish
Date: 2010-12-15 11:10:03 -0500 (Wed, 15 Dec 2010)
New Revision: 27514
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
Log:
[JBIDE-7912]
* replaced custom WatchCreateJob and replaced with InstanceStateJob to have consistent
scheduling across jobs in the client
* removed job related methods in DeltaCloud since job concurrency is dealt with job
scheduling rules now
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-15 15:39:02
UTC (rev 27513)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-15 16:10:03
UTC (rev 27514)
@@ -1,5 +1,10 @@
2010-12-15 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (getInstanceJob):
+ (waitWhilePending):
+ (registerInstanceJob):
+ [JBIDE-7912] removed since job concurrency is dealt with job scheduling rules now
* src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java (isConflicting):
* src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java (isConflicting):
* src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java
(isConflicting):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-15
15:39:02 UTC (rev 27513)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-15
16:10:03 UTC (rev 27514)
@@ -13,14 +13,11 @@
import java.net.MalformedURLException;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.regex.PatternSyntaxException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
import org.jboss.tools.deltacloud.core.client.DeltaCloudAuthException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl;
@@ -62,10 +59,6 @@
private IImageFilter imageFilter;
private IInstanceFilter instanceFilter;
- private Map<String, Job> actionJobs;
-
- private Object actionLock = new Object();
-
private SecurePasswordStore passwordStore;
public static interface IInstanceStateMatcher {
@@ -295,36 +288,6 @@
}
}
- public Job getInstanceJob(String id) {
- synchronized (actionLock) {
- Job j = null;
- if (actionJobs != null) {
- return actionJobs.get(id);
- }
- return j;
- }
- }
-
- public void registerInstanceJob(String id, Job j) {
- synchronized (actionLock) {
- if (actionJobs == null)
- actionJobs = new HashMap<String, Job>();
- actionJobs.put(id, j);
- }
- }
-
- public DeltaCloudInstance waitWhilePending(String instanceId, IProgressMonitor pm)
throws InterruptedException,
- DeltaCloudException {
- IInstanceStateMatcher differsFromPending = new IInstanceStateMatcher() {
-
- @Override
- public boolean matchesState(DeltaCloudInstance instance, DeltaCloudInstance.State
instanceState) {
- return !DeltaCloudInstance.State.PENDING.equals(instanceState);
- }
- };
- return waitForState(instanceId, differsFromPending, pm);
- }
-
public DeltaCloudInstance waitForState(String instanceId, final DeltaCloudInstance.State
expectedState,
IProgressMonitor pm)
throws InterruptedException, DeltaCloudException {
@@ -354,13 +317,6 @@
return instance;
}
- public void removeInstanceJob(String id, Job j) {
- synchronized (actionLock) {
- if (actionJobs != null && actionJobs.get(id) == j)
- actionJobs.remove(id);
- }
- }
-
/**
* Loads the instanceRepo from the server and stores them in this instance.
* Furthermore listeners get informed.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-15 15:39:02
UTC (rev 27513)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-15 16:10:03
UTC (rev 27514)
@@ -1,3 +1,9 @@
+2010-12-15 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(WatchCreateJob):
+ [JBIDE-7912] replaced custom WatchCreateJob and replaced with InstanceStateJob to have
consistent scheduling across jobs
+ in the client
+
2010-12-14 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/cloud/property/InstancePropertySource.java
(getKey):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-15
15:39:02 UTC (rev 27513)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-15
16:10:03 UTC (rev 27514)
@@ -14,9 +14,6 @@
import java.net.URLEncoder;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -27,6 +24,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.job.InstanceStateJob;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.DeltacloudUIExtensionManager;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
@@ -41,7 +39,6 @@
private final static String CONFIRM_CREATE_TITLE = "ConfirmCreate.title";
//$NON-NLS-1$
private final static String CONFIRM_CREATE_MSG = "ConfirmCreate.msg";
//$NON-NLS-1$
private final static String DONT_SHOW_THIS_AGAIN_MSG =
"DontShowThisAgain.msg"; //$NON-NLS-1$
- private final static String STARTING_INSTANCE_MSG = "StartingInstance.msg";
//$NON-NLS-1$
private final static String STARTING_INSTANCE_TITLE =
"StartingInstance.title"; //$NON-NLS-1$
protected NewInstancePage mainPage;
@@ -77,47 +74,6 @@
return mainPage.isPageComplete();
}
- private class WatchCreateJob extends ChainedJob {
-
- private DeltaCloud cloud;
- private String instanceId;
- private String instanceName;
-
- public WatchCreateJob(String title, DeltaCloud cloud,
- String instanceId, String instanceName) {
- super(title, INewInstanceWizardPage.NEW_INSTANCE_FAMILY);
- this.cloud = cloud;
- this.instanceId = instanceId;
- this.instanceName = instanceName;
- }
-
- public IStatus run(IProgressMonitor pm) {
- if (!pm.isCanceled()) {
- DeltaCloudInstance instance = null;
- try {
- pm.beginTask(
- WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] {
instanceName }),
- IProgressMonitor.UNKNOWN);
- pm.worked(1);
- cloud.registerInstanceJob(instanceId, this);
- instance = cloud.waitWhilePending(instanceId, pm);
-
- } catch (Exception e) {
- // do nothing
- } finally {
- // cloud.replaceInstance(instance);
- cloud.removeInstanceJob(instanceId, this);
- System.out.println(instance.getHostName());
- pm.done();
- }
- return Status.OK_STATUS;
- } else {
- pm.done();
- return Status.CANCEL_STATUS;
- }
- }
- };
-
@Override
public boolean performFinish() {
NewInstanceModel model = mainPage.getModel();
@@ -168,12 +124,12 @@
result = true;
}
if (instance != null &&
instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
- final String instanceId = instance.getId();
- final String instanceName = name;
-
// TODO use chained job? Maybe. But chainedJob needs to be moved
- ChainedJob first = new
WatchCreateJob(WizardMessages.getString(STARTING_INSTANCE_TITLE),
- cloud, instanceId, instanceName);
+ ChainedJob first =
+ new InstanceStateJob(
+ WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
+ instance,
+ DeltaCloudInstance.State.RUNNING);
first.setUser(true);
ChainedJob last = first;
ChainedJob temp;