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 Enes Altınok <en...@hotmail.com> on 2016/02/28 18:38:13 UTC

Repoistory connection

Hi,
I want to use oak in my project as embedded.For a start I wrote a test method. In my method I use the same code from this example here https://jackrabbit.apache.org/oak/docs/construct.htmlThe code runs just fine but it does not terminate unless I shutdown repository:((RepositoryImpl) repo).shutdown();So in my project, not for the first time but ever time when I want to connect to repository I call 
                        mongoClient = new MongoClient(host, port);			DB db = mongoClient.getDB(dbName);						Builder builder = new DocumentMK.Builder();			builder.setMongoDB(db);			ns = builder.getNodeStore();						Oak oak = new Oak(ns);			Jcr jcr = new Jcr(oak);						repo = jcr.createRepository();						try {								session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));			} 			catch (LoginException e) {								throw new EntityEngineException(ExceptionCode.OAK_LOGIN_ERROR, null, e, JackrabbitOakSession.class);			} 			catch (RepositoryException e) {								throw new EntityEngineException(ExceptionCode.OAK_REPOSITORY_ERROR, null, e, JackrabbitOakSession.class);			};
and in the end
              session.logout();              ((RepositoryImpl) repo).shutdown();              ns.dispose();              mongoClient.close();

So:1. Do I have to call createRepository() every time or just for the first time and then use another method to connect repository.2. Is shuting down the repository needed? 		 	   		  

RE: Repoistory connection

Posted by Enes Altınok <en...@hotmail.com>.
Hi,
So, I call createRepository only once to construct a repository but then in my application how can I get the repository instance without calling createRepository().


> From: mreutegg@adobe.com
> To: oak-dev@jackrabbit.apache.org
> Subject: Re: Repoistory connection
> Date: Tue, 1 Mar 2016 10:19:51 +0000
> 
> Hi,
> 
> On 01/03/16 10:36, "Enes Altžnok" wrote:
> >1.Is it possible to use SegmentNodeStore withoud osgi?
> 
> yes, see updated page on how to construct the repository:
> 
> http://jackrabbit.apache.org/oak/docs/construct.html
> 
> 
> >2.Is there a sample code or project for the SegmentNodeStore
> >implementation?
> 
> See above. There is also a standalone example you can
> find here:
> https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/standalone
> 
> 
> >3.If we are talking about using oak as embedded and store as
> >SegmentNodeStore, should I use jackrabbit but not oak.
> 
> The SegmentNodeStore is one of the backend options of Apache
> Jackrabbit Oak.
> 
> When you write 'jackrabbit', I assume you are referring to the
> old Jackrabbit 2.x version. This version is in maintenance mode
> and for new projects, I suggest you use the new Oak implementation.
> 
> Regards
>  Marcel
> 
 		 	   		  

Re: Repoistory connection

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi,

this sounds like you are constructing a repository for every
request. You should create the repository when your web application
starts and then create a session per request.

see also the webapp example:

https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/webapp


Regards
 Marcel

On 01/03/16 12:37, "Enes Altınok" wrote:

>Hi,
>1.Now I start using SegmentNodeStore but I constantly get these warning
>messages:
>WARN [TarReader.java:443] Invalid graph metadata in tar file
>2.I have this case both for MongoDocumentStore and SegmentNodeStore:In my
>application, I serve files over a rest api.And while downloading big
>sized files(size over 100MB), if user closes the browser middle of the
>download, then connection is lost and causing input stream not  to close
>proparly.Then If I want to create a session  I get these errors:
>If I am using MongoDocumentStore:
>OakMerge0001: OakMerge0001: Failed to merge changes to the underlying
>store
>or if I am using SegmentNodeStore:
>java.nio.channels.OverlappingFileLockException
>Then I restart tomcat and everyting starts to work again.
>
>> From: mreutegg@adobe.com
>> To: oak-dev@jackrabbit.apache.org
>> Subject: Re: Repoistory connection
>> Date: Tue, 1 Mar 2016 10:19:51 +0000
>> 
>> Hi,
>> 
>> On 01/03/16 10:36, "Enes Altžnok" wrote:
>> >1.Is it possible to use SegmentNodeStore withoud osgi?
>> 
>> yes, see updated page on how to construct the repository:
>> 
>> http://jackrabbit.apache.org/oak/docs/construct.html
>> 
>> 
>> >2.Is there a sample code or project for the SegmentNodeStore
>> >implementation?
>> 
>> See above. There is also a standalone example you can
>> find here:
>> 
>>https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/standalo
>>ne
>> 
>> 
>> >3.If we are talking about using oak as embedded and store as
>> >SegmentNodeStore, should I use jackrabbit but not oak.
>> 
>> The SegmentNodeStore is one of the backend options of Apache
>> Jackrabbit Oak.
>> 
>> When you write 'jackrabbit', I assume you are referring to the
>> old Jackrabbit 2.x version. This version is in maintenance mode
>> and for new projects, I suggest you use the new Oak implementation.
>> 
>> Regards
>>  Marcel
>> 
> 		 	   		  


