protected List < EndpointInfo > doGetUnboundEndpoints ( String tenantId , List < Trace > fragments , boolean compress ) { List < EndpointInfo > ret = new ArrayList < EndpointInfo > ( ) ; Map < String , EndpointInfo > map = new HashMap < String , EndpointInfo > ( ) ; // Process the fragments to identify which endpoints are not used in any trace for ( int i = 0 ; i < fragments . size ( ) ; i ++ ) { Trace trace = fragments . get ( i ) ; if ( trace . initialFragment ( ) && ! trace . getNodes ( ) . isEmpty ( ) && trace . getTransaction ( ) == null ) { // Check if top level node is Consumer if ( trace . getNodes ( ) . get ( 0 ) instanceof Consumer ) { Consumer consumer = ( Consumer ) trace . getNodes ( ) . get ( 0 ) ; String endpoint = EndpointUtil . encodeEndpoint ( consumer . getUri ( ) , consumer . getOperation ( ) ) ; // Check whether endpoint already known, and that it did not result // in a fault (e.g. want to ignore spurious URIs that are not // associated with a valid transaction) if ( ! map . containsKey ( endpoint ) && consumer . getProperties ( Constants . PROP_FAULT ) . isEmpty ( ) ) { EndpointInfo info = new EndpointInfo ( ) ; info . setEndpoint ( endpoint ) ; info . setType ( consumer . getEndpointType ( ) ) ; ret . add ( info ) ; map . put ( endpoint , info ) ; } } else { obtainProducerEndpoints ( trace . getNodes ( ) , ret , map ) ; } } } // Check whether any of the top level endpoints are already associated with // a transaction config if ( configService != null ) { Map < String , TransactionConfig > configs = configService . getTransactions ( tenantId , 0 ) ; for ( TransactionConfig config : configs . values ( ) ) { if ( config . getFilter ( ) != null && config . getFilter ( ) . getInclusions ( ) != null ) { if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Remove unbound URIs associated with btxn config=" + config ) ; } for ( String filter : config . getFilter ( ) . getInclusions ( ) ) { if ( filter != null && ! filter . trim ( ) . isEmpty ( ) ) { Iterator < EndpointInfo > iter = ret . iterator ( ) ; while ( iter . hasNext ( ) ) { EndpointInfo info = iter . next ( ) ; if ( Pattern . matches ( filter , info . getEndpoint ( ) ) ) { iter . remove ( ) ; } } } } } } } // Check if the endpoints should be compressed to identify common patterns if ( compress ) { ret = compressEndpointInfo ( ret ) ; } Collections . sort ( ret , new Comparator < EndpointInfo > ( ) { @ Override public int compare ( EndpointInfo arg0 , EndpointInfo arg1 ) { return arg0 . getEndpoint ( ) . compareTo ( arg1 . getEndpoint ( ) ) ; } } ) ; return ret ; }
This method obtains the unbound endpoints from a list of trace fragments .