Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2015-05-25 17:19:19 -0400
committerRoland Grunberg2015-05-26 12:35:04 -0400
commit5733be7f5b458b4d815c66733cbd76f3ea5fda8c (patch)
tree3ccd9fb109c233373f963285a428e20499439f49
parente5591e231724b6351b7216e90f431df810ef7093 (diff)
downloadorg.eclipse.linuxtools-5733be7f5b458b4d815c66733cbd76f3ea5fda8c.tar.gz
org.eclipse.linuxtools-5733be7f5b458b4d815c66733cbd76f3ea5fda8c.tar.xz
org.eclipse.linuxtools-5733be7f5b458b4d815c66733cbd76f3ea5fda8c.zip
Fix bug 467748 - Progress monitors for pulling an image persist
- the Docker daemon is changing messages and so the handlers have to be more tolerant of these changes - add check for "Pull complete" message - ignore "Pulling" messages - fix DockerProgressDetail class to have toString() and equals() methods - fix job messages for Pulling and Pushing Change-Id: Ic1582a9047dacb14b3d417b2035bf2bf22ba9f97 Reviewed-on: https://git.eclipse.org/r/48321 Tested-by: Hudson CI Tested-by: Roland Grunberg <rgrunber@redhat.com> Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerProgressDetail.java20
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java11
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PushImageCommandHandler.java11
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DVMessages.properties6
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/ImagePullProgressHandler.java30
5 files changed, 56 insertions, 22 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerProgressDetail.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerProgressDetail.java
index 49c9d7d4be..f934c3956c 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerProgressDetail.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerProgressDetail.java
@@ -39,4 +39,24 @@ public class DockerProgressDetail implements IDockerProgressDetail {
return total;
}
+ @Override
+ public String toString() {
+ return "Progress Detail: current=" + Long.toString(current) + "\n"
+ + " start=" + Long.toString(start) + "\n" + " total="
+ + Long.toString(total) + "\n";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DockerProgressDetail other = (DockerProgressDetail) obj;
+ return this.current == other.current && this.start == other.start
+ && this.total == other.total;
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
index 8b4c8f9169..f566defaeb 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
@@ -33,7 +33,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class PullImageCommandHandler extends AbstractHandler implements
IHandler {
- private final static String PULL_IMAGE_JOB_TITLE = "ImagePull.msg"; //$NON-NLS-1$
+ private final static String PULL_IMAGE_JOB_TITLE = "ImagePull.title"; //$NON-NLS-1$
+ private final static String PULL_IMAGE_JOB_TASK = "ImagePull.msg"; //$NON-NLS-1$
private static final String ERROR_PULLING_IMAGE = "ImagePullError.msg"; //$NON-NLS-1$
private IDockerConnection connection;
@@ -55,19 +56,19 @@ public class PullImageCommandHandler extends AbstractHandler implements
}
private void performPullImage(final ImagePull wizard) {
- final Job pullImageJob = new Job(
- DVMessages.getString(PULL_IMAGE_JOB_TITLE)) {
+ final Job pullImageJob = new Job(DVMessages.getFormattedString(
+ PULL_IMAGE_JOB_TITLE, wizard.getImageId())) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
final String id = wizard.getImageId();
- monitor.beginTask(DVMessages.getString(PULL_IMAGE_JOB_TITLE), 1);
+ monitor.beginTask(DVMessages.getString(PULL_IMAGE_JOB_TASK),
+ IProgressMonitor.UNKNOWN);
// pull the image and let the progress
// handler refresh the images when done
try {
((DockerConnection) connection).pullImage(id,
new ImagePullProgressHandler(connection, id));
- monitor.worked(1);
} catch (final DockerException e) {
Display.getDefault().syncExec(new Runnable() {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PushImageCommandHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PushImageCommandHandler.java
index 66e6d09571..2046a52bc0 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PushImageCommandHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PushImageCommandHandler.java
@@ -33,7 +33,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class PushImageCommandHandler extends AbstractHandler implements
IHandler {
- private final static String PUSH_IMAGE_JOB_TITLE = "ImagePush.msg"; //$NON-NLS-1$
+ private final static String PUSH_IMAGE_JOB_TITLE = "ImagePush.title"; //$NON-NLS-1$
+ private final static String PUSH_IMAGE_JOB_TASK = "ImagePush.msg"; //$NON-NLS-1$
private static final String ERROR_PUSHING_IMAGE = "ImagePushError.msg"; //$NON-NLS-1$
private IDockerConnection connection;
@@ -55,19 +56,19 @@ public class PushImageCommandHandler extends AbstractHandler implements
}
private void performPushImage(final ImagePush wizard) {
- final Job pushImageJob = new Job(
- DVMessages.getString(PUSH_IMAGE_JOB_TITLE)) {
+ final Job pushImageJob = new Job(DVMessages.getFormattedString(
+ PUSH_IMAGE_JOB_TITLE, wizard.getImageTag())) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
final String tag = wizard.getImageTag();
- monitor.beginTask(DVMessages.getString(PUSH_IMAGE_JOB_TITLE), 1);
+ monitor.beginTask(DVMessages.getString(PUSH_IMAGE_JOB_TASK),
+ IProgressMonitor.UNKNOWN);
// pull the image and let the progress
// handler refresh the images when done
try {
((DockerConnection) connection).pushImage(tag,
new ImagePushProgressHandler(connection, tag));
- monitor.worked(1);
} catch (final DockerException e) {
Display.getDefault().syncExec(new Runnable() {
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 fe458a3ad7..289075fac9 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
@@ -114,8 +114,10 @@ ImageDownloadComplete.msg=Download complete
ImageDownloadingImage.msg=Downloading image id: {0}
ImageDownloadingJobName.msg=Pulling docker image - {0}
ImageDownloading.msg=Downloading
+ImagePulling.msg=Pulling
+ImagePullComplete.msg=Pull complete
ImageDownloadingAlreadyExists.msg=Already exists
-ImageDownloadingVerified.msg=The image you are pulling has been verified
+ImageDownloadingVerified.msg=verified
ImageUploadComplete.msg=Image successfully pushed
ImageUploadAlreadyComplete.msg=already pushed, skipping
@@ -170,7 +172,9 @@ ContainerCommitError.msg=Error committing container
ImageBuild.msg=Building Image
ImagePull.msg=Pulling Image
+ImagePull.title=Pulling Image <{0}>
ImagePush.msg=Pushing Image
+ImagePush.title=Pushing Image <{0}>
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/ImagePullProgressHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/ImagePullProgressHandler.java
index 1e414eb3fb..c01c034d50 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/ImagePullProgressHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/ImagePullProgressHandler.java
@@ -29,6 +29,8 @@ public class ImagePullProgressHandler implements IDockerProgressHandler {
private final static String IMAGE_DOWNLOADING_JOBNAME = "ImageDownloadingJobName.msg"; //$NON-NLS-1$
private final static String IMAGE_DOWNLOADING_IMAGE = "ImageDownloadingImage.msg"; //$NON-NLS-1$
private final static String IMAGE_DOWNLOADING = "ImageDownloading.msg"; //$NON-NLS-1$
+ private final static String IMAGE_PULLING = "ImagePulling.msg"; //$NON-NLS-1$
+ private final static String IMAGE_PULL_COMPLETE = "ImagePullComplete.msg"; //$NON-NLS-1$
private final static String IMAGE_DOWNLOADING_ALREADY_EXISTS = "ImageDownloadingAlreadyExists.msg"; //$NON-NLS-1$
private final static String IMAGE_DOWNLOADING_VERIFIED = "ImageDownloadingVerified.msg"; //$NON-NLS-1$
@@ -54,14 +56,21 @@ public class ImagePullProgressHandler implements IDockerProgressHandler {
ProgressJob p = progressJobs.get(id);
if (p == null) {
String status = message.status();
- if (status
+ if (status.contains(DVMessages.getString(IMAGE_PULLING))) {
+ // do nothing
+ } else if (status
.equals(DVMessages.getString(IMAGE_DOWNLOAD_COMPLETE))
- || status.equals(DVMessages
+ || status.contains(DVMessages
.getString(IMAGE_DOWNLOADING_ALREADY_EXISTS))
- || status.equals(DVMessages
- .getString(IMAGE_DOWNLOADING_VERIFIED))) {
+ || status.contains(DVMessages
+ .getString(IMAGE_DOWNLOADING_VERIFIED))
+ || status.equals(
+ DVMessages.getString(IMAGE_PULL_COMPLETE))) {
+ // an image is fully loaded, update the image list
connection.getImages(true);
- } else {
+ } else if (status
+ .startsWith(DVMessages.getString(IMAGE_DOWNLOADING))) {
+ // we have a new download in progress, track it
ProgressJob newJob = new ProgressJob(
DVMessages.getFormattedString(
IMAGE_DOWNLOADING_JOBNAME, image),
@@ -75,16 +84,15 @@ public class ImagePullProgressHandler implements IDockerProgressHandler {
} else {
String status = message.status();
- if (status
- .equals(DVMessages.getString(IMAGE_DOWNLOAD_COMPLETE))
- || status.equals(DVMessages
+ if (status.equals(DVMessages.getString(IMAGE_DOWNLOAD_COMPLETE))
+ || status.contains(DVMessages
.getString(IMAGE_DOWNLOADING_ALREADY_EXISTS))
- || status.equals(DVMessages
+ || status.contains(DVMessages
.getString(IMAGE_DOWNLOADING_VERIFIED))) {
p.setPercentageDone(100);
connection.getImages(true);
- } else if (status.startsWith(DVMessages
- .getString(IMAGE_DOWNLOADING))) {
+ } else if (status
+ .startsWith(DVMessages.getString(IMAGE_DOWNLOADING))) {
IDockerProgressDetail detail = message.progressDetail();
if (detail != null) {
if (detail.current() > 0) {

Back to the top