public static void initialiseLinks ( TraceCompletionInformation ci , long fragmentBaseTime , Node n , StringBuilder nodeId ) { // Add Communication to represent a potential 'CausedBy' link from one or more fragments back to // this node TraceCompletionInformation . Communication c = new TraceCompletionInformation . Communication ( ) ; c . getIds ( ) . add ( nodeId . toString ( ) ) ; // Define a a multi-consumer as potentially multiple CausedBy correlations may be created // back to this node c . setMultipleConsumers ( true ) ; // Calculate the base duration for the communication c . setBaseDuration ( n . getTimestamp ( ) - fragmentBaseTime ) ; c . setExpire ( System . currentTimeMillis ( ) + TraceCompletionInformation . Communication . DEFAULT_EXPIRY_WINDOW_MILLIS ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Adding communication to completion information: ci=" + ci + " comms=" + c ) ; } ci . getCommunications ( ) . add ( c ) ; if ( n . getClass ( ) == Producer . class ) { // Get correlation ids List < CorrelationIdentifier > cids = n . findCorrelationIds ( Scope . Interaction , Scope . ControlFlow ) ; if ( ! cids . isEmpty ( ) ) { c = new TraceCompletionInformation . Communication ( ) ; for ( int i = 0 ; i < cids . size ( ) ; i ++ ) { c . getIds ( ) . add ( cids . get ( i ) . getValue ( ) ) ; } c . setMultipleConsumers ( ( ( Producer ) n ) . multipleConsumers ( ) ) ; // Calculate the base duration for the communication c . setBaseDuration ( n . getTimestamp ( ) - fragmentBaseTime ) ; c . setExpire ( System . currentTimeMillis ( ) + TraceCompletionInformation . Communication . DEFAULT_EXPIRY_WINDOW_MILLIS ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Adding communication to completion information: ci=" + ci + " comms=" + c ) ; } ci . getCommunications ( ) . add ( c ) ; } } else if ( n . containerNode ( ) ) { ContainerNode cn = ( ContainerNode ) n ; for ( int i = 0 ; i < cn . getNodes ( ) . size ( ) ; i ++ ) { int len = nodeId . length ( ) ; nodeId . append ( ' ' ) ; nodeId . append ( i ) ; initialiseLinks ( ci , fragmentBaseTime , cn . getNodes ( ) . get ( i ) , nodeId ) ; // Remove this child's specific path, so that next iteration will add a different path number nodeId . delete ( len , nodeId . length ( ) ) ; } } }
This method initialises the completion time information for a trace instance .