RE: Repoistory connection

Posted by Enes Altınok <en...@hotmail.com>.
Hi,
1.Now I start using SegmentNodeStore but I constantly get these warning messages:
WARN [TarReader.java:443] Invalid graph metadata in tar file
2.I have this case both for MongoDocumentStore and SegmentNodeStore:In my application, I serve files over a rest api.And while downloading big sized files(size over 100MB), if user closes the browser middle of the download, then connection is lost and causing input stream not  to close proparly.Then If I want to create a session  I get these errors:
If I am using MongoDocumentStore: 
OakMerge0001: OakMerge0001: Failed to merge changes to the underlying store
or if I am using SegmentNodeStore:  
java.nio.channels.OverlappingFileLockException
Then I restart tomcat and everyting starts to work again.

> From: mreutegg@adobe.com
> To: oak-dev@jackrabbit.apache.org
> Subject: Re: Repoistory connection
> Date: Tue, 1 Mar 2016 10:19:51 +0000
> 
> Hi,
> 
> On 01/03/16 10:36, "Enes Altžnok" wrote:
> >1.Is it possible to use SegmentNodeStore withoud osgi?
> 
> yes, see updated page on how to construct the repository:
> 
> http://jackrabbit.apache.org/oak/docs/construct.html
> 
> 
> >2.Is there a sample code or project for the SegmentNodeStore
> >implementation?
> 
> See above. There is also a standalone example you can
> find here:
> https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/standalone
> 
> 
> >3.If we are talking about using oak as embedded and store as
> >SegmentNodeStore, should I use jackrabbit but not oak.
> 
> The SegmentNodeStore is one of the backend options of Apache
> Jackrabbit Oak.
> 
> When you write 'jackrabbit', I assume you are referring to the
> old Jackrabbit 2.x version. This version is in maintenance mode
> and for new projects, I suggest you use the new Oak implementation.
> 
> Regards
>  Marcel
> 
 		 	   		  

Re: Repoistory connection

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi,

On 01/03/16 10:36, "Enes Altžnok" wrote:
>1.Is it possible to use SegmentNodeStore withoud osgi?

yes, see updated page on how to construct the repository:

http://jackrabbit.apache.org/oak/docs/construct.html


>2.Is there a sample code or project for the SegmentNodeStore
>implementation?

See above. There is also a standalone example you can
find here:
https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/standalone


>3.If we are talking about using oak as embedded and store as
>SegmentNodeStore, should I use jackrabbit but not oak.

The SegmentNodeStore is one of the backend options of Apache
Jackrabbit Oak.

When you write 'jackrabbit', I assume you are referring to the
old Jackrabbit 2.x version. This version is in maintenance mode
and for new projects, I suggest you use the new Oak implementation.

Regards
 Marcel


RE: Repoistory connection

Posted by Enes Altınok <en...@hotmail.com>.
Hi,
1.Is it possible to use SegmentNodeStore withoud osgi?2.Is there a sample code or project for the SegmentNodeStore implementation?3.If we are talking about using oak as embedded and store as SegmentNodeStore, should I use jackrabbit but not oak.
> From: mreutegg@adobe.com
> To: oak-dev@jackrabbit.apache.org
> Subject: Re: Repoistory connection
> Date: Tue, 1 Mar 2016 08:26:30 +0000
> 
> Hi Enes,
> 
> On 28/02/16 18:38, "Enes Altžnok" wrote:
> >So:1. Do I have to call createRepository() every time or just for the
> >first time and then use another method to connect repository.
> 
> You have to call this once when your application starts.
> This will create the JCR Repository instance and initialize
> the repository when you start it the first time.
> 
> >2. Is shuting down the repository needed?
> 
> It is not strictly needed, but recommended. A clean shutdown
> ensures the next startup will be quick and no recovery is
> needed.
> 
> Furthermore, based on your description that you would like
> to embed Oak in your project, the SegmentNodeStore may be
> more suitable. It stores the data of the repository on
> your filesystem and does not require MongoDB.
> 
> Regards
>  Marcel
> 
 		 	   		  

Re: Repoistory connection

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi Enes,

On 28/02/16 18:38, "Enes Altžnok" wrote:
>So:1. Do I have to call createRepository() every time or just for the
>first time and then use another method to connect repository.

You have to call this once when your application starts.
This will create the JCR Repository instance and initialize
the repository when you start it the first time.

>2. Is shuting down the repository needed?

It is not strictly needed, but recommended. A clean shutdown
ensures the next startup will be quick and no recovery is
needed.

Furthermore, based on your description that you would like
to embed Oak in your project, the SegmentNodeStore may be
more suitable. It stores the data of the repository on
your filesystem and does not require MongoDB.

Regards
 Marcel