@Override public Object createService(IProvisioningAgent agent) { return new GarbageCollector(agent); }
public void runGC(IProfile profile) { markSet = new HashMap<IArtifactRepository, Collection<IArtifactKey>>(); if (!traverseMainProfile(profile)) return; //Complete each MarkSet with the MarkSets provided by all of the other registered Profiles traverseRegisteredProfiles(); //Run the GC on each MarkSet invokeCoreGC(); }
public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; if (event.isUninstall() && event.isPost()) { uninstallEventProfileId = event.getProfile().getProfileId(); } } else if (o instanceof CommitOperationEvent) { if (uninstallEventProfileId != null) { CommitOperationEvent event = (CommitOperationEvent) o; if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GCActivator.GC_ENABLED, true)) runGC(event.getProfile()); uninstallEventProfileId = null; } } else if (o instanceof RollbackOperationEvent) { if (uninstallEventProfileId != null && uninstallEventProfileId.equals(((RollbackOperationEvent) o).getProfile().getProfileId())) uninstallEventProfileId = null; } }
/** * Performs garbage collection based on remaining profiles. Should be called to avoid * having PDE's bundle pool area grow unbounded. */ public static void garbageCollect() { try { IProfile[] profiles = getProfileRegistry().getProfiles(); for (int i = 0; i < profiles.length; i++) { if (profiles[i].getProfileId().startsWith(PROFILE_ID_PREFIX)) { getGarbageCollector().runGC(profiles[i]); } } } catch (CoreException e) { // XXX likely should log something here. return; } }
private boolean traverseMainProfile(IProfile profile) { IExtensionRegistry registry = RegistryFactory.getRegistry(); IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); //First we collect all repos and keys for the profile being GC'ed for (int i = 0; i < configElts.length; i++) { if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ continue; } IConfigurationElement runAttribute = configElts[i]; if (runAttribute == null) { continue; } contributeMarkSets(runAttribute, profile, true); } return true; }
private void contributeMarkSets(IConfigurationElement runAttribute, IProfile profile, boolean addRepositories) { ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, profile); SafeRunner.run(providerExecutor); MarkSet[] aProfileMarkSets = providerExecutor.getResult(); if (aProfileMarkSets == null || aProfileMarkSets.length == 0 || aProfileMarkSets[0] == null) return; for (int i = 0; i < aProfileMarkSets.length; i++) { if (aProfileMarkSets[i] == null) { continue; } Collection<IArtifactKey> keys = markSet.get(aProfileMarkSets[i].getRepo()); if (keys == null) { if (addRepositories) { keys = new HashSet<IArtifactKey>(); markSet.put(aProfileMarkSets[i].getRepo(), keys); addKeys(keys, aProfileMarkSets[i].getKeys()); } } else { addKeys(keys, aProfileMarkSets[i].getKeys()); } } }
public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; if (event.isUninstall() && event.isPost()) { uninstallEventProfileId = event.getProfile().getProfileId(); } } else if (o instanceof CommitOperationEvent) { if (uninstallEventProfileId != null) { CommitOperationEvent event = (CommitOperationEvent) o; if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GCActivator.GC_ENABLED, true)) runGC(event.getProfile()); uninstallEventProfileId = null; } } else if (o instanceof RollbackOperationEvent) { if (uninstallEventProfileId != null && uninstallEventProfileId.equals(((RollbackOperationEvent) o).getProfile().getProfileId())) uninstallEventProfileId = null; } }
public Object start(IApplicationContext context) throws Exception { Map<?, ?> allArgs = context.getArguments(); String[] args = (String[]) allArgs.get(IApplicationContext.APPLICATION_ARGS); processArguments(args); // if the user didn't give us a profile id, then use the default SDK one if (profileId == null) profileId = IProfileRegistry.SELF; initializeServices(); IProfile profile = getProfile(profileId); if (profile == null) throw new IllegalArgumentException("\"" + profileId + "\" is not a valid profile identifier."); //$NON-NLS-1$//$NON-NLS-2$ GarbageCollector gc = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME); gc.runGC(profile); agent.stop(); return null; }
private boolean traverseMainProfile(IProfile profile) { IExtensionRegistry registry = RegistryFactory.getRegistry(); IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); //First we collect all repos and keys for the profile being GC'ed for (int i = 0; i < configElts.length; i++) { if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ continue; } IConfigurationElement runAttribute = configElts[i]; if (runAttribute == null) { continue; } contributeMarkSets(runAttribute, profile, true); } return true; }
private void contributeMarkSets(IConfigurationElement runAttribute, IProfile profile, boolean addRepositories) { ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, profile); SafeRunner.run(providerExecutor); MarkSet[] aProfileMarkSets = providerExecutor.getResult(); if (aProfileMarkSets == null || aProfileMarkSets.length == 0 || aProfileMarkSets[0] == null) return; for (int i = 0; i < aProfileMarkSets.length; i++) { if (aProfileMarkSets[i] == null) { continue; } Collection<IArtifactKey> keys = markSet.get(aProfileMarkSets[i].getRepo()); if (keys == null) { if (addRepositories) { keys = new HashSet<IArtifactKey>(); markSet.put(aProfileMarkSets[i].getRepo(), keys); addKeys(keys, aProfileMarkSets[i].getKeys()); } } else { addKeys(keys, aProfileMarkSets[i].getKeys()); } } }
public void runGC(IProfile profile) { markSet = new HashMap<>(); if (!traverseMainProfile(profile)) return; //Complete each MarkSet with the MarkSets provided by all of the other registered Profiles traverseRegisteredProfiles(); //Run the GC on each MarkSet invokeCoreGC(); }
@Override public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; if (event.isUninstall() && event.isPost()) { uninstallEventProfileId = event.getProfile().getProfileId(); } } else if (o instanceof CommitOperationEvent) { if (uninstallEventProfileId != null) { CommitOperationEvent event = (CommitOperationEvent) o; if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GCActivator.GC_ENABLED, true)) runGC(event.getProfile()); uninstallEventProfileId = null; } } else if (o instanceof RollbackOperationEvent) { if (uninstallEventProfileId != null && uninstallEventProfileId.equals(((RollbackOperationEvent) o).getProfile().getProfileId())) uninstallEventProfileId = null; } }
public Object start(IApplicationContext context) throws Exception { Map<?, ?> allArgs = context.getArguments(); String[] args = (String[]) allArgs.get(IApplicationContext.APPLICATION_ARGS); processArguments(args); // if the user didn't give us a profile id, then use the default SDK one if (profileId == null) profileId = IProfileRegistry.SELF; initializeServices(); IProfile profile = getProfile(profileId); if (profile == null) throw new IllegalArgumentException("\"" + profileId + "\" is not a valid profile identifier."); //$NON-NLS-1$//$NON-NLS-2$ GarbageCollector gc = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME); gc.runGC(profile); agent.stop(); return null; }
private boolean traverseMainProfile(IProfile profile) { IExtensionRegistry registry = RegistryFactory.getRegistry(); IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); //First we collect all repos and keys for the profile being GC'ed for (int i = 0; i < configElts.length; i++) { if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ continue; } IConfigurationElement runAttribute = configElts[i]; if (runAttribute == null) { continue; } contributeMarkSets(runAttribute, profile, true); } return true; }
public Object createService(IProvisioningAgent agent) { return new GarbageCollector(agent); }
private void contributeMarkSets(IConfigurationElement runAttribute, IProfile profile, boolean addRepositories) { ParameterizedSafeRunnable providerExecutor = new ParameterizedSafeRunnable(runAttribute, profile); SafeRunner.run(providerExecutor); MarkSet[] aProfileMarkSets = providerExecutor.getResult(); if (aProfileMarkSets == null || aProfileMarkSets.length == 0 || aProfileMarkSets[0] == null) return; for (int i = 0; i < aProfileMarkSets.length; i++) { if (aProfileMarkSets[i] == null) { continue; } Collection<IArtifactKey> keys = markSet.get(aProfileMarkSets[i].getRepo()); if (keys == null) { if (addRepositories) { keys = new HashSet<>(); markSet.put(aProfileMarkSets[i].getRepo(), keys); addKeys(keys, aProfileMarkSets[i].getKeys()); } } else { addKeys(keys, aProfileMarkSets[i].getKeys()); } } }
public void runGC(IProfile profile) { markSet = new HashMap<IArtifactRepository, Collection<IArtifactKey>>(); if (!traverseMainProfile(profile)) return; //Complete each MarkSet with the MarkSets provided by all of the other registered Profiles traverseRegisteredProfiles(); //Run the GC on each MarkSet invokeCoreGC(); }
public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; if (event.isUninstall() && event.isPost()) { uninstallEventProfileId = event.getProfile().getProfileId(); } } else if (o instanceof CommitOperationEvent) { if (uninstallEventProfileId != null) { CommitOperationEvent event = (CommitOperationEvent) o; if (uninstallEventProfileId.equals(event.getProfile().getProfileId()) && getBooleanPreference(GCActivator.GC_ENABLED, true)) runGC(event.getProfile()); uninstallEventProfileId = null; } } else if (o instanceof RollbackOperationEvent) { if (uninstallEventProfileId != null && uninstallEventProfileId.equals(((RollbackOperationEvent) o).getProfile().getProfileId())) uninstallEventProfileId = null; } }
public Object start(IApplicationContext context) throws Exception { Map<?, ?> allArgs = context.getArguments(); String[] args = (String[]) allArgs.get(IApplicationContext.APPLICATION_ARGS); processArguments(args); // if the user didn't give us a profile id, then use the default SDK one if (profileId == null) profileId = DEFAULT_PROFILE_ID; initializeServices(); IProfile profile = getProfile(profileId); if (profile == null) throw new IllegalArgumentException("\"" + profileId + "\" is not a valid profile identifier."); //$NON-NLS-1$//$NON-NLS-2$ GarbageCollector gc = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME); gc.runGC(profile); agent.stop(); return null; }
private boolean traverseMainProfile(IProfile profile) { IExtensionRegistry registry = RegistryFactory.getRegistry(); IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); //First we collect all repos and keys for the profile being GC'ed for (int i = 0; i < configElts.length; i++) { if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ continue; } IConfigurationElement runAttribute = configElts[i]; if (runAttribute == null) { continue; } contributeMarkSets(runAttribute, profile, true); } return true; }