public ConsumerKeyGroup joinKeyGroup ( ConsumerKey consumerKey , OrderingContextImpl orderingGroup ) throws SIResourceException , SISessionDroppedException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "joinKeyGroup" , new Object [ ] { consumerKey , orderingGroup } ) ; JSKeyGroup keyGroup = null ; // We need to hold the keyGroup lock while we add a member (to prevent the // member count (and therefore the ready state) changing under an existing // member's feet). We also need the readyConsumerPointLock while we're adding // a new keyGroup to the hashmap (as users of different groups may attempt to // join at the same time). But we cannot hold the readyConsumerPointLock while we // do this as it is below the keyGroup lock in the hierarchy. Instead we lock // the orderingGroup as a whole, this prevents anyone else trying to come along // and join a new keyGroup (and possibly leave it - causing it to be removed) // before we manage to add ourselves to it. synchronized ( orderingGroup ) { synchronized ( _baseDestHandler . getReadyConsumerPointLock ( ) ) { // See if a keyGroup (specific to a CD) for the supplied orderingGroup is // currently attached to this CD if ( ( keyGroup = keyGroups . get ( orderingGroup ) ) == null ) { // If not, create one // We pass the consumerSet as parameter. This will only be non-null // where XD has registered for message classification JSConsumerSet consumerSet = null ; if ( consumerKey instanceof ConsumableKey ) { consumerSet = ( ( ConsumableKey ) consumerKey ) . getConsumerSet ( ) ; keyGroup = createConsumerKeyGroup ( consumerSet ) ; if ( keyGroup != null ) keyGroups . put ( orderingGroup , keyGroup ) ; } } } //Add this key to the keyGroup if ( keyGroup != null ) ( ( ConsumableKey ) consumerKey ) . joinKeyGroup ( keyGroup ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "joinKeyGroup" , keyGroup ) ; return keyGroup ; }
Add the supplied consumerKey to a keyGroup create the keyGroup if required