You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Goldstein Lyor (JIRA)" <ji...@apache.org> on 2016/05/25 09:09:12 UTC

[jira] [Comment Edited] (SSHD-108) Add upload monitoring to sftp

    [ https://issues.apache.org/jira/browse/SSHD-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15299712#comment-15299712 ] 

Goldstein Lyor edited comment on SSHD-108 at 5/25/16 9:08 AM:
--------------------------------------------------------------

I am not sure I understand what you mean, but I think you can be informed of session issues by registering a _SessionListener_. The _onFailed_ method you mention eventually propagates to _sessionException_ callback so you can distinguish between sessions that closed normally or were aborted. Please note that _sessionClosed_ is *always* called - even for aborted sessions, so it is up to you to "mark" the session as aborted when _sessionException_ is called and then examine the mark in _sessionClosed_. You can easily do this by using the session's _get/setAttribute_ methods - define your own _AttributeKey_ and values and then use it. If you wish to monitor only SFTP sessions, then register an _SftpEventListener_ and add the monitoring session listener to the session argument provided when _initialized_ method is called to inform you of a new SFTP session (and if you really want to clean up after you, remove the session listener when _destroying_ is called).

I think this pretty much covers how I would approach the scenario you describe.


was (Author: lgoldstein):
I am not sure I understand what you mean, but I think you can be informed of session issues by registering a _SessionListener_. The _onFailed_ method you mention eventually propagates to _sessionException_ callback so you can distinguish between sessions that closed normally or were aborted. Please note that _sessionClosed_ is *always* called - even for aborted sessions, so it is up to you "mark" the session as aborted when _sessionException_ is called and then examine the mark in _sessionClosed_. You can easily do this by using the session's _get/setAttribute_ methods - define your own _AttributeKey_ and values and then use it. If you wish to monitor only SFTP sessions, then register an _SftpEventListener_ and add the monitoring session listener to the session argument provided when _initialized_ method is called to inform you of a new SFTP session (and if you really want to clean up after you, remove the session listener when _destroying_ is called).

I think this pretty much covers how I would approach the scenario you describe.

> Add upload monitoring to sftp
> -----------------------------
>
>                 Key: SSHD-108
>                 URL: https://issues.apache.org/jira/browse/SSHD-108
>             Project: MINA SSHD
>          Issue Type: Improvement
>    Affects Versions: 0.5.0
>            Reporter: Richard Evans
>            Assignee: Goldstein Lyor
>            Priority: Minor
>             Fix For: 1.1.0
>
>
> We have sshd integrated into our application and sftp is working fine.  One of the requirements is to initiate some action when a file upload it complete.  I have made this work by implementing handleClose in my SshFile implementation and performing the action if createOutputStream had been called previously.  This seems a bit ugly though; it might be nicer if there was some plug in mechanism to monitor file transfers.
> Ideally the monitor would be able to distinguish between a successful upload and a cancelled one (via ctrl-c at the client), but a quick perusal of the sftp stuff seems to inidicate that this is not possible. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)