You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Marco Crivellaro <mc...@optasportsdata.com> on 2011/08/12 11:19:05 UTC

FTP component enhancement suggestion

Hi All,
when storing a file the ftp component checks if the file exists in the
endpoint, this is done by listing the content of the destination folder and
looping through all files listed.

the list operation takes a long time when the destination folder contains
hundreds of files.
instead of listing for all files the component can simply list for the file
it is interested on, this way the number of files contained in destination
folder won't affect the time it takes the producer to process the exchange.

I currently have a case where delivering to an endpoint is taking more than
a minute because of this issue.


Both ftp and sftp libraries used supports listing for a single file so the
changes would be the following:

*on  FtpOperations*
public boolean existsFile(String name) throws
GenericFileOperationFailedException {
  String[] names = client.listNames(name);
  if (names == null) {
    return false;
  }
  return (names.lenght >= 1);
}



*on SftpOperations*
public boolean existsFile(String name) throws
GenericFileOperationFailedException {
  Vector files = channel.ls(name);
  if (names == null) {
    return false;
  }
  return (names.size >= 1);
}

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4692606.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
Think we agreed my first proposal should be implemented.

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4712376.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
I've opened a ticket for it
https://issues.apache.org/jira/browse/CAMEL-4356

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4715564.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
Claus Ibsen-2 wrote:
> 
> Did you guys come to any conclusions?
> 

Please let me know if I should open a JIRA ticket for this, thank you


--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4714742.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Claus Ibsen <cl...@gmail.com>.
Did you guys come to any conclusions?


On Wed, Aug 17, 2011 at 1:17 PM, Marco Crivellaro
<mc...@optasportsdata.com> wrote:
> think I should open a ticket in JIRA?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4707747.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
think I should open a ticket in JIRA?

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4707747.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marek Niewiadomski <Ma...@medo.pl>.
Marco, you are right. Problems I've met was on client side not server. I've
based my experience on experiments with putty psftp client.

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4696330.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
Marek Niewiadomski wrote:
> 
> By the way, "ls" command is allowed only for directories or names with
> wildcards. For single filename it gives something like "no such file or
> directory" response even if the file exists. It looks that it is something
> to improve in SFTP server. Unfortunately we must work with servers as they
> are I think.
> 

I've tried listing filename for both FTP and SFTP servers (using libraries
used by Camel) and it works.


--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4693456.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by marekni <Ma...@medo.pl>.
Marco Crivellaro wrote:
> 
> ... in the end the list of files needs to be sent over  TCP the more files
> you have the longer it will take.
> 

Transferring big file list can be an issue for slow networks. In theory I
agree with you but just try. 5000 files in folder is enough to observe SFTP
server response latency. Maybe the reason is default file list sorting on
SFTP servers. Simple "ls filename*"  (single file to list) takes over 1s
(tested on linux). 
By the way, "ls" command is allowed only for directories or names with
wildcards. For single filename it gives something like "no such file or
directory" response even if the file exists. It looks that it is something
to improve in SFTP server. Unfortunately we must work with servers as they
are I think.

Regards

--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4693432.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by Marco Crivellaro <mc...@optasportsdata.com>.
marekni wrote:
> 
> In my test method channel.ls(name) for SFTP server takes more less the
> same time like channel.ls()
> 

I have few samples where it takes longer listing the directory, in the end
the list of files needs to be sent over  TCP the more files you have the
longer it will take.


marekni wrote:
> 
> The quickest way is to do this in less elegant i think. I f you want to
> know if file exist just try to make directory with the same name and look
> for results. It require to have write permission on destination folder but
> in most cases if we want to store messages such permission we already
> have.
> 

I think it is more expensive to raise and handle the exception than listing
for a single file.


--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4693129.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: FTP component enhancement suggestion

Posted by marekni <Ma...@medo.pl>.
Hi,

In my test method channel.ls(name) for SFTP server takes more less the same
time like channel.ls()
The quickest way is to do this in less elegant i think. I f you want to know
if file exist just try to make directory with the same name and look for
results. It require to have write permission on destination folder but in
most cases if we want to store messages such permission we already have.

    public boolean existsFile(String name) throws
GenericFileOperationFailedException {
        if (LOG.isTraceEnabled()) {
            LOG.trace("existsFile(" + name + ")");
        }

        try {
            channel.mkdir(name);
            channel.rmdir(name);
            return false;
        } catch (SftpException e) {
            if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) {
                return false;
            }
            return true;
        }
    }


--
View this message in context: http://camel.465427.n5.nabble.com/FTP-component-enhancement-suggestion-tp4692606p4693115.html
Sent from the Camel Development mailing list archive at Nabble.com.