Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: How do you generate a unique number for each request across muliple
tomcat instances?

Tim Funk

2003-12-16

Replies:

One way to get around that:
http://java.sun.com/j2se/1.4.2/docs/guide/idl/jidlFAQ.html#linuxior
http://dast.nlanr.net/Projects/Beacon/guide_faq.html

-Tim

Tom Ly wrote:

> That works great in a windows environment. But on Linux machines,the line <InetAddress.getLocalHost().getHostAddress() > will always return 127.0.0.1
>
> Tim Funk <funkman@(protected)
> across a cluster.
>
> To get a unique string, concatenate your IP address with
> java.rmi.server.UID(), for example:
> String guid = InetAddress.getLocalHost().getHostAddress() +
> (new java.rmi.server.UID()).toString());
>
> See the javadocs on UID for more info.
>
> -Tim
>
> Tom Ly wrote:
>
>
>>I have an application where I need to generate a unique int for each request that comes in. I've got about 8 Tomcat instances running spread across four machines(two tomcat's each machine). It's pretty simple with one Tomcat, but with mulitple Tomcats it gets tricky. I tried using InetAddress to get the ip address of the current machine and use that to set the range for each tomcat(since the ip address will always be unique), but since I'm using Linux, it'll always return 127.0.0.1 as the ip address, so I can use class InetAddress. Any advice on what to do?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
> For additional commands, e-mail: tomcat-user-help@(protected)
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.