• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

testing multithreading PB : network and local thread running

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
I am almost done and I am trying to test my multithreading safety.
here is how my application is built.
I have








And I have created different tests to simulate multithreading:

1) test 50 remote access simultaneously:



This works fine: one thread acquire the lock and the others wait until it is unlocked...

2) Same test but for 50 local access simultaneously:



This works fine also: one thread acquire the lock and the others wait until it is unlocked...

3) Now is where things don't work I do the same thing but create 2 threads: one remote and one local and start them : They both acquire the lock!!!






I don't understand what is wrong in my design that it does not work when i mix remote and local, but is perfectly safe with just remote or just local. It it the test or the code the problem?


Thank you very much for all your help in this
- Lydie
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Lydie,
Literally in my specs:


... your locking system only needs to be concerned with multiple concurrent clients of your server ...



Anyway:


I haven't read it carefully but...

You are have two different instances of Data, one for local, and one for remote, not?

One solution to that will be do the test at the server main thread, remote clients get your DataClient instance through the registry, and local use that DataClient instance you bind ...

Excuse my hurry, it's coffee time!
Back in some minutes
Regards
 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response.
Yes, I know that I just have to be concerned by concurent threads with the server as you mentionned but is this hiding something else???
The all thing bother me: Why???
And if there is a flaw in my design, I would like to understand it to make sure my design is right.

You are have two different instances of Data, one for local, and one for remote, not?

code:


dataAdaptater = ClientConnector.getLocal("./");
recordNumber =13; new LockTest(dataAdaptater , recordNumber);
dataClient = ClientConnector.getRemote("localhost", 1099);

[\QOTE]

Note that dataAdaptater implements DataClient, so it is OK.
In fact I redid the test with :



and I get the same result : the two instances get the lock , which does not happen with multiple remote instances!. In fact with some debugging in the server side, I saw that the lockedRecord hashmap (althought static) is nott the same server/local....the record does not appera to be locked and each instance locks it.
Why is that ? It is static and should be shared by all the instances I create wether they are from a static or remote connection they are DataClient instances and should share lockedRecord!!!
It is sahred by multiples remote instances, I checked, so why is it that way with one remote and on local???
There is something I don't get....


One solution to that will be do the test at the server main thread, remote clients get your DataClient instance through the registry, and local use that DataClient instance you bind ...



I am not sur I undersatnd what you mean here....

It is my turn to grab a - stong - coffee now...
Thanks again
- Lydie

 
Oricio Ocle
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Lydie,
Thats where i think the problem is:
Despite of running rmi server and client in the same virtual machine, you are suposing that both share a common memory space for static members.
Think in a general scenario with server and clients running on different machines, then it's clear that your test is not running in the correct machine, not?
That's why i said:

do the test at the server main thread


i wanted mean:
Both instances of your data class must be at the same side (rmi-network side): Local side.
And in you are running the test with a rmi-local instance and a rmi-remote instance

Hope that help you
Regards
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that because there are two JVMs - and are not sharing the hash maps - the "local" instance versus the server (RMI?) ? (the local/standalone client instance is not looking for the localhost server)

So there will be two separate hash maps. and two "locks" (but not really, because the locking supposes one hash map).

One for "localhost" server (started separately?), one for local client which is part of your test driver code.
 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both, I have just realized it last night (was still thinking of it !).
-Lydie
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic