Community
Participate
Working Groups
In order to abstract away the implementation details of a particular repository, it would be good to make the metadata repository writtable.
a simple 'addInstallableUnit' method wont work in the situation when we read some stuff from the repository and * modify it * and then write it back. Here is why - Say we get the IU 'a' from the repository. Then we modify this IU. Lets call the modfied IU 'a1'. When we write 'a1' back to the repo, it will contain both 'a' and 'a1', which is not what we want. There needs to be some way to say we want to update an IU. So i propose 2 methods for the IWritableMetadataRepository interface - void addInstallableUnit(installableUnit); void updateInstallableUnit(oldUnit, newUnit); Note that this will require the classes to hold 2 copies of the IUs, the old one and the new one. Please give feedback on this.
IUs are not mutable. Therefore if you "modify" an existing IU you need to create a new version of it (there may be exception in dev scenarios). For example if you have IU A v1.0.0 and you want to change anything in it, you create a new version of the IU called IU A v1.0.1. Also as a consistency check, the "add" method of the repository should probably signal when an IU being added already exists. Another thing, we will need the ability to delete stuffs from the repository.
in the persistencemanager class constructor i am trying to get a reference to IMetadataRepositoriesManager using the following code - ServiceReference sr2 = Activator.context.getServiceReference(IMetadataRepositoriesManager.class.getName()); IMetadataRepositoriesManager mgr = (IMetadataRepositoriesManager) Activator.context.getService(sr2); but sr2 is always returned as 'null' when i try to run the metadata generator sdk. can someone tell me why this is so? i did add a dependency to org.eclipse.equinox.prov.metadata.repository in the plugin.xml.
Note that not all metadata repositories will be writeable. There should either be an isWritable method, or use the same pattern as artifact repository. IArtifactRepo has a method getRepoAsWritable() that returns a sub-interface (IWritableArtifactRepository), and the write methods are defined on this sub-interface.
Prashant, make sure that the org.eclipse.equinox.prov.core or the examplarysetup are started.
John, we were thinking of using the adaptor mechanism to allow for writing capability to be completely separated from the reading one.
Hi guys, I have written the IWritableMetadataRepository interface and made LocalMetadataRepository implement it. I am still in doubt whether to make URLMetadataRepository readable or not since it can be in a remote location where we do not have permission to write. I have successfully modified PersistenceMetadata to use the new writeable api and it passes all the tests. The amount of actual code written is pretty low but it took me a long time to figure out a lot of stuff and to make it actually pass all the tests. Please let me know where else in the code you want me to make changes to use the write api. It seems you are using the PersistenceMetadata class everywhere to write to the repository. Since I do not have write access to the CVS yet, I will just upload the modified code here on the 9th.
Created attachment 73364 [details] write api for metadata repository here is the code for the write api for metadata repository.
Created attachment 73366 [details] new project to initialize services properly this is a new project i created which just takes care of initializing all the services properly. without this you will get a lot of classnotfound exceptions while running the new code.
I will be looking at the patch shortly and keep you updated in this bug.
I was able to get the review earlier than expected, here are my remarks: IWrittableMetadataRepository: - it should not have a setWriteLocation(), since the location to write has been determined when the repository has been created - add and remove should probably return a boolean - I'm not sure about save(). On one end it seems to make sense, however then we have to make sure that the changes (removal or addition) are not done visible until save is invoked, which may make consistency across multiple users hard especially when add/remove give feedback. A proposal maybe to have add and remove do batching and block any other write the repo while these operations are performed. Also this problem has probably been addressed in the literature already and it could be good to see what others have done. To get an IWrittableRepository, the adaptor mechanism should be used rather than casting. This allows for decoupling of the reading and writing code thus allowing lighter weight repo implementation. Also this would give the opportunity to check whether or not a repo is writtable before trying to write in it and fail while saying like it is currently done in MetadataCache#save() XStreamMetadataManager writeMetadata is not consistent with readMetadata. It should take a stream.
Just to be more clear of what I meant by "to have add and remove do batching", I meant add(InstallableUnit[]) and remove(InstallableUnit[])
Created attachment 73607 [details] Made changes as requested I have made the changes to the writable repo api as requested in the review. MetadataCache class could not me made to implement the new interface since it requires saving explicitly at the time of a commitoperation event.
I'm a bit disappointed by this patch which did not compile and had not been run (the add method on LocalMetadataRepo was not properly implemented) in conjunction with the other tests. Moreover you have not addressed the issues around the return value of add and remove. That said I released a fixed and cleaned up version of the code so that you can more easily work from the repository.
That is weird, I did a full compile and run before I sent the patch. I am still not sure whether we should return a false on fail or just crash rightaway. However if you do want want to return a boolean I will implement that.
After some reflection, I think add and remove should return a boolean whose semantics should match Collection.addAll/removeAll. Also I just discovered that the implementation of LocalMetadataCache no longer discover all the files in the folder indicated as it is indicated in the java doc.
Could you please also add progress monitors to the add and remove methods.
Created attachment 73912 [details] Made changes to the writable repo api as requested I have made the changes as you requested. Please apply this patch over the current one.
Could you please create the patch against what's in HEAD. I had released the previous one in order for you to work more easily with the repo :) Thx
Created attachment 74453 [details] New patch with changes against the HEAD Made changes against the HEAD and tested it too.
Both artifact and metadata repos have been updated to allow for writable versions. Overall the approach has been to adapt a given repo to IWritable*Repository. This in turn allows or adding IUs, descriptors, .. as appropriate. There is more work to be done in the area of save lifecycle etc but that is for a separate bug. Closing.