You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Frizz <fr...@googlemail.com> on 2014/06/17 12:14:20 UTC

Repository is started up and shut down in every call

I have a small WebService that's deployed in an OSGi container using
Jackrabbit 2.6.2

(1) Initialization for JCR (only done once):

RepositoryFactory repositoryFactory = new RepositoryFactoryImpl();
repository = repositoryFactory.getRepository(cfgMap);

(2) Because Jackrabbit is not thread safe I do the following for each
WebService request:

session = repository.login(new SimpleCredentials(USER_NAME, PASSWORD));
... do some query stuff ...
session.logout();
session = null;

But when I check my logfile it seems that in each WebService call
Jackrabbit is COMPLETELY started up and shut down -> slowing everything
down.

Is this really the way Jackrabbit is supposed to work? Am I doing something
wrong?

Especially those "Database XZY shutdown" don't look right to me, no?

Also: I see a "Repository started (xyz ms)" in every call.



-- First WebService Call: --

Starting repository...
LocalFileSystem initialized at path \user\temp\repository\repository
LocalFileSystem initialized at path \user\temp\repository\version
initializing workspace 'default'...
LocalFileSystem initialized at path \user\temp\repository\default
Index initialized: \user\temp\repository\index
workspace 'security' initialized
Repository started (915ms)
Transient repository initialized
Session opened

... do some query stuff ...

Session closed
Shutting down repository...
shutting down workspace 'default'...
Notification of EventListeners stopped.
workspace 'default' has been shutdown
shutting down workspace 'security'...
Notification of EventListeners stopped.
Index closed: \user\temp\repository\index
Database \user\temp\repository\workspaces\security\db' shutdown.
workspace 'security' has been shutdown
Database \user\temp\repository\version\db shutdown
Repository has been shutdown
Transient repository shut down


-- Second WebService Call: --

Starting repository...
LocalFileSystem initialized at path \user\temp\repository
LocalFileSystem initialized at path \user\temp\version
initializing workspace 'default'...
LocalFileSystem initialized at path \user\temp\default
Index initialized: \user\temp\index
workspace 'security' initialized
Transient repository initialized
Session opened

... do some query stuff ...

Session closed
Shutting down repository...
shutting down workspace 'default'...
Notification of EventListeners stopped.
workspace 'default' has been shutdown
shutting down workspace 'security'...
Notification of EventListeners stopped.
Index closed: \user\temp\index
Database repository\workspaces\security\db' shutdown.
workspace 'security' has been shutdown
Database \user\temp\version\db shutdown
Repository has been shutdown
Transient repository shut down


-- Third WebService Call: --
... and so one ...


cheers,
Frizz

AW: AW: Repository is started up and shut down in every call

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
Hi,

In a production environment i would always recommended a non transient repository.

greets
claus

Re: AW: Repository is started up and shut down in every call

Posted by Chris Poulsen <ch...@dezide.com>.
I did not know that, thank you.

Our JCA setup in production is configured properly with homedir/configfile  
(and we do not need any session trickery to keep things alive, so I guess  
our setup is working like expected),

Which kind of repository would you recommend the OP to use?

-- 
Chris

On Tue, 17 Jun 2014 13:42:24 +0200, KÖLL Claus <C....@tirol.gv.at> wrote:

> Hi Chris.
>
> In a JCA Environment a TransienRepository will be created if you a  
> repository uri.
> You should use the two params homedir and configfile ...
>
> Please see JCR-3129 for more information ..
>
> greets
> claus



AW: Repository is started up and shut down in every call

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
Hi,

The RepositoryFactoryImpl creates only a TransientRepository.
You can see it in the Javadoc ...

With ..
RepositoryConfig config = RepositoryConfig.create(xml, dir);
Repository repository = RepositoryImpl.create(config)

you will get a non transient repository.

In a JCA environment the repository creation mechanism is different.
If there are two params [homedir and configfile] it will create the repository with 

RepositoryConfig config = RepositoryConfig.create(xml, dir);
Repository repository = RepositoryImpl.create(config)

and if not it will use the RepositoryFactory.

hope now it's clear

greets
claus


-----Ursprüngliche Nachricht-----
Von: Frizz [mailto:frizzthecat@googlemail.com] 
Gesendet: Dienstag, 17. Juni 2014 16:07
An: users@jackrabbit.apache.org
Betreff: Re: Repository is started up and shut down in every call

