You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Paul Wilson <pa...@gmail.com> on 2019/10/29 13:08:23 UTC

Plugging an Observer with access to NodeStore

Hi,

I'm looking to implement something resembling a 'materialised view' over
content; essentially a special node which acquires or loses references to
checked in nodes depending upon whether they match a given query. Since I
need the query to run after property indexing takes place, I've been
looking to plug an Observer which also has access to the NodeStore for
writing the results (ala Lucene's async indexer).

I believe the best way to have my Observer access the NodeStore is
via @Reference injection from the OSGi container. I have no plans to use
OSGi however so I've been looking at using PojoSR taking inspiration from
the tests here:
https://github.com/apache/jackrabbit-oak/tree/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi
.

Unfortunately pursuing this line has been a massive time sink where all
roads lead to a timed out test due to an incorrectly configured container.
I could go into detail about this journey if it would help but given the
about of work I had to do just to get this far, I feel like my approach is
wrong. Also the whole PojoSr project feels unmaintained.

So -  how would you recommend I attack this problem? How do I spin up a
test that allows me to inject a NodeStore into my Observer and then perform
session operations?

Any help very appreciated!
Regards - Paul

Re: Plugging an Observer with access to NodeStore

Posted by Paul Wilson <pa...@gmail.com>.
Hi again,

What I'm struggling with is that there is no indication as to what
conditions need to be true in order for the repository to start. The
OakOSGiRepositoryFactory has a static class RepositoryTracker which is
waiting for the addingService method to be called before completing the
future but this is never called, I'm guessing before the preconditions for
the Repository are never satisfied. I can see that more than 70 services
are registered, but what is missing?

Thanks in advance,
Paul



On Thu, 31 Oct 2019 at 18:06, Paul Wilson <pa...@gmail.com> wrote:

> Hi,
>
> To follow on from this - I have created a repository that shows that
> adding `oak-pojosr` as a dependency and copy-pasting
> the OakOSGiRepositoryFactoryTest causes the repository to fail to start
> with the following error:
>
> INFO  SecurityProviderRegistration:478 - Aborting: preconditions are not
> satisfied: Preconditions(preconditions =
> [org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurat
> ionImpl,
> org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider,
> org.apache.jackrabbit.oak.security.user.UserAuthenticationFactoryImpl,
> org.apache.jackrabbit.oak.security.autho
> rization.AuthorizationConfigurationImpl,
> org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl,
> org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl],
> candi
> dates =
> [org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider,
> org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl,
> org.apache.jackrabbit.oak.secur
> ity.user.UserAuthenticationFactoryImpl,
> org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl,
> org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl])
>
> The test hangs and finally timesout. It seems
> that AuthorizationConfigurationImpl is never registered. Manually
> registering AuthorizationConfigurationImpl
> allows SecurityProviderRegistration to work however the repository still
> hangs during startup.
>
> Repository here - https://github.com/paulalexwilson/oak-pojosr-test
>
> Are there any examples anywhere of anyone using oak-pojosr that I could
> follow?
>
> Regards,
> Paul
>
>
> On Tue, 29 Oct 2019 at 14:08, Paul Wilson <pa...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I'm looking to implement something resembling a 'materialised view' over
>> content; essentially a special node which acquires or loses references to
>> checked in nodes depending upon whether they match a given query. Since I
>> need the query to run after property indexing takes place, I've been
>> looking to plug an Observer which also has access to the NodeStore for
>> writing the results (ala Lucene's async indexer).
>>
>> I believe the best way to have my Observer access the NodeStore is
>> via @Reference injection from the OSGi container. I have no plans to use
>> OSGi however so I've been looking at using PojoSR taking inspiration from
>> the tests here:
>> https://github.com/apache/jackrabbit-oak/tree/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi
>> .
>>
>> Unfortunately pursuing this line has been a massive time sink where all
>> roads lead to a timed out test due to an incorrectly configured container.
>> I could go into detail about this journey if it would help but given the
>> about of work I had to do just to get this far, I feel like my approach is
>> wrong. Also the whole PojoSr project feels unmaintained.
>>
>> So -  how would you recommend I attack this problem? How do I spin up a
>> test that allows me to inject a NodeStore into my Observer and then perform
>> session operations?
>>
>> Any help very appreciated!
>> Regards - Paul
>>
>>

Re: Plugging an Observer with access to NodeStore

Posted by Paul Wilson <pa...@gmail.com>.
Hi,

To follow on from this - I have created a repository that shows that adding
`oak-pojosr` as a dependency and copy-pasting
the OakOSGiRepositoryFactoryTest causes the repository to fail to start
with the following error:

INFO  SecurityProviderRegistration:478 - Aborting: preconditions are not
satisfied: Preconditions(preconditions =
[org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurat
ionImpl,
org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider,
org.apache.jackrabbit.oak.security.user.UserAuthenticationFactoryImpl,
org.apache.jackrabbit.oak.security.autho
rization.AuthorizationConfigurationImpl,
org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl,
org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl],
candi
dates =
[org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider,
org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl,
org.apache.jackrabbit.oak.secur
ity.user.UserAuthenticationFactoryImpl,
org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl,
org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl])

The test hangs and finally timesout. It seems
that AuthorizationConfigurationImpl is never registered. Manually
registering AuthorizationConfigurationImpl
allows SecurityProviderRegistration to work however the repository still
hangs during startup.

Repository here - https://github.com/paulalexwilson/oak-pojosr-test

Are there any examples anywhere of anyone using oak-pojosr that I could
follow?

Regards,
Paul


On Tue, 29 Oct 2019 at 14:08, Paul Wilson <pa...@gmail.com> wrote:

> Hi,
>
> I'm looking to implement something resembling a 'materialised view' over
> content; essentially a special node which acquires or loses references to
> checked in nodes depending upon whether they match a given query. Since I
> need the query to run after property indexing takes place, I've been
> looking to plug an Observer which also has access to the NodeStore for
> writing the results (ala Lucene's async indexer).
>
> I believe the best way to have my Observer access the NodeStore is
> via @Reference injection from the OSGi container. I have no plans to use
> OSGi however so I've been looking at using PojoSR taking inspiration from
> the tests here:
> https://github.com/apache/jackrabbit-oak/tree/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi
> .
>
> Unfortunately pursuing this line has been a massive time sink where all
> roads lead to a timed out test due to an incorrectly configured container.
> I could go into detail about this journey if it would help but given the
> about of work I had to do just to get this far, I feel like my approach is
> wrong. Also the whole PojoSr project feels unmaintained.
>
> So -  how would you recommend I attack this problem? How do I spin up a
> test that allows me to inject a NodeStore into my Observer and then perform
> session operations?
>
> Any help very appreciated!
> Regards - Paul
>
>

Re: Plugging an Observer with access to NodeStore

Posted by Paul Wilson <pa...@gmail.com>.
Hi Vikas,

Thanks for the reply. I eventually had more success by copying and
reworking the standalone example in 'oak-examples'. I'm still unsure where
my attempts failed when trying to emulate the pojosr tests.

Regards,
Paul

On Thu, 31 Oct 2019 at 19:06, Vikas Saurabh <vi...@gmail.com> wrote:

> Hi Paul,
>
> On Tue, 29 Oct, 2019, 18:38 Paul Wilson, <pa...@gmail.com> wrote:
>
> > ....
>
> I believe the best way to have my Observer access the NodeStore is
> > via @Reference injection from the OSGi container. I have no plans to use
> > OSGi however ....
>
>
> Admittedly, I'm not the best person to answer this... But I wonder if you
> can take cue from LucenePropertyIndexTest which sets up repository sans
> osgi. While creating Oak instance, you can do .with(Observer) to inject
> your own observer.
>
> --Vikas
> (sent from mobile)
>

Re: Plugging an Observer with access to NodeStore

Posted by Vikas Saurabh <vi...@gmail.com>.
Hi Paul,

On Tue, 29 Oct, 2019, 18:38 Paul Wilson, <pa...@gmail.com> wrote:

> ....

I believe the best way to have my Observer access the NodeStore is
> via @Reference injection from the OSGi container. I have no plans to use
> OSGi however ....


Admittedly, I'm not the best person to answer this... But I wonder if you
can take cue from LucenePropertyIndexTest which sets up repository sans
osgi. While creating Oak instance, you can do .with(Observer) to inject
your own observer.

--Vikas
(sent from mobile)