Forums Register Login

testing multithreading PB : network and local thread running

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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

 
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thank you both, I have just realized it last night (was still thinking of it !).
-Lydie
This parrot is no more. It has ceased to be. Now it's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1027 times.
Similar Threads
How to simulate multiple clients for testing
B&S Locking
help on lock and unlock
NX: URLYBird / my approach of the reading problem
Design Questions
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:59:13.