SM>  Can this session be shared among multiple threads at the same time?

The GenericKeyedObjectPool API supports the behavior of borrowing and
returning objects:

borrowObject(Object key)
returnObject(Object key, Object obj)

This means that one thread would borrow the SFTP session/client object,
perform it's work, and then return it to the pool.
The 'borrow' would indicate that the object usage would be exclusive to the
borrower-thread until it is returned.

JC> Perhaps you'd be more interested in a "cache" rather than a "pool"?

If the intention is to share an SFTP session/client reference between
threads, check-in and check-out could be important.

Although I do not know the use-case, I would imagine that each SFTP session
would likely need to be borrowed from the pool exclusively for some set of
FTP-commands and then returned once the intended set of steps had been
completed. Otherwise, the various threads might issue commands to the
session/client that would interrupt each other.

Because GenericKeyedObjectPool supports exclusivity, testing idle, idle
object evictor, and ensuring a minimum number of idle objects, it would be
ideal for maintaining a connection to an SFTP server, where a simple cache
could eventually be holding onto stale objects or clients having closed
connections.

- MDH



On Tue, Feb 3, 2015 at 3:21 PM, James Carman <ja...@carmanconsulting.com>
wrote:

> Perhaps you'd be more interested in a "cache" rather than a "pool"?
>
> On Tue, Feb 3, 2015 at 3:20 PM, Syed Mudassir <syed.mudas...@gaiatv.in>
> wrote:
>
>>  Guys,
>>   I have a question.
>>   I am using GenericKeyedObjectPool for pooling SFTP sessions.  Suppose I
>> have one session in the pool.
>>   Can this session be shared among multiple threads at the same time?
>>   I mean suppose if there are four threads running parallely, can this
>> session be used at the same time by all the four threads simultaneously?
>>   If it is possible, any sample code to get it done?
>> --
>>
>
>


-- 
(847) 494-2866

Reply via email to