You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@manifoldcf.apache.org by Alessandro Benedetti <ab...@apache.org> on 2015/05/01 16:09:09 UTC
[Repository Connector] Singleton APIConnection
Hi guys !
While developing a custom Repository connector I was using this approach
for a Singleton APIConnection :
public class CustomRepositoryConnector
extends BaseRepositoryConnector{
...
protected BoxSession session ;
...
protected void getSession()
throws ManifoldCFException {
if (session == null) {
session = new BoxSession(clientId, clientSecret, username,
password);
}
}
}
Debugging a little bit I noticed that actually the BoxSession is
instantiated a lot of times during the Job and not only one !
Analyzing the scenario it seems a Session is instantiated every time a
new Repository connection is pulled from a connection pool ( during
the job execution) .
Is it not possible to use only one session for the entire job ?
Is it necessary to get the session only the the "check" and "connect"
method, or inside each of the functional methods ? ( like
addSeedDocument, processSeedsDocuments ext ext )
Cheers
--
--------------------------
Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti
"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"
William Blake - Songs of Experience -1794 England
Re: [Repository Connector] Singleton APIConnection
Posted by Karl Wright <da...@gmail.com>.
Hi Alessandro,
The connection pooling model is very well defined and has been since Day
One. Each connection instance operates independently. There is a chapter
in the book about it in fact.
Karl
On Fri, May 1, 2015 at 10:09 AM, Alessandro Benedetti <abenedetti@apache.org
> wrote:
> Hi guys !
> While developing a custom Repository connector I was using this approach
> for a Singleton APIConnection :
>
> public class CustomRepositoryConnector
> extends BaseRepositoryConnector{
>
> ...
>
> protected BoxSession session ;
>
> ...
>
> protected void getSession()
> throws ManifoldCFException {
> if (session == null) {
> session = new BoxSession(clientId, clientSecret, username,
> password);
>
> }
> }
>
> }
>
>
> Debugging a little bit I noticed that actually the BoxSession is
> instantiated a lot of times during the Job and not only one !
>
> Analyzing the scenario it seems a Session is instantiated every time a
> new Repository connection is pulled from a connection pool ( during
> the job execution) .
>
> Is it not possible to use only one session for the entire job ?
>
> Is it necessary to get the session only the the "check" and "connect"
> method, or inside each of the functional methods ? ( like
> addSeedDocument, processSeedsDocuments ext ext )
>
>
> Cheers
>
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>