[Remoterengine-commits] r188 - pkg/RemoteREngine/inst/java_src/src/server/org/rosuda/REngine/remote/server
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Sep 28 19:29:47 CEST 2009
Author: ian_long
Date: 2009-09-28 19:29:46 +0200 (Mon, 28 Sep 2009)
New Revision: 188
Modified:
pkg/RemoteREngine/inst/java_src/src/server/org/rosuda/REngine/remote/server/RemoteREngine_Server.java
Log:
Write out process Id when the server starts up
Modified: pkg/RemoteREngine/inst/java_src/src/server/org/rosuda/REngine/remote/server/RemoteREngine_Server.java
===================================================================
--- pkg/RemoteREngine/inst/java_src/src/server/org/rosuda/REngine/remote/server/RemoteREngine_Server.java 2009-09-26 04:11:08 UTC (rev 187)
+++ pkg/RemoteREngine/inst/java_src/src/server/org/rosuda/REngine/remote/server/RemoteREngine_Server.java 2009-09-28 17:29:46 UTC (rev 188)
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
+import java.lang.management.ManagementFactory;
import java.rmi.AccessException;
import java.rmi.AlreadyBoundException;
import java.rmi.NoSuchObjectException;
@@ -31,6 +32,7 @@
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.Calendar;
+import java.util.StringTokenizer;
import java.util.Vector;
import org.rosuda.JRI.Rengine;
@@ -223,7 +225,8 @@
throw e;
}
- System.out.println( "R Engine bound as `"+ name +"` as a service on port " + servicePort + " to local RMIRegistry running on port " + registryPort );
+ System.out.println( "R Engine bound as `"+ name +"` as a service on port " + servicePort +
+ " to local RMIRegistry running on port " + registryPort + ", running under Id: " + getPID());
running = true;
}
@@ -645,5 +648,24 @@
return callbackListeners ;
}
+ /**
+ * Method to return an estimate of the JVM's process Id. This implementation is not guaranteed to work
+ * on all OSs - no Java PID solution is, however it appears to work on most common ones.
+ * @return ProcessId of the JVM
+ */
+ public String getPID() {
+ try {
+ String name = ManagementFactory.getRuntimeMXBean().getName();
+ if (name.indexOf("@") > 0) {
+ StringTokenizer tok = new StringTokenizer(name,"@");
+ return tok.nextToken();
+ } else {
+ return name;
+ }
+ } catch (Exception e) {
+ if (DEBUG) System.out.println(e.getClass().getName() + " while trying to determine process Id; " + e.getMessage());
+ return "";
+ }
+ }
}
More information about the Remoterengine-commits
mailing list