@Test public void stressTest() { int numTableReferences = 1000; List<TableReference> tableReferences = IntStream.range(0, numTableReferences) .mapToObj(this::getTableReference) .collect(Collectors.toList()); for (int iteration = 0; iteration < 5; iteration++) { Collections.shuffle(tableReferences); tableReferences.forEach(tableReference -> memoizing.createAndRegisterCounter( STRING_CLASS, METRIC_NAME, tableReference)); } verify(delegate, times(numTableReferences)).createAndRegisterCounter(any(), any(), any()); }
@Override public <T> Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference) { return metricSpecCounterCache.get(MetricSpec.of(clazz, metricName, tableReference)); }
MemoizingTableLevelMetricsController implements TableLevelMetricsController { @Override public <T> Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference) { return metricSpecCounterCache.get(MetricSpec.of(clazz, metricName, tableReference)); } }
MemoizingTableLevelMetricsController implements TableLevelMetricsController { @Override public <T> Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference) { return metricSpecCounterCache.get(MetricSpec.of(clazz, metricName, tableReference)); } MemoizingTableLevelMetricsController(TableLevelMetricsController delegate); }
MemoizingTableLevelMetricsController implements TableLevelMetricsController { @Override public <T> Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference) { return metricSpecCounterCache.get(MetricSpec.of(clazz, metricName, tableReference)); } MemoizingTableLevelMetricsController(TableLevelMetricsController delegate); @Override Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference); }
MemoizingTableLevelMetricsController implements TableLevelMetricsController { @Override public <T> Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference) { return metricSpecCounterCache.get(MetricSpec.of(clazz, metricName, tableReference)); } MemoizingTableLevelMetricsController(TableLevelMetricsController delegate); @Override Counter createAndRegisterCounter(Class<T> clazz, String metricName, TableReference tableReference);  }