google-code-export / rcaller

Automatically exported from code.google.com/p/rcaller
Other
1 stars 0 forks source link

RCaller- with R on a server #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I am trying to implement a java program that uses the RCaller API to access R 
from within the java code. My java application will be deployed on a linux 
server and run as a Java WebStart app. I think it's better to have R installed 
on the server than having separate R installations on every machine that 
downloads and runs the WebStart. 

With that in mind, I wanted to know whether it's possible to use RCaller to 
interact with R installed on a server. I have used RCaller before with R 
installed on my machine itself and that works perfectly but I do not know how 
to use RCaller with R on a server (or even if it's possible or not). My 
questions are:

a) Is this possible ?

b) If yes, then can anyone please provide a simple, basic example of how to 
call R on server from java code using RCaller ?

c) Do R and RCaller have multithreading seeing as if there is one R 
installation on the server and multiple client machines use RCaller to access 
it, there might be major delays in processing their individual requests/ 
processes ?

Any suggestions or feedback on this would be great. Thanks.

Original issue reported on code.google.com by ajrulez....@gmail.com on 17 Mar 2014 at 10:19

GoogleCodeExporter commented 9 years ago
a) yes it is possible if you implement a jsp or servlet on the server which 
gets commands from webstart applications via sockets or http requests. Your jsp 
or servlet runs R codes and returns the result to webstart in same way.

b) each single Rcaller instance creates its own Rscript process indepently, so 
a multithreaded application can be created. Only the one R installation is 
required. Running multiple RCaller instances simultaneously would be slow 
depending on the number of cores and amount of memory. Note that the 'being 
slow' is a result of creating external processes and runtime lags are related 
to R itself.

Hope it helps.

Original comment by mhsatman on 25 Apr 2014 at 9:37

GoogleCodeExporter commented 9 years ago
Hi,
Instead of using jsp/ servlets to make a web application, I'm planning to 
deploy my application as a Java Web Start. 
For RCaller to work within it, do I need to have R installed on every client 
machine and use it's local path for RscriptExecutable or can I have R on a 
central server and have the RscriptExecutable path point to Rscript.exe on that 
server ?

Original comment by ajrulez....@gmail.com on 29 Jul 2014 at 2:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Note: I tried placing my R folder inside Tomcat's webapps/ROOT and using the 
remote server's url and port (80) in my code using:
caller.setRscriptExecutable(http://**.***.***.***:80/R/R-3.0.1/bin/x64/Rscript.e
xe);

However, this resulted in the following exception:
 rcaller.exception.RscriptExecutableNotFoundException: R executable
 http://**.***.***.***:80/R/R-3.0.1/bin/x64/Rscript.exe not found 

I then modified my code and tried to execute Rscript.exe using 
**Runtime.getRuntime().exec(http://**.***.***.***:80/R/R-3.0.1/bin/x64/Rscript.e
xe);** but that resulted in the following exception:
 java.io.IOException: Cannot run program
 "http://**.***.***.***:80/R/R-3.0.1/bin/Rscript.exe CreateProcess
 error=2, The system cannot find the file specified

If I use the above url in my browser, I can successfully access the Rscript.exe 
file. 

Could this error be occurring because of the Windows Firewall ? While setting 
up Tomcat, I had added a new inbound rule for port 80 (for Tomcat). Do I need 
to add a rule for outbound access on port 80 as well ? I do not understand why 
I can access Rscript.exe in my browser but cannot do the same from within my 
java application.

Any suggestions on how to fix this would be very helpful. Thanks.

Original comment by ajrulez....@gmail.com on 31 Jul 2014 at 12:03

GoogleCodeExporter commented 9 years ago
@mhsatman:
"a) yes it is possible if you implement a jsp or servlet on the server which 
gets commands from webstart applications via sockets or http requests. Your jsp 
or servlet runs R codes and returns the result to webstart in same way."

Regarding your suggestion above, do you have any examples on how to implement 
RCaller in a servlet and call it from a Java desktop or Web Start application 
instead of a jsp page ? I need to pass a 2d array (double[][]) from my Java 
code to the servlet, run RCaller in the servlet and return response in the form 
of a double[] array. Is this possible ? Kindly let me know soon. 
Thanks.

Original comment by ajrulez....@gmail.com on 1 Aug 2014 at 12:21