@Test public void testSetBothSuccess() { when(primarySource.set(any())).thenReturn(true); when(secondarySource.set(any())).thenReturn(true); DataNodeConfig config = createConfig(1, 1); assertTrue("Expected success response", compositeSource.set(config)); verify(primarySource).set(config); verify(secondarySource).set(config); }
@Override public boolean set(DataNodeConfig config) { boolean primaryResult = primarySource.set(config); try { boolean secondaryResult = secondarySource.set(config); if (primaryResult != secondaryResult) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Results differ for set({}). sourceOfTruth={}, secondarySource={}", config, primaryResult, secondaryResult); } } catch (Exception e) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.set({})", config, e); } return primaryResult; }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public boolean set(DataNodeConfig config) { boolean primaryResult = primarySource.set(config); try { boolean secondaryResult = secondarySource.set(config); if (primaryResult != secondaryResult) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Results differ for set({}). sourceOfTruth={}, secondarySource={}", config, primaryResult, secondaryResult); } } catch (Exception e) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.set({})", config, e); } return primaryResult; } }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public boolean set(DataNodeConfig config) { boolean primaryResult = primarySource.set(config); try { boolean secondaryResult = secondarySource.set(config); if (primaryResult != secondaryResult) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Results differ for set({}). sourceOfTruth={}, secondarySource={}", config, primaryResult, secondaryResult); } } catch (Exception e) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.set({})", config, e); } return primaryResult; } CompositeDataNodeConfigSource(DataNodeConfigSource primarySource, DataNodeConfigSource secondarySource,
      Time time, DataNodeConfigSourceMetrics metrics); }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public boolean set(DataNodeConfig config) { boolean primaryResult = primarySource.set(config); try { boolean secondaryResult = secondarySource.set(config); if (primaryResult != secondaryResult) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Results differ for set({}). sourceOfTruth={}, secondarySource={}", config, primaryResult, secondaryResult); } } catch (Exception e) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.set({})", config, e); } return primaryResult; } CompositeDataNodeConfigSource(DataNodeConfigSource primarySource, DataNodeConfigSource secondarySource,
      Time time, DataNodeConfigSourceMetrics metrics); @Override void addDataNodeConfigChangeListener(DataNodeConfigChangeListener listener); @Override boolean set(DataNodeConfig config); @Override DataNodeConfig get(String instanceName); @Override void close(); }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public boolean set(DataNodeConfig config) { boolean primaryResult = primarySource.set(config); try { boolean secondaryResult = secondarySource.set(config); if (primaryResult != secondaryResult) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Results differ for set({}). sourceOfTruth={}, secondarySource={}", config, primaryResult, secondaryResult); } } catch (Exception e) { metrics.setSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.set({})", config, e); } return primaryResult; } CompositeDataNodeConfigSource(DataNodeConfigSource primarySource, DataNodeConfigSource secondarySource,
      Time time, DataNodeConfigSourceMetrics metrics); @Override void addDataNodeConfigChangeListener(DataNodeConfigChangeListener listener); @Override boolean set(DataNodeConfig config); @Override DataNodeConfig get(String instanceName); @Override void close();  }