summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Panjer2012-09-17 00:12:06 (EDT)
committer Steffen Pingel2012-09-17 23:37:52 (EDT)
commit9c2fb3869b008896da0e31f3993f82dc8a61c3ff (patch)
tree117c419cd6a56317ba3fb52e471b839f3841c626
parent328ed3e515d3a15b106c84bcb797238bb894f10f (diff)
downloadorg.eclipse.mylyn.builds-9c2fb3869b008896da0e31f3993f82dc8a61c3ff.zip
org.eclipse.mylyn.builds-9c2fb3869b008896da0e31f3993f82dc8a61c3ff.tar.gz
org.eclipse.mylyn.builds-9c2fb3869b008896da0e31f3993f82dc8a61c3ff.tar.bz2
375908: only allow two queued refresh jobs for a build serverrefs/changes/81/7781/3
Change-Id: Ic7e675c605caf330aa91dc9b9642294ba33c23bc Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=375908
-rw-r--r--org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/operations/RefreshOperation.java13
-rw-r--r--org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/util/BuildScheduler.java8
2 files changed, 20 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/operations/RefreshOperation.java b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/operations/RefreshOperation.java
index eaa58e3..ff73a50 100644
--- a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/operations/RefreshOperation.java
+++ b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/operations/RefreshOperation.java
@@ -35,6 +35,7 @@ import org.eclipse.osgi.util.NLS;
* The refresh operation refreshes elements of the model with the latest state from the server.
*
* @author Steffen Pingel
+ * @author Lucas Panjer
*/
public class RefreshOperation extends AbstractElementOperation<IBuildServer> {
@@ -82,6 +83,18 @@ public class RefreshOperation extends AbstractElementOperation<IBuildServer> {
}
@Override
+ public boolean belongsTo(Object family) {
+ if (family instanceof RefreshJob) {
+ RefreshJob refreshJob = (RefreshJob) family;
+ if (getElement().equals(refreshJob.getElement())) {
+ return true;
+ }
+ return false;
+ }
+ return super.belongsTo(family);
+ }
+
+ @Override
public IBuildServer getElement() {
return data.server;
}
diff --git a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/util/BuildScheduler.java b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/util/BuildScheduler.java
index 9f1f66a..100e7ec 100644
--- a/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/util/BuildScheduler.java
+++ b/org.eclipse.mylyn.builds.core/src/org/eclipse/mylyn/builds/internal/core/util/BuildScheduler.java
@@ -18,9 +18,12 @@ import org.eclipse.mylyn.builds.internal.core.operations.BuildJob;
/**
* @author Steffen Pingel
+ * @author Lucas Panjer
*/
public class BuildScheduler {
+ private static final long MAX_QUEUED_REFRESH_JOBS = 2;
+
public BuildScheduler() {
}
@@ -29,7 +32,10 @@ public class BuildScheduler {
}
public void schedule(Job job, long interval) {
- job.schedule(interval);
+ Job[] existingJobs = Job.getJobManager().find(job);
+ if (existingJobs.length < MAX_QUEUED_REFRESH_JOBS) {
+ job.schedule(interval);
+ }
}
public void schedule(List<BuildJob> jobs) {