ClientStats generateLoadReport ( ) { ClientStats . Builder statsBuilder = ClientStats . newBuilder ( ) . setTimestamp ( Timestamps . fromNanos ( time . currentTimeNanos ( ) ) ) . setNumCallsStarted ( callsStartedUpdater . getAndSet ( this , 0 ) ) . setNumCallsFinished ( callsFinishedUpdater . getAndSet ( this , 0 ) ) . setNumCallsFinishedWithClientFailedToSend ( callsFailedToSendUpdater . getAndSet ( this , 0 ) ) . setNumCallsFinishedKnownReceived ( callsFinishedKnownReceivedUpdater . getAndSet ( this , 0 ) ) ; Map < String , LongHolder > localCallsDroppedPerToken = Collections . emptyMap ( ) ; synchronized ( this ) { if ( ! callsDroppedPerToken . isEmpty ( ) ) { localCallsDroppedPerToken = callsDroppedPerToken ; callsDroppedPerToken = new HashMap <> ( localCallsDroppedPerToken . size ( ) ) ; } } for ( Entry < String , LongHolder > entry : localCallsDroppedPerToken . entrySet ( ) ) { statsBuilder . addCallsFinishedWithDrop ( ClientStatsPerToken . newBuilder ( ) . setLoadBalanceToken ( entry . getKey ( ) ) . setNumCalls ( entry . getValue ( ) . num ) . build ( ) ) ; } return statsBuilder . build ( ) ; }
Generate the report with the data recorded this LB stream since the last report .