Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Compare java instances

Reply
Thread Tools

Compare java instances

 
 
Robina Brintha
Guest
Posts: n/a
 
      04-10-2007
Hi all,

I am quite new to Java.

I have an issue to be solved. I want to compare two JVM instances. Let
me go in detail I am instantiating two or more java instances of
particular application and I wanted to know which java instance
started first. For that I am generating random numbers in the
constructor of the class and trying to store it in a static variable
and comparing this with newly generated randon number. But then it
didnt work.

Is there any other easy solution to do that?

Can anyone give some hint?

Thanks in advance

regards,
robina

 
Reply With Quote
 
 
 
 
Rogan Dawes
Guest
Posts: n/a
 
      04-10-2007
Robina Brintha wrote:
> Hi all,
>
> I am quite new to Java.
>
> I have an issue to be solved. I want to compare two JVM instances. Let
> me go in detail I am instantiating two or more java instances of
> particular application and I wanted to know which java instance
> started first. For that I am generating random numbers in the
> constructor of the class and trying to store it in a static variable
> and comparing this with newly generated randon number. But then it
> didnt work.
>
> Is there any other easy solution to do that?
>
> Can anyone give some hint?
>
> Thanks in advance
>
> regards,
> robina
>


How about storing System.currentTimeMillis()?

http://java.sun.com/j2se/1.5.0/docs/...entTimeMillis()

I have no idea how you are comparing these numbers, though. Over the
network? Also keep in mind that if you are in different time zones, you
need to account for that.

Rogan
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      04-10-2007
Robina Brintha wrote:
..
>I have an issue to be solved.


What is the issue to be solved?
What ability are you attempting to offer to the end user?
(I trimmed the rest, because you seemed to be
describing a strategy you thought might achieve
the goal, without actually stating what the goal was)

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via http://www.javakb.com

 
Reply With Quote
 
Robina Brintha
Guest
Posts: n/a
 
      04-10-2007
Dear Andrew,

I have an aplication which will be run by different clients at a time.
Each instance will first find if an update is needed through a method
in the application. The instance which finds that first will be the
coordinator who sends message(multicast) to all other instances.

So in this scenario if two instances finds that an update is needed in
exactly the same time they have to compete using some strategy and
agree upon that either one of them who wins the strategy will be the
coordinator who will send update message to all the others in the
group. Its the issue of what strategy can I use to choose coordinator
and how to share that state among other instances? Hope I have
explained bit clear now. Do you have any idea?


 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      04-10-2007

"Robina Brintha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Dear Andrew,
>
> I have an aplication which will be run by different clients at a time.
> Each instance will first find if an update is needed through a method
> in the application. The instance which finds that first will be the
> coordinator who sends message(multicast) to all other instances.
>
> So in this scenario if two instances finds that an update is needed in
> exactly the same time they have to compete using some strategy and
> agree upon that either one of them who wins the strategy will be the
> coordinator who will send update message to all the others in the
> group. Its the issue of what strategy can I use to choose coordinator
> and how to share that state among other instances? Hope I have
> explained bit clear now. Do you have any idea?


Will the instances be running on the same computer, the same LAN, or
over the internet?

- Oliver


 
Reply With Quote
 
Robina Brintha
Guest
Posts: n/a
 
      04-10-2007
On Apr 10, 5:27 pm, "Oliver Wong" <(E-Mail Removed)> wrote:
> "Robina Brintha" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ps.com...
>
> > Dear Andrew,

>
> > I have an aplication which will be run by different clients at a time.
> > Each instance will first find if an update is needed through a method
> > in the application. The instance which finds that first will be the
> > coordinator who sends message(multicast) to all other instances.

>
> > So in this scenario if two instances finds that an update is needed in
> > exactly the same time they have to compete using some strategy and
> > agree upon that either one of them who wins the strategy will be the
> > coordinator who will send update message to all the others in the
> > group. Its the issue of what strategy can I use to choose coordinator
> > and how to share that state among other instances? Hope I have
> > explained bit clear now. Do you have any idea?

>
> Will the instances be running on the same computer, the same LAN, or
> over the internet?
>
> - Oliver


instances run in same computer...

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      04-10-2007

"Robina Brintha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> On Apr 10, 5:27 pm, "Oliver Wong" <(E-Mail Removed)> wrote:
>> "Robina Brintha" <(E-Mail Removed)> wrote in message
>>
>> news:(E-Mail Removed) ps.com...
>>
>> > I have an aplication which will be run by different clients at a
>> > time.
>> > Each instance will first find if an update is needed through a method
>> > in the application. The instance which finds that first will be the
>> > coordinator who sends message(multicast) to all other instances.

>>

[...]
>> Will the instances be running on the same computer, the same LAN,
>> or
>> over the internet?
>>

>
> instances run in same computer...


Simplest solution is to try to acquire an exclusive resource in an
atomic fashion, and the first process to have successfully required this
resource is the "first" instance, and can act as the server or coordinator
or whatever.

Example include listening on a specific port or trying to gain
exclusive write-access to a specific file.

- Oliver


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      04-11-2007
Robina Brintha wrote:
...
>I have an aplication which will be run by different clients at a time.


You mention later that this will all be happening on one
single PC. *

>Each instance will first find if an update is needed through a method
>in the application. The instance which finds that first will be the
>coordinator who sends message(multicast) to all other instances.


* If that is the case, you might use the JNLP based SingleInstanceService **
to open a 'controller' application that launches a single screen of the
'user visible area' (AKA 'the application'). Later invocations will
'report to' that first controller instance, so it is possible to open
other UVA's as needed, while the controller is overseeing updates for
all.

** Here is an example <http://www.physci.org/jws/#sis>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200704/1

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compare two object instances? is"m1.to_yaml.eql?(m2.to_yaml)" a good way? Greg Hauptmann Ruby 7 09-05-2009 09:56 PM
dicts,instances,containers, slotted instances, et cetera. ocschwar@gmail.com Python 8 01-29-2009 09:52 AM
CAn i get multiple instances of java installed for different apps ? droodle Java 2 05-16-2007 12:49 PM
compare classes and not class instances jantod@gmail.com Python 2 03-02-2006 07:36 PM
list of class instances within a list of a class instances John Wohlbier Python 2 02-22-2004 08:41 AM



Advertisments