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

To M Spritzler - Client Thread ID change

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please help....
This is a followup to the "check client id" post..
The following is the log output when two clients are running network mode against the server. The
first client locks record 5, the second client
trys to lock the entire database. The log shows
that the first client is successful in locking record 5, the second client locks the first 4 records and waits on the 5th. Client 1 then releases the lock on record five, and the second client locks the remaining records in the database.
When the second client trys to unlock the records in the database, notice how the Thread ID changes,
so the lock logic doesn't think the second client owns the records previously locked.
The Thread for the second client starts out as
RMI TCP Connection(6)-127.0.0.1
then, after locking the database, CHANGES to
RMI TCP Connection(7)-127.0.0.1

so the unlock method will fail since it thinks it
is a different connection.
I tried storing/comparing on the Thread itself,
but got the same results.

Any comments.........

C:\Program Files\Java\Duane\Development Certification\Program>java RegFBNSDataba
se .\suncertify\db\db.db
FBNSDbRemote - ScheduleDb is <suncertify.db.Data@750159>
method lock() - Thread <RMI TCP Connection(4)-127.0.0.1> attempting lock
Attemping to lock record <5>
Lock on record <5 was successful for Thread <RMI TCP Connection(4)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(4)-127.0.0.1,5,RMI Runtime]

method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attempting to lock entire database.

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <0>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <0>
Lock on record <0 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <1>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <1>
Lock on record <1 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <2>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <2>
Lock on record <2 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <3>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <3>
Lock on record <3 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <4>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <4>
Lock on record <4 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(4)
-127.0.0.1,5,RMI Runtime]
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <5>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <5>
Lock() -- Lock on record <5> unavailable for Thread <RMI TCP Connection(6)-127.
0.0.1> waiting.......
method unlock() - Thread <RMI TCP Connection(4)-127.0.0.1> attempting unlock on
record <5>
Attempting to unlock record <5>

In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(4)
-127.0.0.1,5,RMI Runtime]
>
current Thread <Thread[RMI TCP Connection(4)-127.0.0.1,5,RMI Runtime]>
Thread owns lock...
Lock on record <5 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <6>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <6>
Lock on record <6 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <7>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <7>
Lock on record <7 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]
In ownsLock() object <LockStatus = false ThreadID = null
>
current Thread <Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]>
Database Lock - Locking record <8>
method lock() - Thread <RMI TCP Connection(6)-127.0.0.1> attempting lock
Attemping to lock record <8>
Lock on record <8 was successful for Thread <RMI TCP Connection(6)-127.0.0.1>Lo
ckStatus = true ThreadID = Thread[RMI TCP Connection(6)-127.0.0.1,5,RMI Runtime]

method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <0>
Attempting to unlock record <0>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <1>
Attempting to unlock record <1>

In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <2>
Attempting to unlock record <2>

In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <3>
Attempting to unlock record <3>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <4>
Attempting to unlock record <4>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <5>
Attempting to unlock record <5>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <6>
Attempting to unlock record <6>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <7>
Attempting to unlock record <7>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
method unlock() - Thread <RMI TCP Connection(7)-127.0.0.1> attempting unlock on
record <8>
Attempting to unlock record <8>
In ownsLock() object <LockStatus = true ThreadID = Thread[RMI TCP Connection(6)
-127.0.0.1,5,]
>
current Thread <Thread[RMI TCP Connection(7)-127.0.0.1,5,RMI Runtime]>
[ March 09, 2003: Message edited by: Max Habibi ]
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


When the second client trys to unlock the records in the database, notice how the Thread ID changes,
so the lock logic doesn't think the second client owns the records previously locked.


Mark is in North Dakota on vacation, but he is likely to close this thread when he returns because exactly same issue is discussed in this thread, where you also participated. As it has been pointed out by many people here, RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. Because of this, you should consider an RMI Factory approach to identify the clients.
Eugene.
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
As the other bartender here, I choose not to close this thread, because it sounds like Duane is specifically asking for Mark's help.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Duane Riech
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Your right, we're discussing this on another Thread. Please feel free to close this one.
Thanks for the response
    Bookmark Topic Watch Topic
  • New Topic