Question

I am working on a tool to perform a p2 installation similar to the p2 DirectorApplication. I am having problems, when the URI of the artifact repository points to a site location using the http protocol. The download of the artifacts stops running at some point and the operation status is set to the severity IStatus.CANCEL. (Using the file protocol this error does not occur.)

I can not verify this with debugging because the "abort" does not happen in this mode. I found a piece of code in the SimpleArtifactRepository.getArtifacts where multiple Jobs are started to download the requested artifacts. If I manualy set the numberOfJobs to 1 the "abort" also doesn't happen.

I am not sure what the reason for this could be. I would be satisfied with a possibility to set the maximum number of threads to 1. There is a property, that is evaluated by SimpleArtifactRepository.getMaximumThreads for this use cased: PROP_MAX_THREADS (eclipse.p2.max.threads).

I can't locate the correct place to set this property though. Any hints are very welcome!

Was it helpful?

Solution

The only official way to set this property is to store it in the repository. So if you own all of the artifact repositories you are using, you could change it there.

Otherwise (and the more likely case), there are only hacks to set it. There is an API for setting properties on an artifact repository, but that API cannot be used on repositories accessed via HTTP. Changes via the API not only affect the in-memory representation, but p2 insists on also changing the persisted repository. This can't be done on a remote repository, so all property changes via the API are prevented.

So to only change the properties in memory, you need to hack the object using reflection. You can see an example here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top