@Test(expected = IllegalArgumentException.class) public void testDuplicateRegister() { String name = "test1"; Metrics.register(name, new StubReservoir()); Metrics.register(name, new StubReservoir()); }
public ActiveReservoir register(String name, ActiveReservoir activeReservoir) { if (name == null || activeReservoir == null) { throw new IllegalArgumentException("neither of name or ActiveReservoir can be null"); } final ActiveReservoir existingReservoir = activeReservoirs.putIfAbsent(name, activeReservoir); if (existingReservoir == null) { onActiveReservoirAdded(activeReservoir); } else { throw new IllegalArgumentException("An active reservoir named " + name + " already exists"); } return activeReservoir; }
MetricsSystem extends MetricRegistry { public ActiveReservoir register(String name, ActiveReservoir activeReservoir) { if (name == null || activeReservoir == null) { throw new IllegalArgumentException("neither of name or ActiveReservoir can be null"); } final ActiveReservoir existingReservoir = activeReservoirs.putIfAbsent(name, activeReservoir); if (existingReservoir == null) { onActiveReservoirAdded(activeReservoir); } else { throw new IllegalArgumentException("An active reservoir named " + name + " already exists"); } return activeReservoir; } }
MetricsSystem extends MetricRegistry { public ActiveReservoir register(String name, ActiveReservoir activeReservoir) { if (name == null || activeReservoir == null) { throw new IllegalArgumentException("neither of name or ActiveReservoir can be null"); } final ActiveReservoir existingReservoir = activeReservoirs.putIfAbsent(name, activeReservoir); if (existingReservoir == null) { onActiveReservoirAdded(activeReservoir); } else { throw new IllegalArgumentException("An active reservoir named " + name + " already exists"); } return activeReservoir; } private  MetricsSystem(); }
MetricsSystem extends MetricRegistry { public ActiveReservoir register(String name, ActiveReservoir activeReservoir) { if (name == null || activeReservoir == null) { throw new IllegalArgumentException("neither of name or ActiveReservoir can be null"); } final ActiveReservoir existingReservoir = activeReservoirs.putIfAbsent(name, activeReservoir); if (existingReservoir == null) { onActiveReservoirAdded(activeReservoir); } else { throw new IllegalArgumentException("An active reservoir named " + name + " already exists"); } return activeReservoir; } private  MetricsSystem(); void shutdown(); ActiveReservoir activeReservoir(String name); ActiveReservoir register(String name, ActiveReservoir activeReservoir); boolean removeActiveReservoir(String name); void removeActiveReservoirMatching(ActiveReservoirRecordFilter filter); SortedMap<String, ActiveReservoir> getActiveReservoirs(); SortedMap<String, ActiveReservoir> getActiveReservoirs(ActiveReservoirRecordFilter filter); }
MetricsSystem extends MetricRegistry { public ActiveReservoir register(String name, ActiveReservoir activeReservoir) { if (name == null || activeReservoir == null) { throw new IllegalArgumentException("neither of name or ActiveReservoir can be null"); } final ActiveReservoir existingReservoir = activeReservoirs.putIfAbsent(name, activeReservoir); if (existingReservoir == null) { onActiveReservoirAdded(activeReservoir); } else { throw new IllegalArgumentException("An active reservoir named " + name + " already exists"); } return activeReservoir; } private  MetricsSystem(); void shutdown(); ActiveReservoir activeReservoir(String name); ActiveReservoir register(String name, ActiveReservoir activeReservoir); boolean removeActiveReservoir(String name); void removeActiveReservoirMatching(ActiveReservoirRecordFilter filter); SortedMap<String, ActiveReservoir> getActiveReservoirs(); SortedMap<String, ActiveReservoir> getActiveReservoirs(ActiveReservoirRecordFilter filter); static final MetricsSystem Metrics; }