You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Elijah Baley <e_...@outlook.com> on 2016/02/20 18:37:12 UTC

Re[2]: CloseFuture listener alternative to channel.waitFor()

See SSHD-652...

------ Original Message ------
From: XXX
To: dev@mina.apache.org
Sent: 20-Feb-16 12:19:17
Subject: Re: CloseFuture listener alternative to channel.waitFor()

>Please open a JIRA issue at https://issues.apache.org/jira/browse/SSHD 
>and specify the scenario that would require such an API. Please note 
>that when you call Channel#close, the return value is a CloseFuture to 
>which one can add listeners. Also, the ClientChannel has a waitFor 
>method that can be used to wait for the CHANNEL_CLOSED event. 
>Furthermore, you can register a ChannelListener whose #channelClosed 
>method will be called. Given so many ways to receive asynchronous 
>information about a channel being closed, why expose the internal 
>CloseFuture ?
>
>------ Original Message ------
>From: "Bean, Michael (Nokia - US)" <mi...@alcatel-lucent.com>
>To: dev@mina.apache.org
>Sent: 19-Feb-16 21:31:43
>Subject: CloseFuture listener alternative to channel.waitFor()
>
>>I need non-blocking means to wait for client request to complete.
>>
>>With sshd-core-1.1.0 and reflection I can get to gracefulFuture field 
>>of AbstractChannel and register a listener:
>>...
>>                     s_closeFutureField = 
>>AbstractChannel.class.getDeclaredField( "gracefulFuture" );
>>                     s_closeFutureField.setAccessible( true );
>>...
>>             timeout = commandEndTime - System.currentTimeMillis();
>>             DefaultCloseFuture closeFuture;
>>             try
>>             {
>>                 closeFuture = (DefaultCloseFuture) 
>>s_closeFutureField.get( channel );
>>             }
>>             catch ( IllegalAccessException e )
>>             {
>>                 throw new RuntimeException( e );
>>             }
>>             //CloseFuture closeFuture = channel.getCloseFuture();
>>             CloseListener closeListener = new CloseListener( workItem, 
>>sc, channel, out );
>>             AlarmHandler alarmHandler = new AlarmHandler( 
>>closeListener );
>>             Alarm alarm = getContext().getAlarmFactory().getAlarm( 
>>alarmHandler, timeout );
>>             closeListener.setAlarm( alarm );
>>             closeFuture.addListener( closeListener );
>>
>>             sc = null;
>>             return workItem.makeSuspend( "Waiting..." );
>>
>>Could getCloseFuture() method be added to AbstractChannel?
>>
>>Thanks,
>>
>>Mike
>>
>>-- Michael Bean (Mike)
>>Nokia - US
>>AAA Product Group
>>3461 Robin Ln, Ste 1
>>Cameron Park, CA 95682
>>Email: michael.bean@alcatel-lucent.com
>>Phone: 1 530 350 6564
>>Fax:   1 530 676 3442
>>