diff options
author | Pascal Rapicault | 2010-04-10 01:45:01 +0000 |
---|---|---|
committer | Pascal Rapicault | 2010-04-10 01:45:01 +0000 |
commit | c500ee5d5c7c9347b3a16d1cbebd51ca42a2e563 (patch) | |
tree | b97d987acd4b98a138f638cb41bf92c429c80bbb | |
parent | a67c5884fe0b7ebf95589d44c8b6aa340a3bf6c9 (diff) | |
download | rt.equinox.p2-c500ee5d5c7c9347b3a16d1cbebd51ca42a2e563.tar.gz rt.equinox.p2-c500ee5d5c7c9347b3a16d1cbebd51ca42a2e563.tar.xz rt.equinox.p2-c500ee5d5c7c9347b3a16d1cbebd51ca42a2e563.zip |
Bug 305490 - [planner] Remove code related to absolute provisioning plan from ProfileChangeRequest
6 files changed, 73 insertions, 103 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java index a931c9d1f..192fdfe67 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java @@ -343,8 +343,6 @@ public class SimplePlanner implements IPlanner { public IProvisioningPlan getProvisioningPlan(IProfileChangeRequest request, ProvisioningContext context, IProgressMonitor monitor) { ProfileChangeRequest pcr = (ProfileChangeRequest) request; - if (pcr.getAbsolute()) - return generateAbsoluteProvisioningPlan(pcr, context, monitor); SubMonitor sub = SubMonitor.convert(monitor, ExpandWork); sub.setTaskName(Messages.Director_Task_Resolving_Dependencies); try { @@ -371,36 +369,36 @@ public class SimplePlanner implements IPlanner { } } - private IProvisioningPlan generateAbsoluteProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) { - Set<IInstallableUnit> toState = profileChangeRequest.getProfile().query(QueryUtil.createIUAnyQuery(), null).toSet(); - HashSet<IInstallableUnit> fromState = new HashSet<IInstallableUnit>(toState); - toState.removeAll(profileChangeRequest.getRemovals()); - toState.addAll(profileChangeRequest.getAdditions()); - - IProvisioningPlan plan = engine.createPlan(profileChangeRequest.getProfile(), context); - planIUOperations(plan, fromState, toState); - planPropertyOperations(plan, profileChangeRequest); - - if (DEBUG) { - Object[] operands = new Object[0]; - try { - Method getOperands = plan.getClass().getMethod("getOperands", new Class[0]); //$NON-NLS-1$ - operands = (Object[]) getOperands.invoke(plan, new Object[0]); - } catch (Throwable e) { - // ignore - } - for (int i = 0; i < operands.length; i++) { - Tracing.debug(operands[i].toString()); - } - } - Map<IInstallableUnit, RequestStatus>[] changes = computeActualChangeRequest(toState, profileChangeRequest); - Map<IInstallableUnit, RequestStatus> requestChanges = (changes == null) ? null : changes[0]; - Map<IInstallableUnit, RequestStatus> requestSideEffects = (changes == null) ? null : changes[1]; - QueryableArray plannedState = new QueryableArray(toState.toArray(new IInstallableUnit[toState.size()])); - PlannerStatus plannerStatus = new PlannerStatus(Status.OK_STATUS, null, requestChanges, requestSideEffects, plannedState); - plan.setStatus(plannerStatus); - return plan; - } + // private IProvisioningPlan generateAbsoluteProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) { + // Set<IInstallableUnit> toState = profileChangeRequest.getProfile().query(QueryUtil.createIUAnyQuery(), null).toSet(); + // HashSet<IInstallableUnit> fromState = new HashSet<IInstallableUnit>(toState); + // toState.removeAll(profileChangeRequest.getRemovals()); + // toState.addAll(profileChangeRequest.getAdditions()); + // + // IProvisioningPlan plan = engine.createPlan(profileChangeRequest.getProfile(), context); + // planIUOperations(plan, fromState, toState); + // planPropertyOperations(plan, profileChangeRequest); + // + // if (DEBUG) { + // Object[] operands = new Object[0]; + // try { + // Method getOperands = plan.getClass().getMethod("getOperands", new Class[0]); //$NON-NLS-1$ + // operands = (Object[]) getOperands.invoke(plan, new Object[0]); + // } catch (Throwable e) { + // // ignore + // } + // for (int i = 0; i < operands.length; i++) { + // Tracing.debug(operands[i].toString()); + // } + // } + // Map<IInstallableUnit, RequestStatus>[] changes = computeActualChangeRequest(toState, profileChangeRequest); + // Map<IInstallableUnit, RequestStatus> requestChanges = (changes == null) ? null : changes[0]; + // Map<IInstallableUnit, RequestStatus> requestSideEffects = (changes == null) ? null : changes[1]; + // QueryableArray plannedState = new QueryableArray(toState.toArray(new IInstallableUnit[toState.size()])); + // PlannerStatus plannerStatus = new PlannerStatus(Status.OK_STATUS, null, requestChanges, requestSideEffects, plannedState); + // plan.setStatus(plannerStatus); + // return plan; + // } //Verify that all the meta requirements necessary to perform the uninstallation (if necessary) and all t private Collection<IRequirement> areMetaRequirementsSatisfied(IProfile oldProfile, Collection<IInstallableUnit> newProfile, IProvisioningPlan initialPlan) { diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java index f01e4a509..b41e2fc7b 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java @@ -31,7 +31,6 @@ public class ProfileChangeRequest implements Cloneable, IProfileChangeRequest { private HashMap<String, String> propertiesToAdd = null; // map of key->value for properties to be added private HashMap<IInstallableUnit, Map<String, String>> iuPropertiesToAdd = null; // map iu->map of key->value pairs for properties to be added for an iu private HashMap<IInstallableUnit, List<String>> iuPropertiesToRemove = null; // map of iu->list of property keys to be removed for an iu - private boolean isAbsolute = false; //Indicate whether or not the request is an absolute one private ArrayList<IRequirement> additionalRequirements; public static ProfileChangeRequest createByProfileId(IProvisioningAgent agent, String profileId) { @@ -219,14 +218,6 @@ public class ProfileChangeRequest implements Cloneable, IProfileChangeRequest { removeInstallableUnitProfileProperty(iu, SimplePlanner.INCLUSION_RULES); } - public void setAbsoluteMode(boolean absolute) { - isAbsolute = absolute; - } - - public boolean getAbsolute() { - return isAbsolute; - } - @SuppressWarnings("unchecked") public Object clone() { ProfileChangeRequest result = new ProfileChangeRequest(profile); diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java index d711aa943..16280faf8 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java @@ -21,10 +21,10 @@ import org.eclipse.equinox.internal.p2.operations.Activator; import org.eclipse.equinox.internal.p2.operations.Messages; import org.eclipse.equinox.internal.provisional.configurator.Configurator; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.core.IAgentLocation; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; @@ -142,12 +142,12 @@ public class ProvisioningSession { // If the phase set calls for download, then we want to download the install plan artifacts // at the same time as the actual install artifacts. This way, we will only install the install handler // after already knowing we have successfully obtained the artifacts that will be installed afterward. - ProfileChangeRequest downloadRequest = new ProfileChangeRequest(profile); - downloadRequest.setAbsoluteMode(true); - downloadRequest.addAll(QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet()); - + IProvisioningPlan downloadPlan = getEngine().createPlan(profile, context); + Iterator<IInstallableUnit> it = QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null).iterator(); + while (it.hasNext()) { + downloadPlan.addInstallableUnit(it.next()); + } IPhaseSet download = PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_COLLECT}); - IProvisioningPlan downloadPlan = getPlanner().getProvisioningPlan(downloadRequest, context, mon.newChild(100)); IStatus downloadStatus = getEngine().perform(downloadPlan, download, mon.newChild(300)); if (!downloadStatus.isOK()) { mon.done(); 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 328d0a757..04f5e7fd3 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 @@ -18,14 +18,12 @@ import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.engine.*; import org.eclipse.equinox.internal.p2.engine.phases.Collect; -import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; import org.eclipse.equinox.p2.metadata.IArtifactKey; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; @@ -123,18 +121,14 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { // call the engine with only the "collect" phase so all we do is download IProfile profile = createProfile(); try { - ProfileChangeRequest request = new ProfileChangeRequest(profile); - request.setAbsoluteMode(true); - request.addAll(processedIUs); - ProvisioningContext context = new ProvisioningContext(agent); IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME); if (engine == null) throw new ProvisionException(Messages.exception_noEngineService); - IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME); - if (planner == null) - throw new ProvisionException(Messages.exception_noPlannerService); - - IProvisioningPlan plan = planner.getProvisioningPlan(request, context, monitor); + ProvisioningContext context = new ProvisioningContext(agent); + IProvisioningPlan plan = engine.createPlan(profile, context); + for (Iterator<IInstallableUnit> iterator = processedIUs.iterator(); iterator.hasNext();) { + plan.addInstallableUnit(iterator.next()); + } IStatus result = engine.perform(plan, getPhaseSet(), progress.newChild(1)); PhaseSet nativeSet = getNativePhase(); if (nativeSet != null) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java index 3cf915bdb..5abaa3601 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java @@ -1,10 +1,8 @@ package org.eclipse.equinox.p2.tests.planner; import org.eclipse.equinox.internal.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /******************************************************************************* @@ -20,36 +18,33 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class AbsolutePlanTest extends AbstractProvisioningTest { public void testAddAndRemoveIU() { IProfile profile = createProfile(getName()); - ProfileChangeRequest pcr = new ProfileChangeRequest(profile); - pcr.setAbsoluteMode(true); + IEngine engine = createEngine(); + IProvisioningPlan plan = engine.createPlan(profile, new ProvisioningContext(getAgent())); IInstallableUnit iuA = createEclipseIU("A"); - pcr.addInstallableUnits(new IInstallableUnit[] {iuA, createEclipseIU("B"), createEclipseIU("C")}); - IPlanner planner = createPlanner(); - IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null); + plan.addInstallableUnit(iuA); + plan.addInstallableUnit(createEclipseIU("B")); + plan.addInstallableUnit(createEclipseIU("C")); assertEquals(3, countPlanElements(plan)); - createEngine().perform(plan, null); + engine.perform(plan, null); - ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); - removeRequest.setAbsoluteMode(true); - removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); - assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(getAgent()), null))); + IProvisioningPlan plan2 = engine.createPlan(profile, new ProvisioningContext(getAgent())); + plan2.removeInstallableUnit(iuA); + assertEquals(1, countPlanElements(plan2)); } public void testAddAndRemoveProperty() { IInstallableUnit iuA = createEclipseIU("A"); IProfile profile = createProfile(getName()); - ProfileChangeRequest pcr = new ProfileChangeRequest(profile); - pcr.setAbsoluteMode(true); - pcr.addInstallableUnits(new IInstallableUnit[] {iuA}); - pcr.setInstallableUnitProfileProperty(iuA, "key", "value"); + IEngine engine = createEngine(); + IProvisioningPlan plan = engine.createPlan(profile, new ProvisioningContext(getAgent())); + plan.addInstallableUnit(iuA); + plan.setInstallableUnitProfileProperty(iuA, "key", "value"); - IPlanner planner = createPlanner(); - ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null); assertEquals(1, countPlanElements(plan)); - createEngine().perform(plan, null); + engine.perform(plan, null); - Operand[] ops = plan.getOperands(); + Operand[] ops = ((ProvisioningPlan) plan).getOperands(); boolean found = false; for (int i = 0; i < ops.length; i++) { if (ops[i] instanceof InstallableUnitPropertyOperand) @@ -57,24 +52,20 @@ public class AbsolutePlanTest extends AbstractProvisioningTest { } assertTrue(found); - ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); - removeRequest.setAbsoluteMode(true); - removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); - removeRequest.removeInstallableUnitProfileProperty(iuA, "key"); + IProvisioningPlan plan2 = engine.createPlan(profile, new ProvisioningContext(getAgent())); + plan2.removeInstallableUnit(iuA); + plan2.setInstallableUnitProfileProperty(iuA, "key", null); - assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(getAgent()), null))); + assertEquals(1, countPlanElements(plan2)); } public void testAddProperty() { IProfile profile = createProfile(getName()); + IEngine engine = createEngine(); - ProfileChangeRequest pcr = new ProfileChangeRequest(profile); - pcr.setAbsoluteMode(true); - pcr.setProfileProperty("foo", "bar"); - - IPlanner planner = createPlanner(); - IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null); - createEngine().perform(plan, null); + IProvisioningPlan plan = engine.createPlan(profile, new ProvisioningContext(getAgent())); + plan.setProfileProperty("foo", "bar"); + engine.perform(plan, null); assertEquals("bar", getProfileRegistry().getProfile(getName()).getProperty("foo")); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java index 0a45c9154..1051dbba0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java @@ -13,6 +13,7 @@ package org.eclipse.equinox.p2.tests.planner; import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.director.SimplePlanner; import org.eclipse.equinox.internal.provisional.p2.director.PlanExecutionHelper; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.core.IProvisioningAgent; @@ -45,33 +46,28 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { } public void testRemoveUnresolvedIU() { - ProfileChangeRequest request = new ProfileChangeRequest(profile); - request.setAbsoluteMode(true); - request.addInstallableUnits(new IInstallableUnit[] {a1}); - request.setInstallableUnitInclusionRules(a1, ProfileInclusionRules.createStrictInclusionRule(a1)); final ProvisioningContext context = new ProvisioningContext(getAgent()); + IProvisioningPlan plan = engine.createPlan(profile, context); + plan.addInstallableUnit(a1); + plan.setInstallableUnitProfileProperty(a1, SimplePlanner.INCLUSION_RULES, ProfileInclusionRules.createStrictInclusionRule(a1)); context.setMetadataRepositories(new URI[0]); - IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); assertContains(profile.query(QueryUtil.createIUAnyQuery(), null), a1); - ProfileChangeRequest req = new ProfileChangeRequest(profile); - req.removeInstallableUnits(new IInstallableUnit[] {a1}); + IProvisioningPlan plan2 = engine.createPlan(profile, context); + plan2.removeInstallableUnit(a1); - IProvisioningPlan plan2 = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertEquals(IStatus.OK, PlanExecutionHelper.executePlan(plan2, engine, context, new NullProgressMonitor()).getSeverity()); assertNotContains(profile.query(QueryUtil.createIUAnyQuery(), null), a1); } public void testAvailableVsQueryInProfile() { - ProfileChangeRequest request = new ProfileChangeRequest(profile); - request.setAbsoluteMode(true); - request.addInstallableUnits(new IInstallableUnit[] {c1}); - request.setInstallableUnitInclusionRules(c1, ProfileInclusionRules.createStrictInclusionRule(c1)); final ProvisioningContext context = new ProvisioningContext(getAgent()); + IProvisioningPlan plan = engine.createPlan(profile, context); + plan.addInstallableUnit(c1); + plan.setInstallableUnitProfileProperty(c1, SimplePlanner.INCLUSION_RULES, ProfileInclusionRules.createStrictInclusionRule(c1)); context.setMetadataRepositories(new URI[0]); - IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); assertContains(profile.query(QueryUtil.createIUAnyQuery(), null), c1); |