@VisibleForTesting
  double getErrorRate(Map<ErrorType, Integer> errorTypeCounts, int callCount)
  {
    Integer connectExceptionCount = errorTypeCounts.getOrDefault(ErrorType.CONNECT_EXCEPTION, 0);
    Integer closedChannelExceptionCount = errorTypeCounts.getOrDefault(ErrorType.CLOSED_CHANNEL_EXCEPTION, 0);
    Integer serverErrorCount = errorTypeCounts.getOrDefault(ErrorType.SERVER_ERROR, 0);
    Integer timeoutExceptionCount = errorTypeCounts.getOrDefault(ErrorType.TIMEOUT_EXCEPTION, 0);
    Integer streamErrorCount = errorTypeCounts.getOrDefault(ErrorType.STREAM_ERROR, 0);

    double validExceptionCount = connectExceptionCount + closedChannelExceptionCount + serverErrorCount
        + timeoutExceptionCount;
    if (_loadBalanceStreamException)
    {
      validExceptionCount += streamErrorCount;
    }
    return callCount == 0 ? 0 : validExceptionCount / callCount;
  }
@Test(dataProvider = "loadBalanceStreamExceptionDataProvider")
  public void testGetErrorRateWithStreamError(Boolean loadBalanceStreamException)
  {
    Map<ErrorType, Integer> errorTypeCounts = ImmutableMap.of(
        ErrorType.CONNECT_EXCEPTION, 1,
        ErrorType.CLOSED_CHANNEL_EXCEPTION, 1,
        ErrorType.SERVER_ERROR, 1,
        ErrorType.TIMEOUT_EXCEPTION, 1,
        ErrorType.STREAM_ERROR, 10
    );

    StateUpdater stateUpdater = new StateUpdater(new D2RelativeStrategyProperties().setUpdateIntervalMs(5000),
        _quarantineManager, _executorService, new ConcurrentHashMap<>(), Collections.emptyList(), SERVICE_NAME,
        loadBalanceStreamException);

    assertEquals( stateUpdater.getErrorRate(errorTypeCounts, 20), loadBalanceStreamException ? 0.7 : 0.2);
  }