private void assignLockManagerFromCluster ( ) { String lockManagerServer = null ; while ( lockManagerServer == null ) { if ( activeNodes . size ( ) == 1 ) { // ONLY CURRENT NODE ONLINE, SET IT AS INITIAL LOCK MANAGER lockManagerServer = nodeName ; if ( configurationMap . putIfAbsent ( CONFIG_LOCKMANAGER , lockManagerServer ) == null ) break ; } else { lockManagerServer = ( String ) configurationMap . get ( CONFIG_LOCKMANAGER ) ; if ( lockManagerServer != null && lockManagerServer . equals ( nodeName ) ) { // LAST LOCK MANAGER WAS CURRENT NODE? TRY TO FORCE A NEW ELECTION OLogManager . instance ( ) . info ( this , "Found lock as current node, even if it was offline. Forcing a new election..." ) ; getLockManagerRequester ( ) . setServer ( lockManagerServer ) ; lockManagerServer = electNewLockManager ( ) ; break ; } if ( lockManagerServer != null ) break ; } try { Thread . sleep ( 100 ) ; } catch ( InterruptedException e ) { break ; } } getLockManagerRequester ( ) . setServer ( lockManagerServer ) ; OLogManager . instance ( ) . info ( this , "Distributed Lock Manager server is '%s'" , lockManagerServer ) ; }
ASSIGN THE LOCK MANAGER AT STARTUP