A better way to create commonly used Resources at startup?
Hi, As SLING-3618 shows, there's some non-deterministic behavior in the Sling startup that potentially causes nodes such as /var to be created by different modules depending on startup timing. So potentially with different node types, as seen in that issue. Does someone have a better idea on how to manage the creation of those commonly used nodes? It's probably only about a handful of them such as /var /libs /apps. We might define a CommonResourcesCreator service on which components such as ClassLoaderWriterImpl depend. That service then makes sure the required node types are available, and provides them to its clients. -Bertrand
Re: A better way to create commonly used Resources at startup?
Not sure if we really need that. Agreed, we now have a case where this is a problem - but why not just fix this? In the past we didn't have that problem. Now, *if* we want to do something about it, why not have this as a configuration of the resource resolver factory? Before it registers itself it makes sure that the required resources are created/available. No need for additional services or dependencies. Carsten 2014-07-23 10:58 GMT+02:00 Bertrand Delacretaz bdelacre...@apache.org: Hi, As SLING-3618 shows, there's some non-deterministic behavior in the Sling startup that potentially causes nodes such as /var to be created by different modules depending on startup timing. So potentially with different node types, as seen in that issue. Does someone have a better idea on how to manage the creation of those commonly used nodes? It's probably only about a handful of them such as /var /libs /apps. We might define a CommonResourcesCreator service on which components such as ClassLoaderWriterImpl depend. That service then makes sure the required node types are available, and provides them to its clients. -Bertrand -- Carsten Ziegeler Adobe Research Switzerland cziege...@apache.org
Re: A better way to create commonly used Resources at startup?
It sounds like the core issue is that nodes are created before node types are known? Could we tackle that specifically too? (Maybe that resolves the situation) Cheers, Stefan On 7/23/14 10:58 AM, Bertrand Delacretaz bdelacre...@apache.org wrote: Hi, As SLING-3618 shows, there's some non-deterministic behavior in the Sling startup that potentially causes nodes such as /var to be created by different modules depending on startup timing. So potentially with different node types, as seen in that issue. Does someone have a better idea on how to manage the creation of those commonly used nodes? It's probably only about a handful of them such as /var /libs /apps. We might define a CommonResourcesCreator service on which components such as ClassLoaderWriterImpl depend. That service then makes sure the required node types are available, and provides them to its clients. -Bertrand
Re: A better way to create commonly used Resources at startup?
I guess one of the problem's here is that there are parts which are not using the resource resolver and therefore start doing stuff before the resource bundles are active - and in that case the node types have not been added. I guess another solution would be to use the require/provide capabilities in the manifest. Carsten 2014-07-23 11:04 GMT+02:00 Stefan Egli stefane...@apache.org: It sounds like the core issue is that nodes are created before node types are known? Could we tackle that specifically too? (Maybe that resolves the situation) Cheers, Stefan On 7/23/14 10:58 AM, Bertrand Delacretaz bdelacre...@apache.org wrote: Hi, As SLING-3618 shows, there's some non-deterministic behavior in the Sling startup that potentially causes nodes such as /var to be created by different modules depending on startup timing. So potentially with different node types, as seen in that issue. Does someone have a better idea on how to manage the creation of those commonly used nodes? It's probably only about a handful of them such as /var /libs /apps. We might define a CommonResourcesCreator service on which components such as ClassLoaderWriterImpl depend. That service then makes sure the required node types are available, and provides them to its clients. -Bertrand -- Carsten Ziegeler Adobe Research Switzerland cziege...@apache.org
Re: A better way to create commonly used Resources at startup?
Hi, On Wed, Jul 23, 2014 at 11:04 AM, Carsten Ziegeler cziege...@apache.org wrote: ...we now have a case where this is a problem - but why not just fix this?... We need to fix that case, sure, but the current behavior is not clean - we probably have several similar potential node creation race conditions at startup. ...*if* we want to do something about it, why not have this as a configuration of the resource resolver factory? Before it registers itself it makes sure that the required resources are created/available. No need for additional services or dependencies Good idea, but services which go directly to the repository do not currently have a dependency on that factory. We could add an unused dependency to that, but in the end that's not cleaner than a new service dedicated to the creation of initial resources. As Stefan says, the Sling node types need to be registered before those initial resources are created, so there's a bit more to it. -Bertrand
Re: A better way to create commonly used Resources at startup?
2014-07-23 11:42 GMT+02:00 Bertrand Delacretaz bdelacre...@apache.org: Hi, On Wed, Jul 23, 2014 at 11:04 AM, Carsten Ziegeler cziege...@apache.org wrote: ...we now have a case where this is a problem - but why not just fix this?... We need to fix that case, sure, but the current behavior is not clean - we probably have several similar potential node creation race conditions at startup. Probably, but maybe not :) Can we find this out? ...*if* we want to do something about it, why not have this as a configuration of the resource resolver factory? Before it registers itself it makes sure that the required resources are created/available. No need for additional services or dependencies Good idea, but services which go directly to the repository do not currently have a dependency on that factory. We could add an unused dependency to that, but in the end that's not cleaner than a new service dedicated to the creation of initial resources. Well, I would suggest to change the code to use the resource resolver - that's why we have the abstraction in the first place. As also pointed out, the correct solution is the resource capabilities model of OSGi - which is declarative by using manifest entries and does not require any artifical service. Carsten As Stefan says, the Sling node types need to be registered before those initial resources are created, so there's a bit more to it. -Bertrand -- Carsten Ziegeler Adobe Research Switzerland cziege...@apache.org
Re: A better way to create commonly used Resources at startup?
On Wed, Jul 23, 2014 at 11:49 AM, Carsten Ziegeler cziege...@apache.org wrote: ...As also pointed out, the correct solution is the resource capabilities model of OSGi - which is declarative by using manifest entries and does not require any artifical service Interesting, do you have pointers as to how this works? -Bertrand
Re: A better way to create commonly used Resources at startup?
On Wednesday 23 July 2014 14:49:57 Bertrand Delacretaz wrote: On Wed, Jul 23, 2014 at 11:49 AM, Carsten Ziegeler cziege...@apache.org wrote: ...As also pointed out, the correct solution is the resource capabilities model of OSGi - which is declarative by using manifest entries and does not require any artifical service Interesting, do you have pointers as to how this works? http://wiki.osgi.org/wiki/Require-Capability http://wiki.osgi.org/wiki/Provide-Capability http://blog.osgi.org/2012/03/requirements-and-capabilities.html O. -Bertrand
Re: A better way to create commonly used Resources at startup?
On Wed, Jul 23, 2014 at 2:59 PM, Oliver Lietz apa...@oliverlietz.de wrote: http://wiki.osgi.org/wiki/Require-Capability http://wiki.osgi.org/wiki/Provide-Capability Cool - is that implemented by the version of the Felix framework that we use? -Bertrand
Re: A better way to create commonly used Resources at startup?
Sure :) Apache Felix implements R5 Carsten 2014-07-23 15:05 GMT+02:00 Bertrand Delacretaz bdelacre...@apache.org: On Wed, Jul 23, 2014 at 2:59 PM, Oliver Lietz apa...@oliverlietz.de wrote: http://wiki.osgi.org/wiki/Require-Capability http://wiki.osgi.org/wiki/Provide-Capability Cool - is that implemented by the version of the Felix framework that we use? -Bertrand -- Carsten Ziegeler Adobe Research Switzerland cziege...@apache.org