P2: Headless update: Multiple P2 repos [message #642820] |
Thu, 02 December 2010 19:50 |
Dave Orme Messages: 424 Registered: July 2009 |
Senior Member |
|
|
P2 devs:
I'm trying to use the P2 API to update new bundles in an application where more than one P2 repo is used for splitting the application deployment along functional lines.
My approach has been to initialize and query both repositories, then to consolidate the various resulting Collection<IInstallableUnit> into a single Collection, which I then pass to "new UpdateOperation".
(It has to be a single UpdateOperation because there might be dependencies between Features in the various P2 repos. For example, the core platform might be updated using one P2 repo, but the real app--which obviously depends on the core platform--could use another P2 repo for its updates.)
The trouble is that when I run the resolve job, I get back an IStatus that says "Your original request has been modified." Then when I try to get the provisioning job from the updateOperation, I get back a null job with no indication of what went wrong or how to recover from this situation.
Here's my update method, with the exact failure line marked:
protected IStatus update(IProvisioningAgent agent, IProgressMonitor monitor) throws ProvisionException, OperationCanceledException, URISyntaxException {
ProvisioningSession session = new ProvisioningSession(agent);
//get the repo managers
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
// Update from two sites...
Collection<IInstallableUnit> iu1 = initializeMetadataAndArtifactSite(new URI(P2SITE), metadataManager, artifactManager, monitor);
Collection<IInstallableUnit> iu2 = initializeMetadataAndArtifactSite(new URI(SECOND_P2SITE), metadataManager, artifactManager, monitor);
// For now we'll assume no dupes between the sites. Ideally, we should filter out dupes.
ArrayList<IInstallableUnit> toInstallOrUpdate = new ArrayList<IInstallableUnit>(iu1.size() + iu2.size());
toInstallOrUpdate.addAll(iu1);
toInstallOrUpdate.addAll(iu2);
log(info("IUs to install/update:"));
StringBuffer ius = new StringBuffer("\n");
for (IInstallableUnit iu : toInstallOrUpdate) {
ius.append(iu.toString() + "\n");
}
log(info(ius.toString()));
// Perform the install
UpdateOperation updateOperation = new UpdateOperation(session, toInstallOrUpdate);
ProvisioningJob resolveJob = updateOperation.getResolveJob(monitor);
if (null == resolveJob) {
return log(error("Unexpected: updateOperation#getResolveJob returned null!", new NullPointerException()));
}
IStatus updateStatus = syncRunJob(monitor, resolveJob);
log(updateStatus);
if (updateStatus.isOK()) {
log(info("Updating..."));
/ /FAILURE vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
ProvisioningJob provisioningJob = updateOperation.getProvisioningJob(monitor);
// FAILURE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if (null == provisioningJob) {
return log(error("Unexpected: updateOperation#getProvisioningJob returned null!", new NullPointerException()));
}
updateStatus = syncRunJob(monitor, provisioningJob);
log(updateStatus);
} else {
log(info("Update status returned !ok: " + updateStatus.getMessage()));
}
return updateStatus;
}
Thanks in advance,
Dave Orme
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02770 seconds