private static void getStats(
      StatsSnapshot snapshot,
      AggregationData data,
      View view,
      ViewData.AggregationWindowData windowData) {
    if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_VIEW || view == RPC_SERVER_SERVER_LATENCY_VIEW) {
      snapshot.avgLatencyTotal = ((DistributionData) data).getMean();
    } else if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_MINUTE_VIEW
        || view == RPC_SERVER_SERVER_LATENCY_MINUTE_VIEW) {
      snapshot.avgLatencyLastMinute = ((AggregationData.MeanData) data).getMean();
    } else if (view == RPC_CLIENT_ROUNDTRIP_LATENCY_HOUR_VIEW
        || view == RPC_SERVER_SERVER_LATENCY_HOUR_VIEW) {
      snapshot.avgLatencyLastHour = ((AggregationData.MeanData) data).getMean();
    } else if (view == RPC_CLIENT_ERROR_COUNT_VIEW || view == RPC_SERVER_ERROR_COUNT_VIEW) {
      snapshot.errorsTotal = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_ERROR_COUNT_MINUTE_VIEW
        || view == RPC_SERVER_ERROR_COUNT_MINUTE_VIEW) {
      snapshot.errorsLastMinute = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_ERROR_COUNT_HOUR_VIEW
        || view == RPC_SERVER_ERROR_COUNT_HOUR_VIEW) {
      snapshot.errorsLastHour = ((AggregationData.MeanData) data).getCount();
    } else if (view == RPC_CLIENT_REQUEST_BYTES_VIEW || view == RPC_SERVER_REQUEST_BYTES_VIEW) {
      DistributionData distributionData = (DistributionData) data;
      snapshot.inputRateTotal =
          distributionData.getCount()
              * distributionData.getMean()
              / BYTES_PER_KB
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } else if (view == RPC_CLIENT_REQUEST_BYTES_MINUTE_VIEW
        || view == RPC_SERVER_REQUEST_BYTES_MINUTE_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.inputRateLastMinute =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_REQUEST_BYTES_HOUR_VIEW
        || view == RPC_SERVER_REQUEST_BYTES_HOUR_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.inputRateLastHour =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_VIEW || view == RPC_SERVER_RESPONSE_BYTES_VIEW) {
      DistributionData distributionData = (DistributionData) data;
      snapshot.outputRateTotal =
          distributionData.getCount()
              * distributionData.getMean()
              / BYTES_PER_KB
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_MINUTE_VIEW
        || view == RPC_SERVER_RESPONSE_BYTES_MINUTE_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.outputRateLastMinute =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_RESPONSE_BYTES_HOUR_VIEW
        || view == RPC_SERVER_RESPONSE_BYTES_HOUR_VIEW) {
      AggregationData.MeanData meanData = (AggregationData.MeanData) data;
      snapshot.outputRateLastHour =
          meanData.getMean() * meanData.getCount() / BYTES_PER_KB / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_STARTED_COUNT_MINUTE_VIEW
        || view == RPC_SERVER_STARTED_COUNT_MINUTE_VIEW) {
      snapshot.countLastMinute = ((CountData) data).getCount();
      snapshot.rpcRateLastMinute = snapshot.countLastMinute / SECONDS_PER_MINUTE;
    } else if (view == RPC_CLIENT_STARTED_COUNT_HOUR_VIEW
        || view == RPC_SERVER_STARTED_COUNT_HOUR_VIEW) {
      snapshot.countLastHour = ((CountData) data).getCount();
      snapshot.rpcRateLastHour = snapshot.countLastHour / SECONDS_PER_HOUR;
    } else if (view == RPC_CLIENT_STARTED_COUNT_CUMULATIVE_VIEW
        || view == RPC_SERVER_STARTED_COUNT_CUMULATIVE_VIEW) {
      snapshot.countTotal = ((CountData) data).getCount();
      snapshot.rpcRateTotal =
          snapshot.countTotal
              / getDurationInSecs((ViewData.AggregationWindowData.CumulativeData) windowData);
    } // TODO(songya): compute and store latency percentiles.
  }
