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.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.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadProgressEvent.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadStatus.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java34
3 files changed, 94 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadProgressEvent.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadProgressEvent.java
new file mode 100644
index 000000000..fdc1b7c39
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadProgressEvent.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.repository;
+
+import java.net.URI;
+import java.util.EventObject;
+
+public class DownloadProgressEvent extends EventObject {
+
+ private static final long serialVersionUID = -7880532297074721824L;
+ private ProgressStatistics stat;
+
+ public DownloadProgressEvent(ProgressStatistics stat) {
+ super(stat);
+ this.stat = stat;
+ }
+
+ public String getFileName() {
+ return stat.m_fileName;
+ }
+
+ public URI getDownloadURI() {
+ return stat.m_uri;
+ }
+
+ public long getAverageSpeed() {
+ return stat.getAverageSpeed();
+ }
+
+ public long getRecentSpeed() {
+ return stat.getRecentSpeed();
+ }
+
+ public long getFinished() {
+ return stat.m_current;
+ }
+
+ public double getPercentage() {
+ return stat.getPercentage();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadStatus.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadStatus.java
index de0597da7..ddcccb7ba 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadStatus.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/DownloadStatus.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 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
@@ -74,4 +74,19 @@ public class DownloadStatus extends Status {
public long getLastModified() {
return lastModified;
}
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append(' ');
+ sb.append("LastModified="); //$NON-NLS-1$
+ sb.append(getLastModified());
+ sb.append(' ');
+ sb.append("FileSize="); //$NON-NLS-1$
+ sb.append(getFileSize() == UNKNOWN_SIZE ? "Unknown size" : getFileSize()); //$NON-NLS-1$
+ sb.append(' ');
+ sb.append("Download rate="); //$NON-NLS-1$
+ sb.append(getTransferRate() == UNKNOWN_RATE ? "Unknown rate" : getTransferRate()); //$NON-NLS-1$
+ return sb.toString();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
index 6169fb36d..dd8c89a89 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Cloudsmith Inc.
+ * Copyright (c) 2006, 2012 Cloudsmith Inc.
* 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
@@ -16,6 +16,9 @@ import java.net.URI;
import java.text.NumberFormat;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.osgi.util.NLS;
/**
@@ -30,6 +33,8 @@ public class ProgressStatistics {
private static final int SPEED_RESOLUTION = 1000;
+ private static IProvisioningAgent agent = null;
+
private static String convert(long amount) {
NumberFormat fmt = NumberFormat.getInstance();
if (amount < 1024)
@@ -42,13 +47,27 @@ public class ProgressStatistics {
return fmt.format(((double) amount) / (1024 * 1024)) + "MB"; //$NON-NLS-1$
}
- private final String m_fileName;
+ public static void setProvisioningAgent(IProvisioningAgent agent) {
+ ProgressStatistics.agent = agent;
+ }
+
+ private void publishEvent(DownloadProgressEvent event) {
+ if (agent == null) {
+ agent = ServiceHelper.getService(Activator.getContext(), IProvisioningAgent.class);
+ }
+ IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ if (eventBus != null) {
+ eventBus.publishEvent(event);
+ }
+ }
+
+ final String m_fileName;
private final long m_total;
private final long m_startTime;
- private long m_current;
+ long m_current;
private long m_lastReportTime;
@@ -58,7 +77,7 @@ public class ProgressStatistics {
private long m_recentSpeedMapKey;
- private URI m_uri;
+ URI m_uri;
public ProgressStatistics(URI uri, String fileName, long total) {
m_startTime = System.currentTimeMillis();
@@ -125,6 +144,11 @@ public class ProgressStatistics {
}
public synchronized String report() {
+ publishEvent(new DownloadProgressEvent(this));
+ return createReportString();
+ }
+
+ private String createReportString() {
String uriString = m_uri.toString();
if (m_fileName != null && uriString.endsWith(m_fileName))
uriString = uriString.substring(0, uriString.lastIndexOf(m_fileName));
@@ -145,7 +169,7 @@ public class ProgressStatistics {
}
public String toString() {
- return report();
+ return createReportString();
}
synchronized private void registerRecentSpeed(long key, long inc) {

Back to the top