@Test public void testGetBothSuccess() { DataNodeConfig config = createConfig(1, 1); when(primarySource.get(any())).thenReturn(config); when(secondarySource.get(any())).thenReturn(config); assertEquals("Unexpected response", config, compositeSource.get(config.getInstanceName())); verify(primarySource).get(config.getInstanceName()); verify(secondarySource).get(config.getInstanceName()); }
@Override public DataNodeConfig get(String instanceName) { DataNodeConfig primaryResult = primarySource.get(instanceName); try { DataNodeConfig secondaryResult = secondarySource.get(instanceName); if (!Objects.equals(primaryResult, secondaryResult)) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Results differ for get({}). sourceOfTruth={}, secondarySource={}", instanceName, primaryResult, secondaryResult); } } catch (Exception e) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.get({})", instanceName, e); } return primaryResult; }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public DataNodeConfig get(String instanceName) { DataNodeConfig primaryResult = primarySource.get(instanceName); try { DataNodeConfig secondaryResult = secondarySource.get(instanceName); if (!Objects.equals(primaryResult, secondaryResult)) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Results differ for get({}). sourceOfTruth={}, secondarySource={}", instanceName, primaryResult, secondaryResult); } } catch (Exception e) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.get({})", instanceName, e); } return primaryResult; } }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public DataNodeConfig get(String instanceName) { DataNodeConfig primaryResult = primarySource.get(instanceName); try { DataNodeConfig secondaryResult = secondarySource.get(instanceName); if (!Objects.equals(primaryResult, secondaryResult)) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Results differ for get({}). sourceOfTruth={}, secondarySource={}", instanceName, primaryResult, secondaryResult); } } catch (Exception e) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.get({})", instanceName, e); } return primaryResult; } CompositeDataNodeConfigSource(DataNodeConfigSource primarySource, DataNodeConfigSource secondarySource,
      Time time, DataNodeConfigSourceMetrics metrics); }
CompositeDataNodeConfigSource implements DataNodeConfigSource { @Override public DataNodeConfig get(String instanceName) { DataNodeConfig primaryResult = primarySource.get(instanceName); try { DataNodeConfig secondaryResult = secondarySource.get(instanceName); if (!Objects.equals(primaryResult, secondaryResult)) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Results differ for get({}). sourceOfTruth={}, secondarySource={}", instanceName, primaryResult, secondaryResult); } } catch (Exception e) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.get({})", instanceName, 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 DataNodeConfig get(String instanceName) { DataNodeConfig primaryResult = primarySource.get(instanceName); try { DataNodeConfig secondaryResult = secondarySource.get(instanceName); if (!Objects.equals(primaryResult, secondaryResult)) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Results differ for get({}). sourceOfTruth={}, secondarySource={}", instanceName, primaryResult, secondaryResult); } } catch (Exception e) { metrics.getSwallowedErrorCount.inc(); LOGGER.error("Error from secondarySource.get({})", instanceName, 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();  }