[Remoterengine-devel] callbacks on RemoteREngine and server side console

Romain Francois romain.francois at dbmail.com
Mon Aug 24 11:16:55 CEST 2009


Hello,

I've finally enabled main loop callbacks on the RemoteREngine so that R 
read eval print loop (REPL) callbacks are sent to interested parties.

== callbacks ==

Because of rmi, I could not have this as blocking calls, so it is done 
by wrapping the information in a RCallback object and sending this 
object to callback listeners, which are then supposed to handle it 
(asynchronously).

The RCallback has a needsResponse method that indicates if this callback 
needs a response (at the moment only the ChooseFileCallback callback 
needs a response). When the callback needs a response, the client is 
supposed to call the sendResponse method (responses are associated with 
the callback they originated from by a simple id mechanism).

The server will keep a reference to callbacks for which it waits for a 
response and act accordingly the first time it receives a response for a 
given callback. it will also send another callback to indicate that no 
further response is needed.

ReadConsoleCallbacks are handled separately at the moment, clients call 
the sendToConsole method, this adds a command to the queue of commands 
that feed the REPL. The REPL is sent a command as soon as the queue is 
not empty. Maybe later we can add the ability to remove queued commands, 
etc ...

== server side console ==

when you start the server, at the moment you get a fairly simple console 
that allows you to cleanly shut the server: it lets the clients know 
about it, it unbinds the server from the rmiregistry and finally shuts 
the jvm.

I'd like to turn this console into an actual R console so that we can 
type commands into the REPL from the server side. For that, the 
ConsoleThread implements CallbackListener (dummy implementation atm).

The problem I have is that the server side console is now implemented 
with a BufferedRead( InputStreamReader( System.in) ) and that the 
readLine method blocks which makes it difficult to implement the console.

Also there are more capable console readers available such as jline or 
the gnu readline bindings for java or we could make a simple swing 
widget on the server side.

What I probably need to do is write an interface for what the console is 
supposed to do, provide a default implementation that needs only java 
(no other libraries) and add the possibility to plug another 
implementation (jline,...) so to get more capable readline capabilities 
(such as completions, command history, ...)

Anyone willing to help on this ?

Romain

http://jline.sourceforge.net/
http://java-readline.sourceforge.net/

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/w33B : Completion for java objects
|- http://tr.im/vzip : Code Snippet : List of CRAN packages
`- http://tr.im/vsK1 : R parser package on CRAN



More information about the Remoterengine-devel mailing list