@Test public void computeHash() throws IOException { ObjectMapper om = new ObjectMapperFactory().withModule(new DynamicConfigApiJsonModule()).create(); HashComputer hashComputer = new DefaultHashComputer(); Node node = Testing.newTestNode("foo", "localhost"); NodeContext nodeContext = new NodeContext(Testing.newTestCluster(Testing.newTestStripe("stripe-1").addNodes(node)), Testing.N_UIDS[1]); String hash = hashComputer.computeHash(new Config(nodeContext, Version.CURRENT)); String json = om.writeValueAsString(nodeContext); NodeContext reloaded = om.readValue(json, NodeContext.class); String reloadedHash = hashComputer.computeHash(new Config(reloaded, Version.CURRENT)); assertThat(reloaded, is(nodeContext)); assertThat(reloadedHash, is(hash)); }
@Override public String computeHash(Config config) { String output = Props.toString(config.getTopology().getCluster().toProperties(false, false, true, config.getVersion())); String hash = HashUtils.generateHash(output); LOGGER.debug("Computed hash: {} for config:\n{}", hash, output); return hash; }
DefaultHashComputer implements HashComputer { @Override public String computeHash(Config config) { String output = Props.toString(config.getTopology().getCluster().toProperties(false, false, true, config.getVersion())); String hash = HashUtils.generateHash(output); LOGGER.debug("Computed hash: {} for config:\n{}", hash, output); return hash; } }
DefaultHashComputer implements HashComputer { @Override public String computeHash(Config config) { String output = Props.toString(config.getTopology().getCluster().toProperties(false, false, true, config.getVersion())); String hash = HashUtils.generateHash(output); LOGGER.debug("Computed hash: {} for config:\n{}", hash, output); return hash; }  }
DefaultHashComputer implements HashComputer { @Override public String computeHash(Config config) { String output = Props.toString(config.getTopology().getCluster().toProperties(false, false, true, config.getVersion())); String hash = HashUtils.generateHash(output); LOGGER.debug("Computed hash: {} for config:\n{}", hash, output); return hash; }  @Override String computeHash(Config config); @Override void checkHash(Config config, String expectedHash); }
DefaultHashComputer implements HashComputer { @Override public String computeHash(Config config) { String output = Props.toString(config.getTopology().getCluster().toProperties(false, false, true, config.getVersion())); String hash = HashUtils.generateHash(output); LOGGER.debug("Computed hash: {} for config:\n{}", hash, output); return hash; }  @Override String computeHash(Config config); @Override void checkHash(Config config, String expectedHash);  }