Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengxin Zhu2012-01-12 02:27:54 -0500
committerMengxin Zhu2012-01-12 02:51:38 -0500
commit04549b1dd45c808514d61d55185d55a7a8b7fb63 (patch)
treee5cd3123c13bc9d2582cdcc15cd812e7f7bdaf67 /bundles/org.eclipse.equinox.p2.artifact.repository
parentc56d3086f43989513d7e3d2a149a0b6b1f82e9a7 (diff)
downloadrt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.tar.gz
rt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.tar.xz
rt.equinox.p2-04549b1dd45c808514d61d55185d55a7a8b7fb63.zip
316328 engine should be more verbose while performing an installationv20120112-1825
1. the event of phase starts and finishes 2. download events, including how many artifacts to be downloaded, how many artifacts to be downloaded from a specific repository, the mirror request(download) result, download progress event(a wrapper of ProgressStatistics) 3. the events before/after configuring/unconfiguring an IU Signed-off-by: Mengxin Zhu <kane.zhu@windriver.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorEvent.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java28
4 files changed, 76 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
index ecda9a06c..485fee5c6 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
@@ -41,6 +41,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.persistence,
org.eclipse.equinox.internal.p2.repository,
org.eclipse.equinox.internal.p2.repository.helpers,
+ org.eclipse.equinox.internal.provisional.p2.core.eventbus,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.core.spi;version="[2.0.0,3.0.0)",
@@ -49,7 +50,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.repository.artifact.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.spi;version="[2.0.0,3.0.0)",
org.eclipse.internal.provisional.equinox.p2.jarprocessor;resolution:=optional,
- org.eclipse.osgi.service.datalocation;version="[1.3.0, 2.0.0)",
+ org.eclipse.osgi.service.datalocation;version="[1.3.0,2.0.0)",
org.eclipse.osgi.signedcontent;version="1.0.0",
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.3.0",
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorEvent.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorEvent.java
new file mode 100644
index 000000000..83213c857
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorEvent.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.repository;
+
+import java.util.EventObject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+
+public class MirrorEvent extends EventObject {
+
+ private static final long serialVersionUID = -2958057566692590943L;
+
+ private IStatus downloadStatus;
+
+ private IArtifactRepository repository;
+
+ private IArtifactDescriptor descriptor;
+
+ public MirrorEvent(IArtifactRepository repo, IArtifactDescriptor descriptor, IStatus downloadStatus) {
+ super(descriptor);
+ this.repository = repo;
+ this.descriptor = descriptor;
+ this.downloadStatus = downloadStatus;
+ }
+
+ public IArtifactRepository getSourceRepository() {
+ return repository;
+ }
+
+ public IArtifactDescriptor getMirroredDescriptor() {
+ return descriptor;
+ }
+
+ public IStatus getDownloadStatus() {
+ return downloadStatus;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
index b0daef205..499830240 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,6 +23,7 @@ import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifact
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.repository.Transport;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
@@ -192,6 +193,9 @@ public class MirrorRequest extends ArtifactRequest {
lastResult = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
allResults.add(lastResult);
} while (lastResult.getSeverity() == IStatus.ERROR && lastResult.getCode() == IArtifactRepository.CODE_RETRY && counter++ < MAX_RETRY_REQUEST);
+ IProvisioningEventBus bus = (IProvisioningEventBus) source.getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME);
+ if (bus != null)
+ bus.publishEvent(new MirrorEvent(source, sourceDescriptor, lastResult.isOK() ? lastResult : (allResults.getChildren().length <= 1 ? lastResult : allResults)));
if (lastResult.isOK()) {
collectStats(sourceDescriptor, monitor);
return lastResult;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 79970410d..0c4c1dd76 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,12 +25,13 @@ import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5Verifier;
import org.eclipse.equinox.internal.p2.artifact.repository.*;
+import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
import org.eclipse.equinox.internal.p2.artifact.repository.Messages;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator;
import org.eclipse.equinox.internal.p2.metadata.index.IndexProvider;
-import org.eclipse.equinox.internal.p2.repository.Transport;
+import org.eclipse.equinox.internal.p2.repository.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -557,18 +558,28 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
// TODO: optimize and ensure manifest is written first
File zipFile = null;
+ long start = System.currentTimeMillis();
+ long totalArtifactSize = 0;
try {
zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null);
FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder));
FileInputStream fis = new FileInputStream(zipFile);
- FileUtils.copyStream(fis, true, destination, false);
+ totalArtifactSize += FileUtils.copyStream(fis, true, destination, false);
} catch (IOException e) {
return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, e.getMessage()));
} finally {
if (zipFile != null)
zipFile.delete();
}
- return reportStatus(descriptor, destination, Status.OK_STATUS);
+ long end = System.currentTimeMillis();
+ DownloadStatus statusWithDownloadSpeed = new DownloadStatus(IStatus.OK, Activator.ID, Status.OK_STATUS.getMessage());
+ try {
+ statusWithDownloadSpeed.setFileSize(totalArtifactSize);
+ statusWithDownloadSpeed.setTransferRate(totalArtifactSize / Math.max((end - start), 1) * 1000);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ return reportStatus(descriptor, destination, statusWithDownloadSpeed);
}
//download from the best available mirror
@@ -607,8 +618,9 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
int expected_loops = new Double(in.length() / bufferSize).intValue() + 1; // +1: also count the initial run
SubMonitor sub = SubMonitor.convert(monitor, Messages.downloading + in.getName(), expected_loops);
// Be optimistic about the outcome of this...
- IStatus status = Status.OK_STATUS;
+ IStatus status = new DownloadStatus(IStatus.OK, Activator.ID, Status.OK_STATUS.getMessage());
try {
+ long start = System.currentTimeMillis();
FileInputStream stream = new FileInputStream(in);
try {
int len;
@@ -619,6 +631,10 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
} finally {
stream.close();
}
+ long end = System.currentTimeMillis();
+ ((DownloadStatus) status).setFileSize(in.length());
+ ((DownloadStatus) status).setLastModified(in.lastModified());
+ ((DownloadStatus) status).setTransferRate(in.length() / Math.max((end - start), 1) * 1000);
} catch (IOException ioe) {
status = new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_copying_local_file, in.getAbsolutePath()), ioe);
}
@@ -732,6 +748,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
+ ProgressStatistics.setProvisioningAgent(getProvisioningAgent());
+
final MultiStatus overallStatus = new MultiStatus(Activator.ID, IStatus.OK, null, null);
LinkedList<IArtifactRequest> requestsPending = new LinkedList<IArtifactRequest>(Arrays.asList(requests));

Back to the top