Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoribull2010-02-04 18:58:40 -0500
committeribull2010-02-04 18:58:40 -0500
commit9ca2c2a2a099f684074bbd83ffe0558ff5e56f64 (patch)
treef3103f43b46f6384c43e93c39529c0a610d78740 /bundles/org.eclipse.equinox.p2.artifact.repository
parent2476ddbea1cf40a85520fb9168aa59e2d68b48f2 (diff)
downloadrt.equinox.p2-9ca2c2a2a099f684074bbd83ffe0558ff5e56f64.tar.gz
rt.equinox.p2-9ca2c2a2a099f684074bbd83ffe0558ff5e56f64.tar.xz
rt.equinox.p2-9ca2c2a2a099f684074bbd83ffe0558ff5e56f64.zip
bug 274025: [publisher] p2 metadata generator does not scale
https://bugs.eclipse.org/bugs/show_bug.cgi?id=274025 This adds a batch process to ArtifactRepository which, in the simple artifact repository, will do the save at the end. The publisher is configured to use the batch process now.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java45
2 files changed, 78 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
index a8936f302..e1fb37a64 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
@@ -45,6 +45,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
// keep a list of the repositories that we have successfully loaded
private List<ChildInfo> loadedRepos = new ArrayList<ChildInfo>();
private IArtifactRepositoryManager manager;
+ private boolean disableSave;
/**
* Create a Composite repository in memory.
@@ -79,7 +80,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
return manager;
}
- /*
+ /**
* This is only called by the parser when loading a repository.
*/
CompositeArtifactRepository(IArtifactRepositoryManager manager, CompositeRepositoryState state) {
@@ -89,7 +90,10 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
addChild(state.getChildren()[i], false);
}
- CompositeArtifactRepository(IArtifactRepositoryManager manager, URI location, String repositoryName, Map<String, String> properties) {
+ /**
+ * @noreference This constructor is not intended to be referenced by clients.
+ */
+ protected CompositeArtifactRepository(IArtifactRepositoryManager manager, URI location, String repositoryName, Map<String, String> properties) {
super(repositoryName, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties);
this.manager = manager;
save();
@@ -393,7 +397,15 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
return applicable.toArray(new IArtifactRequest[applicable.size()]);
}
- private void save() {
+ /**
+ * This method is only protected for testing purposes
+ *
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ protected void save() {
+ if (disableSave)
+ return;
if (!isModifiable())
return;
boolean compress = "true".equalsIgnoreCase(properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
@@ -551,4 +563,29 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
CompoundQueryable<IArtifactDescriptor> queryable = new CompoundQueryable<IArtifactDescriptor>(repos);
return queryable;
}
+
+ public IStatus executeBatch(Runnable runnable) {
+ IStatus result = null;
+ synchronized (this) {
+ try {
+ disableSave = true;
+ runnable.run();
+ } catch (Throwable e) {
+ result = new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
+ } finally {
+ disableSave = false;
+ try {
+ save();
+ } catch (Exception e) {
+ if (result != null)
+ result = new MultiStatus(Activator.ID, IStatus.ERROR, new IStatus[] {result}, e.getMessage(), e);
+ else
+ result = new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
+ }
+ }
+ }
+ if (result == null)
+ result = Status.OK_STATUS;
+ return result;
+ }
}
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 127c7851b..4f9a0c33c 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
@@ -216,6 +216,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
private MirrorSelector mirrors;
+ private boolean disableSave = false;
+
static void delete(File toDelete) {
if (toDelete.isDirectory()) {
File[] children = toDelete.listFiles();
@@ -437,11 +439,13 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
simple = createInternalDescriptor(descriptor);
if (simple.getRepositoryProperty(SimpleArtifactDescriptor.ARTIFACT_REFERENCE) == null) {
File file = getArtifactFile(descriptor);
- if (file == null)
- return false;
- delete(file);
- if (file.exists())
- return false;
+ if (file != null) {
+ // If the file != null remove it, otherwise just remove
+ // the descriptor
+ delete(file);
+ if (file.exists())
+ return false;
+ }
}
boolean result = artifactDescriptors.remove(descriptor);
if (result)
@@ -900,11 +904,13 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
public void save() {
- boolean compress = "true".equalsIgnoreCase(properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
+ if (disableSave)
+ return;
+ boolean compress = "true".equalsIgnoreCase((String) properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
save(compress);
}
- public void save(boolean compress) {
+ private void save(boolean compress) {
assertModifiable();
OutputStream os = null;
try {
@@ -990,4 +996,29 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
return query.perform(artifactMap.keySet().iterator());
}
+
+ public IStatus executeBatch(Runnable runnable) {
+ IStatus result = null;
+ synchronized (this) {
+ try {
+ disableSave = true;
+ runnable.run();
+ } catch (Throwable e) {
+ result = new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
+ } finally {
+ disableSave = false;
+ try {
+ save();
+ } catch (Exception e) {
+ if (result != null)
+ result = new MultiStatus(Activator.ID, IStatus.ERROR, new IStatus[] {result}, e.getMessage(), e);
+ else
+ result = new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
+ }
+ }
+ }
+ if (result == null)
+ result = Status.OK_STATUS;
+ return result;
+ }
}

Back to the top