Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2007-12-01 20:14:22 +0000
committerPascal Rapicault2007-12-01 20:14:22 +0000
commitd0a87c0ab5ba1ed04726b4ff0380ab475f1952b9 (patch)
tree331d4c90dc1aa5f0e25629b12a0bae8a1882e287 /bundles/org.eclipse.equinox.p2.garbagecollector/src
parent3b034e4e81fe79a01ff62efa80df3a918ee51c00 (diff)
downloadrt.equinox.p2-d0a87c0ab5ba1ed04726b4ff0380ab475f1952b9.tar.gz
rt.equinox.p2-d0a87c0ab5ba1ed04726b4ff0380ab475f1952b9.tar.xz
rt.equinox.p2-d0a87c0ab5ba1ed04726b4ff0380ab475f1952b9.zip
Release additional cleanups from bug 210462
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.garbagecollector/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/CoreGarbageCollector.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GCActivator.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GarbageCollector.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/IMarkSetProvider.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/Messages.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/RootSet.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/messages.properties10
7 files changed, 52 insertions, 129 deletions
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/CoreGarbageCollector.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/CoreGarbageCollector.java
index 80f8d22dd..dee84c045 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/CoreGarbageCollector.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/CoreGarbageCollector.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.garbagecollector;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
@@ -29,14 +27,14 @@ public class CoreGarbageCollector {
/**
* Given a list of IArtifactKeys and an IArtifactRepository, removes all artifacts
- * in aRepository that are not mapped to by an IArtifactKey in rootSet
+ * in aRepository that are not mapped to by an IArtifactKey in markSet
*/
- public synchronized void clean(IArtifactKey[] rootSet, IArtifactRepository aRepository) {
+ public synchronized void clean(IArtifactKey[] markSet, IArtifactRepository aRepository) {
IArtifactKey[] repositoryKeys = aRepository.getArtifactKeys();
for (int j = 0; j < repositoryKeys.length; j++) {
boolean artifactIsActive = false;
- for (int k = 0; k < rootSet.length; k++) {
- if (repositoryKeys[j].equals(rootSet[k])) {
+ for (int k = 0; k < markSet.length; k++) {
+ if (repositoryKeys[j].equals(markSet[k])) {
artifactIsActive = true;
break;
}
@@ -44,21 +42,17 @@ public class CoreGarbageCollector {
if (!artifactIsActive) {
aRepository.removeDescriptor(repositoryKeys[j]);
if (debugMode) {
- LogHelper.log(new Status(IStatus.INFO, GCActivator.ID, Messages.CoreGarbageCollector_0 + repositoryKeys[j]));
+ Tracing.debug("Key removed:" + repositoryKeys[j]); //$NON-NLS-1$
}
}
}
}
- /**
+ /*
* If set to true, debug mode will log information about each artifact deleted by the CoreGarbageCollector
* @param inDebugMode
*/
public static void setDebugMode(boolean inDebugMode) {
- if (inDebugMode) {
- LogHelper.log(new Status(Status.INFO, GCActivator.ID, Messages.CoreGarbageCollector_1));
- }
debugMode = inDebugMode;
}
-
}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GCActivator.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GCActivator.java
index 55e1793dd..0629d51d0 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GCActivator.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GCActivator.java
@@ -11,7 +11,10 @@
package org.eclipse.equinox.p2.garbagecollector;
import java.util.EventObject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
import org.eclipse.equinox.p2.core.eventbus.SynchronousProvisioningListener;
import org.eclipse.equinox.p2.engine.*;
@@ -50,7 +53,7 @@ public class GCActivator implements BundleActivator {
private void registerGCTrigger() {
ProvisioningEventBus eventBus = (ProvisioningEventBus) getService(GCActivator.context, ProvisioningEventBus.class.getName());
if (eventBus == null) {
- System.err.println(Messages.GCActivator_0); //TODO Clean up.
+ LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.Missing_bus));
}
eventBus.addListener(busListener = new SynchronousProvisioningListener() {
//The GC is triggered when an uninstall event occured during a "transaction" and the transaction is committed.
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GarbageCollector.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GarbageCollector.java
index b5950cdfb..77b3b801c 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GarbageCollector.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/GarbageCollector.java
@@ -22,11 +22,11 @@ import org.eclipse.equinox.p2.metadata.IArtifactKey;
* The main control point for the p2 garbage collector. Takes a Profile and runs the CoreGarbageCollector with the
* appropriate MarkSets for the repositories used by that Profile.
*
- * Takes the profile passed in and creates a set (rootSetMap) that maps the artifact repositories it uses to the
+ * Takes the profile passed in and creates a set (markSet) that maps the artifact repositories it uses to the
* artifact keys its IUs hold. This is done by getting MarkSets from all registered IMarkSetProviders.
*
* Then, the MarkSets are obtained for every other registered Profile in a similar fashion. Each MarkSet is
- * checked to see if its artifact repository is already a key in rootSetMap. If so, that MarkSet's artifact keys
+ * checked to see if its artifact repository is already a key in markSet. If so, that MarkSet's artifact keys
* are added to the list that is mapped to by the artifact repository.
*/
public class GarbageCollector {
@@ -64,29 +64,7 @@ public class GarbageCollector {
continue;
}
- try {
- ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, profileToGC);
- SafeRunner.run(providerExecutor);
- MarkSet[] inProfileRootSets = providerExecutor.getResult();
- if (inProfileRootSets[0] == null)
- return false;
-
- for (int j = 0; j < inProfileRootSets.length; j++) {
- if (inProfileRootSets[j] == null) {
- continue;
- }
- Collection keys = (Collection) markSet.get(inProfileRootSets[j].getRepo());
- if (keys == null) {
- keys = new HashSet();
- markSet.put(inProfileRootSets[j].getRepo(), keys);
- }
- addKeys(keys, inProfileRootSets[j].getKeys());
- }
-
- } catch (ClassCastException e) {
- LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.CoreGarbageCollector_0, e));
- continue;
- }
+ contributeMarkSets(runAttribute, profileToGC, true);
}
return true;
}
@@ -96,8 +74,8 @@ public class GarbageCollector {
while (keyIterator.hasNext()) {
IArtifactRepository nextRepo = (IArtifactRepository) keyIterator.next();
IArtifactKey[] keys = (IArtifactKey[]) ((Collection) markSet.get(nextRepo)).toArray(new IArtifactKey[0]);
- MarkSet aRootSet = new MarkSet(keys, nextRepo);
- new CoreGarbageCollector().clean(aRootSet.getKeys(), aRootSet.getRepo());
+ MarkSet aMarkSet = new MarkSet(keys, nextRepo);
+ new CoreGarbageCollector().clean(aMarkSet.getKeys(), aMarkSet.getRepo());
}
}
@@ -119,7 +97,7 @@ public class GarbageCollector {
Profile[] registeredProfiles = profileRegistry.getProfiles();
for (int j = 0; j < registeredProfiles.length; j++) {
- contributeRootSets(runAttribute, registeredProfiles[j]);
+ contributeMarkSets(runAttribute, registeredProfiles[j], false);
}
}
}
@@ -127,7 +105,7 @@ public class GarbageCollector {
private class ParameterizedSafeRunnable implements ISafeRunnable {
IConfigurationElement cfg;
Profile aProfile;
- MarkSet[] aProfileRootSets;
+ MarkSet[] aProfileMarkSets;
public ParameterizedSafeRunnable(IConfigurationElement runtAttribute, Profile profile) {
cfg = runtAttribute;
@@ -135,46 +113,50 @@ public class GarbageCollector {
}
public void handleException(Throwable exception) {
- LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.GarbageCollector_3, exception));
+ LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.Error_in_extension, exception));
}
public void run() throws Exception {
- IMarkSetProvider aRootSetProvider = (IMarkSetProvider) cfg.createExecutableExtension(ATTRIBUTE_CLASS);
- if (aRootSetProvider == null) {
- aProfileRootSets = null;
+ IMarkSetProvider aMarkSetProvider = (IMarkSetProvider) cfg.createExecutableExtension(ATTRIBUTE_CLASS);
+ if (aMarkSetProvider == null) {
+ aProfileMarkSets = null;
return;
}
- aProfileRootSets = aRootSetProvider.getRootSets(aProfile);
+ aProfileMarkSets = aMarkSetProvider.getMarkSets(aProfile);
}
public MarkSet[] getResult() {
- return aProfileRootSets;
+ return aProfileMarkSets;
}
}
- private void contributeRootSets(IConfigurationElement runAttribute, Profile aProfile) {
- try {
- ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, aProfile);
- SafeRunner.run(providerExecutor);
- MarkSet[] aProfileRootSets = providerExecutor.getResult();
- if (aProfileRootSets[0] == null)
- return;
+ private void contributeMarkSets(IConfigurationElement runAttribute, Profile aProfile, boolean addRepositories) {
+ ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, aProfile);
+ SafeRunner.run(providerExecutor);
+ MarkSet[] aProfileMarkSets = providerExecutor.getResult();
+ if (aProfileMarkSets[0] == null)
+ return;
+
+ for (int i = 0; i < aProfileMarkSets.length; i++) {
+ if (aProfileMarkSets[i] == null) {
+ continue;
+ }
- for (int j = 0; j < aProfileRootSets.length; j++) {
- if (aProfileRootSets[j] == null) {
+ for (int j = 0; j < aProfileMarkSets.length; j++) {
+ if (aProfileMarkSets[j] == null) {
continue;
}
-
- //contribute any keys that are relevant to the Profile being GC'ed
- if (markSet.containsKey(aProfileRootSets[j].getRepo())) {
- Collection keys = (Collection) markSet.get(aProfileRootSets[j].getRepo());
- addKeys(keys, aProfileRootSets[j].getKeys());
- markSet.put(aProfileRootSets[j].getRepo(), keys);
+ Collection keys = (Collection) markSet.get(aProfileMarkSets[j].getRepo());
+ if (keys == null) {
+ if (addRepositories) {
+ keys = new HashSet();
+ markSet.put(aProfileMarkSets[j].getRepo(), keys);
+ addKeys(keys, aProfileMarkSets[j].getKeys());
+ }
+ } else {
+ addKeys(keys, aProfileMarkSets[j].getKeys());
}
}
-
- } catch (ClassCastException e) {
- LogHelper.log(new Status(IStatus.ERROR, GCActivator.ID, Messages.CoreGarbageCollector_0, e));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/IMarkSetProvider.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/IMarkSetProvider.java
index 387aabd24..c5becb94c 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/IMarkSetProvider.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/IMarkSetProvider.java
@@ -14,7 +14,7 @@ import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.engine.Profile;
/**
- * Any class which declares itself as an extension to the org.eclipse.equinox.p2.garbagecollector.rootsetproviders
+ * Any class which declares itself as an extension to the org.eclipse.equinox.p2.garbagecollector.marksetproviders
* extension point must implement this interface. Given a Profile, implementors will need to provide an array of
* MarkSet objects, each of which should contain an IArtifactRepository and the IArtifactKeys used by the given
* Profile.
@@ -28,7 +28,7 @@ public interface IMarkSetProvider {
* @param p A profile whose ArtifactRepositories require a garbage collection
* @return An array of MarkSet object(s) containing p's IArtifactRepository and its root set of IArtifactKeys
*/
- public MarkSet[] getRootSets(Profile p);
+ public MarkSet[] getMarkSets(Profile p);
/**
* Returns the IArtifactRepository for which this IMarkSetProvider provides a MarkSet.
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/Messages.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/Messages.java
index 9c5f8e867..f805b6e63 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/Messages.java
@@ -5,14 +5,8 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.equinox.p2.garbagecollector.messages"; //$NON-NLS-1$
- public static String CoreGarbageCollector_0;
- public static String CoreGarbageCollector_1;
- public static String GarbageCollector_0;
- public static String GarbageCollector_1;
- public static String GarbageCollector_2;
- public static String GarbageCollector_3;
- public static String GarbageCollector_4;
- public static String GCActivator_0;
+ public static String Error_in_extension;
+ public static String Missing_bus;
static {
// load message values from bundle file
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/RootSet.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/RootSet.java
deleted file mode 100644
index 43cb7ac67..000000000
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/RootSet.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.garbagecollector;
-
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-
-/**
- * Wrapper class used to store an IArtifactRepository and its root set of IArtifactKeys.
- */
-public class RootSet {
-
- /**
- * The root set for repo. This is the set of keys that currently map to an artifact in repo.
- */
- private IArtifactKey[] keys;
-
- /**
- * The ArtifactRepository for which a root set is being stored.
- */
- private IArtifactRepository repo;
-
- public RootSet(IArtifactKey[] inKeys, IArtifactRepository inRepo) {
- keys = inKeys;
- repo = inRepo;
- }
-
- public IArtifactKey[] getKeys() {
- return keys;
- }
-
- public IArtifactRepository getRepo() {
- return repo;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/messages.properties b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/messages.properties
index 2e985e3c9..bf2ab8a36 100644
--- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/p2/garbagecollector/messages.properties
@@ -1,8 +1,2 @@
-CoreGarbageCollector_0=Removing ArtifactKey: ${0}.
-CoreGarbageCollector_1=CoreGarbageCollector now running in debug mode.
-GarbageCollector_0=Extension does not implement IRootSetProvider interface.
-GarbageCollector_1=Could not instantiate an instance of the provided extension.
-GarbageCollector_2=A failure occurred while getting the root set.
-GarbageCollector_3=Error occurred during call to an IRootSetProvider.
-GarbageCollector_4=Number of RootSets has exceeded GarbageCollector.NUMBER_OF_ROOTSETS.
-GCActivator_0=ProvisioningEventBus service could not be obtained, CoreGarbageCollector will not function properly.
+Error_in_extension=An error occurred while calling to an IMarkSetProvider.
+Missing_bus=ProvisioningEventBus service could not be obtained, CoreGarbageCollector will not function properly.

Back to the top