Opened 10 years ago

Closed 10 years ago

#617 closed enhancement (fixed)

Re-use server connections within a transaction

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: External files support 1.1
Component: net.sf.basedb.xfiles Keywords:
Cc:

Description

The current implementation opens a new connection for each remote file that is accessed. If a single transaction is creating multiple files it would be nice to be able to re-use the same connection.

Change History (5)

comment:1 by Nicklas Nordborg, 10 years ago

This turned out to be a bit more complicated than expected. The idea was to create a cache linked to the current transaction (via a DbControl item). Then when the transaction is finished the cache is cleared and the connections closed. This turned out to work quite well, except that there are cases (for example, when downloading a file from the web client or from the ftp server) when the transaction is closed before the file download has been completed. This caused the server connection to be closed and file transfer to be aborted.

To solve this issue, a counter to keep track of the number of opened files is required so that the connection is not closed until the last file has been downloaded.

comment:2 by Nicklas Nordborg, 10 years ago

(In [2571]) References #617: Re-use server connections within a transaction

Implemented for the SFTP protocol. The action factory initializes the cache if a DbControl is provided and also register an action to clean up when the transaction is ended, Then, the connection manager saves connections in the cache which are re-used in subsequent requests to the same host.

comment:3 by Nicklas Nordborg, 10 years ago

(In [2572]) References #617: Re-use server connections within a transaction

Implemented for the FTP protocol. Since this supports anonymous ftp without a file server the connection parameters comparison needed to be changed so that it is based on both the URI and the connection parameters.

comment:4 by Nicklas Nordborg, 10 years ago

(In [2583]) References #617: Re-use server connections within a transaction

Fixes a NullPointerException when listing possible connection managers for a file server.

comment:5 by Nicklas Nordborg, 10 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.