private static void getStats ( StatsSnapshot snapshot , AggregationData data , View view , ViewData . AggregationWindowData windowData ) { if ( view == RPC_CLIENT_ROUNDTRIP_LATENCY_VIEW || view == RPC_SERVER_SERVER_LATENCY_VIEW ) { snapshot . avgLatencyTotal = ( ( DistributionData ) data ) . getMean ( ) ; } else if ( view == RPC_CLIENT_ROUNDTRIP_LATENCY_MINUTE_VIEW || view == RPC_SERVER_SERVER_LATENCY_MINUTE_VIEW ) { snapshot . avgLatencyLastMinute = ( ( AggregationData . MeanData ) data ) . getMean ( ) ; } else if ( view == RPC_CLIENT_ROUNDTRIP_LATENCY_HOUR_VIEW || view == RPC_SERVER_SERVER_LATENCY_HOUR_VIEW ) { snapshot . avgLatencyLastHour = ( ( AggregationData . MeanData ) data ) . getMean ( ) ; } else if ( view == RPC_CLIENT_ERROR_COUNT_VIEW || view == RPC_SERVER_ERROR_COUNT_VIEW ) { snapshot . errorsTotal = ( ( AggregationData . MeanData ) data ) . getCount ( ) ; } else if ( view == RPC_CLIENT_ERROR_COUNT_MINUTE_VIEW || view == RPC_SERVER_ERROR_COUNT_MINUTE_VIEW ) { snapshot . errorsLastMinute = ( ( AggregationData . MeanData ) data ) . getCount ( ) ; } else if ( view == RPC_CLIENT_ERROR_COUNT_HOUR_VIEW || view == RPC_SERVER_ERROR_COUNT_HOUR_VIEW ) { snapshot . errorsLastHour = ( ( AggregationData . MeanData ) data ) . getCount ( ) ; } else if ( view == RPC_CLIENT_REQUEST_BYTES_VIEW || view == RPC_SERVER_REQUEST_BYTES_VIEW ) { DistributionData distributionData = ( DistributionData ) data ; snapshot . inputRateTotal = distributionData . getCount ( ) * distributionData . getMean ( ) / BYTES_PER_KB / getDurationInSecs ( ( ViewData . AggregationWindowData . CumulativeData ) windowData ) ; } else if ( view == RPC_CLIENT_REQUEST_BYTES_MINUTE_VIEW || view == RPC_SERVER_REQUEST_BYTES_MINUTE_VIEW ) { AggregationData . MeanData meanData = ( AggregationData . MeanData ) data ; snapshot . inputRateLastMinute = meanData . getMean ( ) * meanData . getCount ( ) / BYTES_PER_KB / SECONDS_PER_MINUTE ; } else if ( view == RPC_CLIENT_REQUEST_BYTES_HOUR_VIEW || view == RPC_SERVER_REQUEST_BYTES_HOUR_VIEW ) { AggregationData . MeanData meanData = ( AggregationData . MeanData ) data ; snapshot . inputRateLastHour = meanData . getMean ( ) * meanData . getCount ( ) / BYTES_PER_KB / SECONDS_PER_HOUR ; } else if ( view == RPC_CLIENT_RESPONSE_BYTES_VIEW || view == RPC_SERVER_RESPONSE_BYTES_VIEW ) { DistributionData distributionData = ( DistributionData ) data ; snapshot . outputRateTotal = distributionData . getCount ( ) * distributionData . getMean ( ) / BYTES_PER_KB / getDurationInSecs ( ( ViewData . AggregationWindowData . CumulativeData ) windowData ) ; } else if ( view == RPC_CLIENT_RESPONSE_BYTES_MINUTE_VIEW || view == RPC_SERVER_RESPONSE_BYTES_MINUTE_VIEW ) { AggregationData . MeanData meanData = ( AggregationData . MeanData ) data ; snapshot . outputRateLastMinute = meanData . getMean ( ) * meanData . getCount ( ) / BYTES_PER_KB / SECONDS_PER_MINUTE ; } else if ( view == RPC_CLIENT_RESPONSE_BYTES_HOUR_VIEW || view == RPC_SERVER_RESPONSE_BYTES_HOUR_VIEW ) { AggregationData . MeanData meanData = ( AggregationData . MeanData ) data ; snapshot . outputRateLastHour = meanData . getMean ( ) * meanData . getCount ( ) / BYTES_PER_KB / SECONDS_PER_HOUR ; } else if ( view == RPC_CLIENT_STARTED_COUNT_MINUTE_VIEW || view == RPC_SERVER_STARTED_COUNT_MINUTE_VIEW ) { snapshot . countLastMinute = ( ( CountData ) data ) . getCount ( ) ; snapshot . rpcRateLastMinute = snapshot . countLastMinute / SECONDS_PER_MINUTE ; } else if ( view == RPC_CLIENT_STARTED_COUNT_HOUR_VIEW || view == RPC_SERVER_STARTED_COUNT_HOUR_VIEW ) { snapshot . countLastHour = ( ( CountData ) data ) . getCount ( ) ; snapshot . rpcRateLastHour = snapshot . countLastHour / SECONDS_PER_HOUR ; } else if ( view == RPC_CLIENT_STARTED_COUNT_CUMULATIVE_VIEW || view == RPC_SERVER_STARTED_COUNT_CUMULATIVE_VIEW ) { snapshot . countTotal = ( ( CountData ) data ) . getCount ( ) ; snapshot . rpcRateTotal = snapshot . countTotal / getDurationInSecs ( ( ViewData . AggregationWindowData . CumulativeData ) windowData ) ; } }
Gets RPC stats by its view definition, and set it to stats snapshot.