Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2017-03-02 20:25:34 -0500
committerJeff Johnston2017-03-03 14:04:11 -0500
commitae6c2339fbf0447e4f5208233a0b94082d4c41cd (patch)
tree90478b81e2756bab5eab9c9a69c893928d33e4b1
parentb70e2cc00ad4a9c14c7b03afd93ee089f6c8d925 (diff)
downloadorg.eclipse.linuxtools-ae6c2339fbf0447e4f5208233a0b94082d4c41cd.tar.gz
org.eclipse.linuxtools-ae6c2339fbf0447e4f5208233a0b94082d4c41cd.tar.xz
org.eclipse.linuxtools-ae6c2339fbf0447e4f5208233a0b94082d4c41cd.zip
Bug 513029 - Fix open retry logic to be quiet and properly clean up
- change DockerExplorerContentProvider openRetry job to be a system job to avoid it showing up in Tasks view - properly cancel and remove an openRetry job if the connection URI has been removed - remove a job once it is complete or cancelled - fix dispose() to loop through all open retry jobs and cancel them - add a more accurate title for the open retry jobs (won't be displayed due to the job being marked system) Change-Id: I7bd4d998fdb639c653e95552170bbf48502bea8f Reviewed-on: https://git.eclipse.org/r/92213 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties1
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java46
2 files changed, 45 insertions, 2 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties
index b498d982e3..d084b9898f 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties
@@ -133,6 +133,7 @@ ViewerNoConnectionSelected.msg=No Docker connection selected
ViewerConnectionNotAvailable.msg={0} - connection not available
PingJob.msg=Opening connection...
+PingJob2.msg=Opening connection ''{0}''[{1}]...
PingJobError.msg=Failed to connect to ''{0}''
PingJobError.msg.withExplanation=Failed to connect to ''{0}'': {1}
ImagesLoadJob.msg=Loading images from ''{0}'' ...
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
index c8b2d303a8..643b239f9b 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
@@ -62,6 +62,17 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
@Override
public void dispose() {
+ for (Job job : openRetryJobs.values()) {
+ LoadingJob loadingJob = (LoadingJob) job;
+ IProgressMonitor monitor = loadingJob.getMonitor();
+ monitor.setCanceled(true);
+ job.cancel();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
}
@Override
@@ -94,7 +105,12 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
return new Object[] { new LoadingStub(connection) };
} else if (connection
.getState() == EnumDockerConnectionState.CLOSED) {
- openRetry(connection);
+ synchronized (openRetryJobs) {
+ Job job = openRetryJobs.get(connection);
+ if (job == null) {
+ openRetry(connection);
+ }
+ }
return new Object[] { new LoadingStub(connection) };
}
return new Object[0];
@@ -209,14 +225,26 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
*/
private void openRetry(final IDockerConnection connection) {
final Job openRetryJob = new LoadingJob(
- DVMessages.getString("PingJob.msg"), //$NON-NLS-1$
+ DVMessages.getFormattedString("PingJob2.msg", //$NON-NLS-1$
+ connection.getName(), connection.getUri()),
connection) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
+ setMonitor(monitor);
long totalSleep = 0;
long sleepTime = 3000; // 3 second default
for (;;) {
try {
+ // check if Connection is removed or cancelled
+ if (monitor.isCanceled() || DockerConnectionManager
+ .getInstance()
+ .getConnectionByUri(
+ connection.getUri()) == null) {
+ synchronized (openRetryJobs) {
+ openRetryJobs.remove(connection);
+ }
+ return Status.CANCEL_STATUS;
+ }
connection.open(true);
connection.ping();
synchronized (openRetryJobs) {
@@ -241,6 +269,9 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
null);
}
} catch (InterruptedException e) {
+ synchronized (openRetryJobs) {
+ openRetryJobs.remove(connection);
+ }
return Status.CANCEL_STATUS;
}
}
@@ -249,6 +280,7 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
synchronized (openRetryJobs) {
openRetryJobs.put(connection, openRetryJob);
}
+ openRetryJob.setSystem(true);
openRetryJob.schedule();
}
@@ -953,6 +985,8 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
private abstract class LoadingJob extends Job {
+ private IProgressMonitor monitor;
+
public LoadingJob(final String name, final Object target) {
super(name);
this.addJobChangeListener(new JobChangeAdapter() {
@@ -964,6 +998,14 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
});
}
+ public IProgressMonitor getMonitor() {
+ return monitor;
+ }
+
+ public void setMonitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+
@Override
public boolean belongsTo(Object family) {
return DockerExplorerView.class.equals(family);

Back to the top