You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jan Winter <ja...@gmail.com> on 2014/11/03 14:31:28 UTC

[gogo runtime-0.10] Closure.executeStatement(...) methode should be syncronized

Hello gogo.runtime experts,

I have a syncronisation problem in gogo-runtime(0.10.0).

I have 2 gogo commands 'producer' and 'consumer' (@see attached 
Gogo_syncProblem.java
<http://apache-felix.18485.x6.nabble.com/file/n5010375/Gogo_syncProblem.java>  
).

1) 'producer( optionalSecToWait )' produce 3 lines (line 1, line 2, line 3)
2) 'consumer()' consume any line from System.in and print this out to
System.out

Random observation by 'producer | consumer'
- sometimes 3 lines are printed
- sometimes NOT

*FIX:* Closure.public synchronized Object executeStatement(...)
- Than 3 lines printed always.




--
View this message in context: http://apache-felix.18485.x6.nabble.com/gogo-runtime-0-10-Closure-executeStatement-methode-should-be-syncronized-tp5010375.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: [gogo runtime-0.10] Closure.executeStatement(...) methode should be syncronized

Posted by Jan Winter <ja...@gmail.com>.
Great post:)

Thanks again to Derek



--
View this message in context: http://apache-felix.18485.x6.nabble.com/gogo-runtime-0-10-Closure-executeStatement-methode-should-be-syncronized-tp5010375p5010399.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: [gogo runtime-0.10] Closure.executeStatement(...) methode should be syncronized

Posted by Derek Baum <de...@baums.org.uk>.
I am not aware of any docs about stream handling in gogo.

Gogo is based on the OSGi RFC-147, which I believe has now been withdrawn, as it was not considered important to have multiple OSGi shell implementations conforming to a common interface.

The intent of RFC-147 was that a command could be written as a POJO, without any references to OSGi:
- Gogo commands don’t have to to implement any interface
- they can simply read and write System.in and System.out - which works as expected when connected to gogo via telnet or ssh

Session.getKeyboard() should NOT generally be used:
- it makes the code gogo-specific
- it stops the code working in a pipeline

The main use-case for Session.getKeyboard() to to allow the implementation of a gogo paging filter command, like less(1).

In this case, the command needs to read its control keys (e.g. enter for next page etc) from Session.getKeyboard() and NOT from System.in which contains the input being pages.

RFC-147 also defined a rich terminal interface that allowed full control of the terminal e.g. to implement command-line editing or curses-like terminal utilities, but it was not implemented.

—
Derek



On 5 Nov 2014, at 12:09, Jan Winter <ja...@gmail.com> wrote:

> Thanks Derek (again :) )
> 
> I added this check in the past as I used the 'session.getKeyboard()' stream.
> - because of a endless-loop on readLine() (sometimes)
> 
> Exist anywhere a documentation about stream handling in pipe-mode (etc..)?
> 
> Regards Jan.
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/gogo-runtime-0-10-Closure-executeStatement-methode-should-be-syncronized-tp5010375p5010378.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: [gogo runtime-0.10] Closure.executeStatement(...) methode should be syncronized

Posted by Jan Winter <ja...@gmail.com>.
Thanks Derek (again :) )

I added this check in the past as I used the 'session.getKeyboard()' stream.
- because of a endless-loop on readLine() (sometimes)

Exist anywhere a documentation about stream handling in pipe-mode (etc..)?

Regards Jan.


 



--
View this message in context: http://apache-felix.18485.x6.nabble.com/gogo-runtime-0-10-Closure-executeStatement-methode-should-be-syncronized-tp5010375p5010378.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: [gogo runtime-0.10] Closure.executeStatement(...) methode should be syncronized

Posted by Derek Baum <de...@baums.org.uk>.
There is a problem in your consumer readLines() method.

It returns immediately  if input is not ready:

        if (!rdr.ready()) {
            return Collections.emptyList();
        }

The producer and consumer run concurrently, and thus the consumer will start before the producer has generated any output.

If you comment out the above lines, then your readLines() method will block in the read loop until input is available:

        while (true) {
            String line = rdr.readLine();

—
Derek

On 3 Nov 2014, at 13:31, Jan Winter <ja...@gmail.com> wrote:

> Hello gogo.runtime experts,
> 
> I have a syncronisation problem in gogo-runtime(0.10.0).
> 
> I have 2 gogo commands 'producer' and 'consumer' (@see attached 
> Gogo_syncProblem.java
> <http://apache-felix.18485.x6.nabble.com/file/n5010375/Gogo_syncProblem.java>  
> ).
> 
> 1) 'producer( optionalSecToWait )' produce 3 lines (line 1, line 2, line 3)
> 2) 'consumer()' consume any line from System.in and print this out to
> System.out
> 
> Random observation by 'producer | consumer'
> - sometimes 3 lines are printed
> - sometimes NOT
> 
> *FIX:* Closure.public synchronized Object executeStatement(...)
> - Than 3 lines printed always.
> 
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/gogo-runtime-0-10-Closure-executeStatement-methode-should-be-syncronized-tp5010375.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>