please ignore this question
since individual server instances under a cluster are running in its own
JVM process, so there is no way to have a "global variable" crossing
server-instances... I was under a false impression that clustered server
instances are only compartmented in its separate classloader universe on
the same JVM, hence it is desirable that a static shared object such as
a HashMap be accessible to the threads within the server instances.
the false impression is actually from the tracing I printed out in the
server.log from both instances : instance-ONE/instance-TWO:
note that the hashcodes for the class loader loading the concerned java
class are identical and also the hashcodes for the static HashMap in the
singleton com.sun.jbi.bindings.shared.registry.LockRegistry are
identical (initially - later it becomes different in each instance)
====== the server.log for instance-ONE/instnace-TWO....
instance-ONE/server.log:
[#|2009-03-24T15:50:43.935-0700|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|
Retrieving document at
'C:\glassfish_2.1\glassfish\nodeagents\cluster1-nodeagent\instance-ONE\jbi\service-assemblies\HelloDukeCompApplication\HelloDukeCompApplication-sun-ftp-binding\sun-ftp-binding\HelloDuke\FTP.wsdl'.|#]
[#|2009-03-24T15:50:43.997-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003008:
Activated outbound endpoint for service name
{
http://j2ee.netbeans.org/wsdl/FTP}service1 and endpoint name port1.|#]
[#|2009-03-24T15:50:44.044-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.register(key,
lock) === *LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137*|#]
*[#|2009-03-24T15:50:44.044-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.get(key)
=== HasMap :::::: hashcode=230043070 value={force_allooc=dummy}|#]*
[#|2009-03-24T15:50:44.044-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.register(key,
lock) === LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137|#]
[#|2009-03-24T15:50:44.060-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.get(key)
=== HasMap :::::: hashcode=230043070 value={force_allooc=dummy}|#]
[#|2009-03-24T15:50:44.060-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.register(key,
lock) === LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137|#]
[#|2009-03-24T15:50:44.060-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=80af1700-9edf-48e8-919b-61b2b21e69f0;|LockRegistry.get(key)
=== HasMap :::::: hashcode=-933287174
value={449b888d-46aa-338b-8397-ada5cd19f683=com.sun.jbi.bindings.shared.registr,
force_allooc=dummy}|#]
[#|2009-03-24T15:50:44.060-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.FTPBindingDeployer|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R002003:
Successfully initialized service unit
HelloDukeCompApplication-sun-ftp-binding.|#]
[#|2009-03-24T15:50:44.326-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.FTPBindingDeployer|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R002008:
Shutting down service unit: HelloDukeCompApplication-sun-ftp-binding.|#]
[#|2009-03-24T15:50:44.326-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003006:
ServiceUnit shutdown method called.|#]
[#|2009-03-24T15:50:44.326-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003009:
Deactivated outbound endpoint with service name
{
http://j2ee.netbeans.org/wsdl/FTP}service1 and endpoint name port1.|#]
instance-TWO/server.log:
[#|2009-03-24T15:50:43.529-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003008:
Activated outbound endpoint for service name
{
http://j2ee.netbeans.org/wsdl/FTP}service1 and endpoint name port1.|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.register(key,
lock) === *LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137*|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.get(key)
=== *HasMap :::::: hashcode=230043070 value={force_allooc=dummy}*|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.register(key,
lock) === LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.get(key)
=== HasMap :::::: hashcode=230043070 value={force_allooc=dummy}|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.register(key,
lock) === LockRegistry's class loader
::::::sun.misc.Launcher$AppClassLoader_at_a39137|#]
[#|2009-03-24T15:50:43.576-0700|SEVERE|sun-appserver2.1|com.sun.jbi.bindings.shared.registry.LockRegistry|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;_RequestID=e263951d-a581-48b8-9f7e-dd884aaef987;|LockRegistry.get(key)
=== HasMap :::::: hashcode=-918078638
value={449b888d-46aa-338b-8397-ada5cd19f683=com.sun.jbi.bindings.shared.registr,
force_allooc=dummy}|#]
[#|2009-03-24T15:50:43.576-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.FTPBindingDeployer|_ThreadID=20;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R002003:
Successfully initialized service unit
HelloDukeCompApplication-sun-ftp-binding.|#]
[#|2009-03-24T15:50:44.076-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.FTPBindingDeployer|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R002008:
Shutting down service unit: HelloDukeCompApplication-sun-ftp-binding.|#]
[#|2009-03-24T15:50:44.076-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003006:
ServiceUnit shutdown method called.|#]
[#|2009-03-24T15:50:44.076-0700|INFO|sun-appserver2.1|sun-ftp-binding.com.sun.jbi.ftpbc.ServiceUnitImpl|_ThreadID=21;_ThreadName=HelloDukeCompApplication-sun-ftp-binding;|FTPBC-R003009:
Deactivated outbound endpoint with service name
{
http://j2ee.netbeans.org/wsdl/FTP}service1 and endpoint name port1.|#]
Jim Fu wrote:
> I am using java.util.concurrent.ReentrantLock to synchronize threads
> on a JVM.
> when the application is deployed to a cluster, the lock instance is
> per server instance, meaning only threads running on the same instance
> can be synchronized by the lock instance.
>
> is it possible to make the lock instance 'global' to the server
> instances?
>
> BTW, tried to put the lock registry class (a singleton with a static
> HashMap inside) in system class path hoping that it will be a global
> registry accessible to both server instances in the cluster, but the
> runtime debugging shows that it is still a per server instance
> reference (indicated by different hashcode).
>
> is this achievable under glassfish v2.1 clustering?
>
> thanks in advance
>
> Jim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>