Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » P2: Headless update: Multiple P2 repos
P2: Headless update: Multiple P2 repos [message #642820] Thu, 02 December 2010 19:50 Go to next message
Dave Orme is currently offline Dave OrmeFriend
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
Re: P2: Headless update: Multiple P2 repos [message #642824 is a reply to message #642820] Thu, 02 December 2010 20:00 Go to previous messageGo to next message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Never mind, it was a (ok, my own) dumb mistake. Very Happy

For the curious, the code I posted actually works but was oversimplified for the purposes of illustration.

What was broken was my build, which was producing a non-P2updatable product. (I hadn't converted the Maven/Tycho build to use "eclipse-repository" from "eclipse-application" packaging type.)

Doh!


Thanks,

Dave Orme
Re: P2: Headless update: Multiple P2 repos [message #771837 is a reply to message #642824] Wed, 28 December 2011 09:52 Go to previous messageGo to next message
Ulyana Tsyukh is currently offline Ulyana TsyukhFriend
Messages: 6
Registered: December 2011
Junior Member
Hi Dave

I wanted to ask you how did you initialize the installable units Collection<IInstallableUnit>, can not find it anywhere. I would also like to update from multiple locations at the same time.

Kind Regards,

Ulyana
Re: P2: Headless update: Multiple P2 repos [message #771971 is a reply to message #771837] Wed, 28 December 2011 17:16 Go to previous messageGo to next message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Hi Ulyana,

Here's an example that works: https://github.com/pieceoftheloaf/SynchronizeOperation


Regards,

Dave
Re: P2: Headless update: Multiple P2 repos [message #772297 is a reply to message #771971] Thu, 29 December 2011 13:03 Go to previous message
Ulyana Tsyukh is currently offline Ulyana TsyukhFriend
Messages: 6
Registered: December 2011
Junior Member
Thank you Dave. Was very helpful !
Previous Topic:RCP/Equinox Console App Launcher on Linux
Next Topic:Is os.version>=10.7 legal in osgi platform filter? (repost)
Goto Forum:
  


Current Time: Wed Dec 17 23:24:57 GMT 2014

Powered by FUDForum. Page generated in 0.01793 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software