Still I don't understand why (1) results in a TransientRepository whereas
(2) does not - since both get a config file and a repository directory
location.

(1)
cfgMap.put(RepositoryFactoryImpl.REPOSITORY_CONF, configLocation);
cfgMap.put(RepositoryFactoryImpl.REPOSITORY_HOME, repositoryLocation);

RepositoryFactory repositoryFactory = new RepositoryFactoryImpl();
repository = repositoryFactory.getRepository(cfgMap);

(2)
RepositoryConfig config = RepositoryConfig.create(xml, dir);
Repository repository = RepositoryImpl.create(config)

Re: Repository is started up and shut down in every call

Posted by Frizz <fr...@googlemail.com>.
Still I don't understand why (1) results in a TransientRepository whereas
(2) does not - since both get a config file and a repository directory
location.

(1)
cfgMap.put(RepositoryFactoryImpl.REPOSITORY_CONF, configLocation);
cfgMap.put(RepositoryFactoryImpl.REPOSITORY_HOME, repositoryLocation);

RepositoryFactory repositoryFactory = new RepositoryFactoryImpl();
repository = repositoryFactory.getRepository(cfgMap);

(2)
RepositoryConfig config = RepositoryConfig.create(xml, dir);
Repository repository = RepositoryImpl.create(config)

AW: Repository is started up and shut down in every call

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
Hi,

What i meant was in a jca environment.

Yes I would do it like this ..

>RepositoryConfig config = RepositoryConfig.create(xml, dir);
>Repository repository = RepositoryImpl.create(config)


greets
claus

Re: Repository is started up and shut down in every call

Posted by Frizz <fr...@googlemail.com>.
Confused ... now I have two more questions :-)

(1) When I look at RepositoryFactoryImpl.java I can seen that, in case
REPOSITORY_HOME is set in the Map passed to getRepository(cfgMap), it
ALWAYS results in a TransientRepository. What's the idea behind that?

(2) At the moment I do the following (which results in a
TransientRepository):

cfgMap.put(RepositoryFactoryImpl.REPOSITORY_CONF, configLocation);
cfgMap.put(RepositoryFactoryImpl.REPOSITORY_HOME, repositoryLocation);

RepositoryFactory repositoryFactory = new RepositoryFactoryImpl();
repository = repositoryFactory.getRepository(cfgMap);

I thought when I do this I set config file and repository directory
correctly, no?


So are you saying that I have to do the following instead to get a
non-TransientRepository?

RepositoryConfig config = RepositoryConfig.create(xml, dir);
Repository repository = RepositoryImpl.create(config)
(where "xml" (File) = configuration file and "dir" (File) = repository home
directory)






On Tue, Jun 17, 2014 at 1:42 PM, KÖLL Claus <C....@tirol.gv.at> wrote:

> Hi Chris.
>
> In a JCA Environment a TransienRepository will be created if you a
> repository uri.
> You should use the two params homedir and configfile ...
>
> Please see JCR-3129 for more information ..
>
> greets
> claus
>

AW: Repository is started up and shut down in every call

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
Hi Chris.

In a JCA Environment a TransienRepository will be created if you a repository uri.
You should use the two params homedir and configfile ...

Please see JCR-3129 for more information ..

greets
claus

Re: Repository is started up and shut down in every call

Posted by Chris Poulsen <ch...@dezide.com>.
I do not know. We use a JCA deployment model so we're just retrieving  
something implementing Repository from JNDI.

-- 
Chris

On Tue, 17 Jun 2014 12:56:40 +0200, Frizz <fr...@googlemail.com>  
wrote:

> Which one would you recommend? A  
> org.apache.jackrabbit.core.RepositoryImpl ?
>
>
>
> On Tue, Jun 17, 2014 at 12:42 PM, Chris Poulsen  
> <ch...@dezide.com>
> wrote:
>
>> Yes, you can keep a transient repository alive by holding a session for
>> the duration you need (we do this for testing) - Or you can use another
>> repository type (probably recommended for more serious use).
>>
>> --
>> Chris
>>
>>
>> On Tue, 17 Jun 2014 12:30:19 +0200, Frizz <fr...@googlemail.com>
>> wrote:
>>
>>  Thanks for your reply.
<snip>
>>
<snip>
>>
>>



Re: Repository is started up and shut down in every call

Posted by Frizz <fr...@googlemail.com>.
Which one would you recommend? A org.apache.jackrabbit.core.RepositoryImpl ?



