You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Matthew Dornquast <ma...@cata.com> on 2000/07/17 21:47:42 UTC

Unique identifier for a server process.

Java question:

How do I get a globally unique Identifier for an instance of a VM without relying on an external configuration?  Is there any way to do this without using JNI?

IP Address is a good start, as generally it's unique. (Yes, I know non-routable disqualify, but the scope is LAN related)  The challenge is what happens when two or more copies of a server are running on the same box.

This relates to something I'm doing with sessions for Tomcat.

Any help/suggestions appreciated.

-Matthew

Re: Unique identifier for a server process.

Posted by Nimret Sandhu <ni...@lightmail.com>.
On Mon, 17 Jul 2000, you wrote:
> 
> Java question:
> 
> How do I get a globally unique Identifier for an instance of a VM without relying on an external configuration?  Is there any way to do this without using JNI?
> 
> IP Address is a good start, as generally it's unique. (Yes, I know non-routable disqualify, but the scope is LAN related)  The challenge is what happens when two or more copies of a server are running on the same box.
> 
> This relates to something I'm doing with sessions for Tomcat.
> 
> Any help/suggestions appreciated.

1 possibility is http://java.sun.com/products/jdk/1.1/docs/api/java.rmi.server.UID.html#_top_

however, i am not sure how well this will work .. if u can get a hold of the
java process ( write it to a .pid file from your startup script, if u have
one), then you could use that along with the ip addr, and perhaps port #.

hth ~
-- 
Nimret Sandhu
http://nimret.penguinpowered.com || http://nimret.dhs.org
http://www.360.com

Re: Unique identifier for a server process.

Posted by Arion Yu <ar...@stt.com.hk>.
Hi!

I have an idea but don't know if it works.

for each VM,
while (true) {
try {
create a ServerSocket listening on a particular port;
log the current time (the identifier for the VM);
close the socket;
break;
}
catch (some exception) {
// try again after some time
}
}

Arion

Matthew Dornquast wrote:

> Java question: How do I get a globally unique Identifier for an
> instance of a VM without relying on an external configuration?  Is
> there any way to do this without using JNI? IP Address is a good
> start, as generally it's unique. (Yes, I know non-routable disqualify,
> but the scope is LAN related)  The challenge is what happens when two
> or more copies of a server are running on the same box. This relates
> to something I'm doing with sessions for Tomcat. Any help/suggestions
> appreciated. -Matthew

--
[This email and any files transmitted with it are confidential and may
contain information that is legally privileged. They are intended solely
for the addressee(s). Access to this email by anyone else is
unauthorized. If you are not the intended recipient, please delete it
and notify the sender by email immediately; you should not copy or use
it for any purpose, nor disclose its contents to any other person. Thank
you.]