summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengxin Zhu2011-11-29 03:07:40 (EST)
committerMengxin Zhu2011-11-29 03:12:22 (EST)
commita2911b94ef0f39554e5ff16786d3543061b648eb (patch)
tree11256b415a967102fe0fad6a0207d528dceeff6a
parent6af7b1119469961d1d702921249cdaea63fc535e (diff)
downloadrt.equinox.p2-a2911b94ef0f39554e5ff16786d3543061b648eb.zip
rt.equinox.p2-a2911b94ef0f39554e5ff16786d3543061b648eb.tar.gz
rt.equinox.p2-a2911b94ef0f39554e5ff16786d3543061b648eb.tar.bz2
Support customizable downloading stats.
Bug 364929 supports a way to specify different parameters for collecting downloading statsbased on different host runtime, such as the package name of Eclipse, os, ws and arch of Eclipse is running. Signed-off-by: Mengxin Zhu <kane.zhu@windriver.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepositoryManager.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java2
10 files changed, 63 insertions, 9 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
index e75e6b4..33e2095 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
@@ -42,7 +42,11 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
}
public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties) {
- return new MirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties, getTransport());
+ return createMirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties, null);
+ }
+
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties, String downloadStatsParameters) {
+ return new MirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties, getTransport(), downloadStatsParameters);
}
public IArtifactRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException {
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 b0daef2..556a732 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
@@ -54,6 +54,10 @@ public class MirrorRequest extends ArtifactRequest {
* for reporting download statistics for that artifact.
*/
private static final String PROP_DOWNLOAD_STATS = "download.stats"; //$NON-NLS-1$
+ /**
+ * The additional parameters for downloading statistics
+ */
+ private String downloadStatsParamters;
protected final IArtifactRepository target;
@@ -62,6 +66,10 @@ public class MirrorRequest extends ArtifactRequest {
protected IArtifactDescriptor descriptor;
public MirrorRequest(IArtifactKey key, IArtifactRepository targetRepository, Map<String, String> targetDescriptorProperties, Map<String, String> targetRepositoryProperties, Transport transport) {
+ this(key, targetRepository, targetDescriptorProperties, targetRepositoryProperties, transport, null);
+ }
+
+ public MirrorRequest(IArtifactKey key, IArtifactRepository targetRepository, Map<String, String> targetDescriptorProperties, Map<String, String> targetRepositoryProperties, Transport transport, String statsParameters) {
super(key, transport);
target = targetRepository;
if (targetDescriptorProperties == null || targetDescriptorProperties.isEmpty()) {
@@ -77,6 +85,7 @@ public class MirrorRequest extends ArtifactRequest {
this.targetRepositoryProperties = new HashMap<String, String>();
this.targetRepositoryProperties.putAll(targetRepositoryProperties);
}
+ this.downloadStatsParamters = statsParameters;
}
public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) {
@@ -214,6 +223,13 @@ public class MirrorRequest extends ArtifactRequest {
URI statsURI;
try {
statsURI = URIUtil.append(new URI(statsRoot), statsProperty);
+ if (downloadStatsParamters != null) {
+ try {
+ statsURI = new URI(statsURI.getScheme(), statsURI.getUserInfo(), statsURI.getHost(), statsURI.getPort(), statsURI.getPath(), statsURI.getQuery() == null ? downloadStatsParamters : downloadStatsParamters + "&" + statsURI.getQuery(), statsURI.getFragment()); //$NON-NLS-1$
+ } catch (URISyntaxException e) {
+ LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unable to create download statistics due to invalid URL query: " + statsRoot + " suffix: " + statsProperty + " query: " + downloadStatsParamters)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
} catch (URISyntaxException e) {
LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unable to report download statistics due to invalid URL: " + statsRoot + " suffix: " + statsProperty)); //$NON-NLS-1$ //$NON-NLS-2$
return;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java
index 74f18b1..76dc887 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Sonatype, Inc. - transport split
+ * Wind River - continue development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.repository;
@@ -26,7 +27,11 @@ public class RawMirrorRequest extends MirrorRequest {
protected IArtifactDescriptor sourceDescriptor, targetDescriptor;
public RawMirrorRequest(IArtifactDescriptor sourceDescriptor, IArtifactDescriptor targetDescriptor, IArtifactRepository targetRepository, Transport transport) {
- super(sourceDescriptor.getArtifactKey(), targetRepository, null, null, transport);
+ this(sourceDescriptor, targetDescriptor, targetRepository, transport, null);
+ }
+
+ public RawMirrorRequest(IArtifactDescriptor sourceDescriptor, IArtifactDescriptor targetDescriptor, IArtifactRepository targetRepository, Transport transport, String statsParameters) {
+ super(sourceDescriptor.getArtifactKey(), targetRepository, null, null, transport, statsParameters);
this.sourceDescriptor = sourceDescriptor;
this.targetDescriptor = targetDescriptor;
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
index 720280b..92d9198 100644
--- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
@@ -14,7 +14,7 @@ Export-Package: org.eclipse.equinox.internal.p2.engine;
org.eclipse.pde.build,
org.eclipse.equinox.p2.repository.tools",
org.eclipse.equinox.internal.p2.engine.phases;x-friends:="org.eclipse.equinox.p2.director.app,org.eclipse.equinox.p2.repository.tools,org.eclipse.equinox.p2.ui.sdk.scheduler",
- org.eclipse.equinox.p2.engine;version="2.0.0",
+ org.eclipse.equinox.p2.engine;version="2.2.0",
org.eclipse.equinox.p2.engine.query;version="2.0.0",
org.eclipse.equinox.p2.engine.spi;version="2.0.0"
Require-Bundle: org.eclipse.equinox.common,
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java
index 79655db..a1ce30f 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java
@@ -146,6 +146,12 @@ public interface IProfile extends IQueryable<IInstallableUnit> {
public static final String STATE_PROP_TAG = "org.eclipse.equinox.p2.state.tag"; //$NON-NLS-1$
/**
+ * Profile property constant for additional parameters of the downloading stats(e.g., package=jee&os=linux).
+ * @since 2.2
+ */
+ public static final String PROP_STATS_PARAMETERS = "org.eclipse.equinox.p2.stats.parameters"; //$NON-NLS-1$
+
+ /**
* Returns the provisioning agent that manages this profile
* @return A provisioning agent.
*/
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
index 57818e5..a216e05 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
@@ -43,6 +43,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
private static final String NATIVE_ARTIFACTS = "nativeArtifacts"; //$NON-NLS-1$
private static final String NATIVE_TYPE = "org.eclipse.equinox.p2.native"; //$NON-NLS-1$
private static final String PARM_OPERAND = "operand"; //$NON-NLS-1$
+ private static final String PARM_PROFILE = "profile"; //$NON-NLS-1$
protected class CollectNativesAction extends ProvisioningAction {
public IStatus execute(Map<String, Object> parameters) {
@@ -57,8 +58,13 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
@SuppressWarnings("unchecked")
List<IArtifactRequest> artifactRequests = (List<IArtifactRequest>) parameters.get(NATIVE_ARTIFACTS);
+ IProfile profile = (IProfile) parameters.get(PARM_PROFILE);
+ String statsParameter = null;
+ if (profile != null)
+ statsParameter = profile.getProperty(IProfile.PROP_STATS_PARAMETERS);
+
for (IArtifactKey keyToDownload : toDownload) {
- IArtifactRequest request = manager.createMirrorRequest(keyToDownload, destinationArtifactRepository, null, null);
+ IArtifactRequest request = manager.createMirrorRequest(keyToDownload, destinationArtifactRepository, null, null, statsParameter);
artifactRequests.add(request);
}
return Status.OK_STATUS;
diff --git a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF
index 692c9c6..2b2f15f 100644
--- a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF
@@ -28,7 +28,7 @@ Export-Package: org.eclipse.equinox.internal.p2.persistence;
org.eclipse.equinox.p2.updatesite",
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.p2.repository;version="2.0.0",
- org.eclipse.equinox.p2.repository.artifact;version="2.0.0",
+ org.eclipse.equinox.p2.repository.artifact;version="2.1.0",
org.eclipse.equinox.p2.repository.artifact.spi;version="2.0.0",
org.eclipse.equinox.p2.repository.metadata;version="2.0.0",
org.eclipse.equinox.p2.repository.metadata.spi;version="2.0.0",
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepositoryManager.java
index c11690b..7ea8d59 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepositoryManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River - continuing development
*******************************************************************************/
package org.eclipse.equinox.p2.repository.artifact;
@@ -60,6 +61,22 @@ public interface IArtifactRepositoryManager extends IRepositoryManager<IArtifact
public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties);
/**
+ * Return a new request to mirror the given artifact into the destination repository.
+ * @param key the artifact to mirror
+ * @param destination the destination where the artifact will be mirrored
+ * @param destinationDescriptorProperties additional properties for use in creating the repository's ArtifactDescriptor,
+ * or <code>null</code> to indicate no additional properties are needed
+ * @param destinationRepositoryProperties additional repository specific properties for use in creating the repositor's ArtifactDescriptor,
+ * , or <code>null</code> to indicate no additional properties are needed
+ * @param downloadStatsParameters additional customizable parameters for downloading statistics
+ * , or <code>null</code> to indicate no additional customizable stats parameters
+ * @return the newly created request object
+ * @see IArtifactRepositoryManager#createMirrorRequest(IArtifactKey, IArtifactRepository, Map, Map)
+ * @since 2.1
+ */
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties, String downloadStatsParameters);
+
+ /**
* Creates and returns a new empty artifact repository of the given type at
* the given location.
* <p>
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
index 5fe41c2..943a73b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
@@ -80,7 +80,7 @@ public class CollectAction extends ProvisioningAction {
for (IArtifactKey key : toDownload) {
if (!aggregatedRepositoryView.contains(key)) {
Map<String, String> repositoryProperties = CollectAction.createArtifactDescriptorProperties(installableUnit);
- requests.add(Util.getArtifactRepositoryManager(agent).createMirrorRequest(key, bundlePool, null, repositoryProperties));
+ requests.add(Util.getArtifactRepositoryManager(agent).createMirrorRequest(key, bundlePool, null, repositoryProperties, profile.getProperty(IProfile.PROP_STATS_PARAMETERS)));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java
index 7dd742b..bf9d56e 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java
@@ -57,7 +57,7 @@ public class CollectAction extends ProvisioningAction {
int count = 0;
for (IArtifactKey key : toDownload) {
//TODO Here there are cases where the download is not necessary again because what needs to be done is just a configuration step
- requests[count++] = Util.getArtifactRepositoryManager(agent).createMirrorRequest(key, destination, null, null);
+ requests[count++] = Util.getArtifactRepositoryManager(agent).createMirrorRequest(key, destination, null, null, profile.getProperty(IProfile.PROP_STATS_PARAMETERS));
}
if (requests.length == count)