On Tue, Jun 17, 2014 at 12:42 PM, Chris Poulsen <ch...@dezide.com>
wrote:

> Yes, you can keep a transient repository alive by holding a session for
> the duration you need (we do this for testing) - Or you can use another
> repository type (probably recommended for more serious use).
>
> --
> Chris
>
>
> On Tue, 17 Jun 2014 12:30:19 +0200, Frizz <fr...@googlemail.com>
> wrote:
>
>  Thanks for your reply.
>>
>> As you might have guessed I am really not a Jackrabbit expert (I started
>> working with it yesterday).
>>
>> Java Doc for TransientRepositry says: "...A repository proxy that
>> automatically initializes and shuts down the underlying repository
>> instance
>> when the first session is opened
>> or the last one closed.". So would it be an options to keep a dummy
>> session
>> open to avoid startup/shutdown? Or better not?
>>
>> What would be the correct way to avoid this permanent startup/shutdown?
>>
>> cheers,
>> Frizz
>>
>>
>> On Tue, Jun 17, 2014 at 12:19 PM, Chris Poulsen <chris.poulsen@dezide.com
>> >
>> wrote:
>>
>>  That is the way that a transient repository is supposed to work.
>>>
>>> --
>>> Chris
>>>
>>>
>>> On Tue, 17 Jun 2014 12:14:20 +0200, Frizz <fr...@googlemail.com>
>>> wrote:
>>>
>>>   WebService that's deployed in an OSGi container using
>>>
>> <snip>
>
>>
>>>
>>>
>>>
>
>

Re: Repository is started up and shut down in every call

Posted by Chris Poulsen <ch...@dezide.com>.
Yes, you can keep a transient repository alive by holding a session for  
the duration you need (we do this for testing) - Or you can use another  
repository type (probably recommended for more serious use).

-- 
Chris

On Tue, 17 Jun 2014 12:30:19 +0200, Frizz <fr...@googlemail.com>  
wrote:

> Thanks for your reply.
>
> As you might have guessed I am really not a Jackrabbit expert (I started
> working with it yesterday).
>
> Java Doc for TransientRepositry says: "...A repository proxy that
> automatically initializes and shuts down the underlying repository  
> instance
> when the first session is opened
> or the last one closed.". So would it be an options to keep a dummy  
> session
> open to avoid startup/shutdown? Or better not?
>
> What would be the correct way to avoid this permanent startup/shutdown?
>
> cheers,
> Frizz
>
>
> On Tue, Jun 17, 2014 at 12:19 PM, Chris Poulsen  
> <ch...@dezide.com>
> wrote:
>
>> That is the way that a transient repository is supposed to work.
>>
>> --
>> Chris
>>
>>
>> On Tue, 17 Jun 2014 12:14:20 +0200, Frizz <fr...@googlemail.com>
>> wrote:
>>
>>   WebService that's deployed in an OSGi container using
<snip>
>>
>>
>>



Re: Repository is started up and shut down in every call

Posted by Frizz <fr...@googlemail.com>.
Thanks for your reply.

As you might have guessed I am really not a Jackrabbit expert (I started
working with it yesterday).

Java Doc for TransientRepositry says: "...A repository proxy that
automatically initializes and shuts down the underlying repository instance
when the first session is opened
or the last one closed.". So would it be an options to keep a dummy session
open to avoid startup/shutdown? Or better not?

What would be the correct way to avoid this permanent startup/shutdown?

cheers,
Frizz


On Tue, Jun 17, 2014 at 12:19 PM, Chris Poulsen <ch...@dezide.com>
wrote:

> That is the way that a transient repository is supposed to work.
>
> --
> Chris
>
>
> On Tue, 17 Jun 2014 12:14:20 +0200, Frizz <fr...@googlemail.com>
> wrote:
>
>   WebService that's deployed in an OSGi container using
>> Jackrabbit 2.6.2
>> (1) Initialization for JCR
>>
>
>
>

Re: Repository is started up and shut down in every call

Posted by Chris Poulsen <ch...@dezide.com>.
That is the way that a transient repository is supposed to work.

-- 
Chris

On Tue, 17 Jun 2014 12:14:20 +0200, Frizz <fr...@googlemail.com>  
wrote:

>  WebService that's deployed in an OSGi container using
> Jackrabbit 2.6.2
> (1) Initialization for JCR