[Remoterengine-commits] r163 - pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 21 05:37:04 CEST 2009


Author: ian_long
Date: 2009-09-21 05:37:04 +0200 (Mon, 21 Sep 2009)
New Revision: 163

Modified:
   pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java
Log:
Checks the status of the Engine before setting it to valid

Modified: pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java
===================================================================
--- pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java	2009-09-20 16:35:16 UTC (rev 162)
+++ pkg/RemoteREngine/inst/java_src/src/client/org/rosuda/REngine/remote/client/RemoteREngine.java	2009-09-21 03:37:04 UTC (rev 163)
@@ -140,7 +140,7 @@
 			REngineRegistry.add( this, engine_id ); 
 			callbackDispatcher.start();
 			
-			valid = true; 
+			valid = testConnection(); 
 		} catch ( NotBoundException nb) {
 			System.out.println("Unable to locate " + name + " within RMI Registry");
 		} catch( Exception e ){
@@ -533,5 +533,19 @@
 			/* what now */
 		} 
 	}
+	
+	/**
+	 * Check to see if we can run a command against the server
+	 * @return true if the command returns successfully
+	 */
+	private boolean testConnection() {
+		try {
+			REXP rexp = parseAndEval("R.version$version.string");
+			return rexp != null;
+		} catch (Throwable t) {
+			System.err.println(t.getClass().getName() + ": while testing connection to engine; " + t.getMessage());
+			return false;
+		}
+	}
 }
 



More information about the Remoterengine-commits mailing list