@Test public void testLoadIllegalValue() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); Properties p = new Properties(); p.setProperty("replication.entries.max", "foo"); p.store(output, ""); DefaultNodeConfigLoader loader = new DefaultNodeConfigLoader(); NodeConfig config = loader.load(new ByteArrayInputStream(output.toByteArray())); Assert.assertEquals(Log.ALL_ENTRIES, config.getMaxReplicationEntries()); }
@Nonnull @Override public NodeConfig load(@Nonnull InputStream input) throws IOException { Properties p = new Properties(); p.load(input); NodeConfig config = new NodeConfig(); config.setMinElectionTimeout(getIntProperty(p, "election.timeout.min", 3000)); config.setMaxElectionTimeout(getIntProperty(p, "election.timeout.max", 4000)); config.setLogReplicationDelay(getIntProperty(p, "replication.delay", 0)); config.setLogReplicationInterval(getIntProperty(p, "replication.interval", 1000)); config.setLogReplicationReadTimeout(getIntProperty(p, "replication.timeout.read", 900)); config.setMaxReplicationEntries(getIntProperty(p, "replication.entries.max", Log.ALL_ENTRIES)); config.setSnapshotDataLength(getIntProperty(p, "snapshot.data.length", 1024)); config.setMaxReplicationEntriesForNewNode(getIntProperty(p, "new-node.replication.entries.max", Log.ALL_ENTRIES)); config.setNewNodeMaxRound(getIntProperty(p, "new-node.round.max", 10)); config.setNewNodeReadTimeout(getIntProperty(p, "new-node.timeout.read", 3000)); config.setNewNodeAdvanceTimeout(getIntProperty(p, "new-node.timeout.advance", 3000)); config.setPreviousGroupConfigChangeTimeout(getIntProperty(p, "group.config.change.timeout", 0)); config.setNioWorkerThreads(getIntProperty(p, "connector.workers", 0)); return config; }
DefaultNodeConfigLoader implements NodeConfigLoader { @Nonnull @Override public NodeConfig load(@Nonnull InputStream input) throws IOException { Properties p = new Properties(); p.load(input); NodeConfig config = new NodeConfig(); config.setMinElectionTimeout(getIntProperty(p, "election.timeout.min", 3000)); config.setMaxElectionTimeout(getIntProperty(p, "election.timeout.max", 4000)); config.setLogReplicationDelay(getIntProperty(p, "replication.delay", 0)); config.setLogReplicationInterval(getIntProperty(p, "replication.interval", 1000)); config.setLogReplicationReadTimeout(getIntProperty(p, "replication.timeout.read", 900)); config.setMaxReplicationEntries(getIntProperty(p, "replication.entries.max", Log.ALL_ENTRIES)); config.setSnapshotDataLength(getIntProperty(p, "snapshot.data.length", 1024)); config.setMaxReplicationEntriesForNewNode(getIntProperty(p, "new-node.replication.entries.max", Log.ALL_ENTRIES)); config.setNewNodeMaxRound(getIntProperty(p, "new-node.round.max", 10)); config.setNewNodeReadTimeout(getIntProperty(p, "new-node.timeout.read", 3000)); config.setNewNodeAdvanceTimeout(getIntProperty(p, "new-node.timeout.advance", 3000)); config.setPreviousGroupConfigChangeTimeout(getIntProperty(p, "group.config.change.timeout", 0)); config.setNioWorkerThreads(getIntProperty(p, "connector.workers", 0)); return config; } }
DefaultNodeConfigLoader implements NodeConfigLoader { @Nonnull @Override public NodeConfig load(@Nonnull InputStream input) throws IOException { Properties p = new Properties(); p.load(input); NodeConfig config = new NodeConfig(); config.setMinElectionTimeout(getIntProperty(p, "election.timeout.min", 3000)); config.setMaxElectionTimeout(getIntProperty(p, "election.timeout.max", 4000)); config.setLogReplicationDelay(getIntProperty(p, "replication.delay", 0)); config.setLogReplicationInterval(getIntProperty(p, "replication.interval", 1000)); config.setLogReplicationReadTimeout(getIntProperty(p, "replication.timeout.read", 900)); config.setMaxReplicationEntries(getIntProperty(p, "replication.entries.max", Log.ALL_ENTRIES)); config.setSnapshotDataLength(getIntProperty(p, "snapshot.data.length", 1024)); config.setMaxReplicationEntriesForNewNode(getIntProperty(p, "new-node.replication.entries.max", Log.ALL_ENTRIES)); config.setNewNodeMaxRound(getIntProperty(p, "new-node.round.max", 10)); config.setNewNodeReadTimeout(getIntProperty(p, "new-node.timeout.read", 3000)); config.setNewNodeAdvanceTimeout(getIntProperty(p, "new-node.timeout.advance", 3000)); config.setPreviousGroupConfigChangeTimeout(getIntProperty(p, "group.config.change.timeout", 0)); config.setNioWorkerThreads(getIntProperty(p, "connector.workers", 0)); return config; } DefaultNodeConfigLoader();  DefaultNodeConfigLoader(String propertyNamePrefix); }
DefaultNodeConfigLoader implements NodeConfigLoader { @Nonnull @Override public NodeConfig load(@Nonnull InputStream input) throws IOException { Properties p = new Properties(); p.load(input); NodeConfig config = new NodeConfig(); config.setMinElectionTimeout(getIntProperty(p, "election.timeout.min", 3000)); config.setMaxElectionTimeout(getIntProperty(p, "election.timeout.max", 4000)); config.setLogReplicationDelay(getIntProperty(p, "replication.delay", 0)); config.setLogReplicationInterval(getIntProperty(p, "replication.interval", 1000)); config.setLogReplicationReadTimeout(getIntProperty(p, "replication.timeout.read", 900)); config.setMaxReplicationEntries(getIntProperty(p, "replication.entries.max", Log.ALL_ENTRIES)); config.setSnapshotDataLength(getIntProperty(p, "snapshot.data.length", 1024)); config.setMaxReplicationEntriesForNewNode(getIntProperty(p, "new-node.replication.entries.max", Log.ALL_ENTRIES)); config.setNewNodeMaxRound(getIntProperty(p, "new-node.round.max", 10)); config.setNewNodeReadTimeout(getIntProperty(p, "new-node.timeout.read", 3000)); config.setNewNodeAdvanceTimeout(getIntProperty(p, "new-node.timeout.advance", 3000)); config.setPreviousGroupConfigChangeTimeout(getIntProperty(p, "group.config.change.timeout", 0)); config.setNioWorkerThreads(getIntProperty(p, "connector.workers", 0)); return config; } DefaultNodeConfigLoader();  DefaultNodeConfigLoader(String propertyNamePrefix); @Nonnull @Override NodeConfig load(@Nonnull InputStream input); }
DefaultNodeConfigLoader implements NodeConfigLoader { @Nonnull @Override public NodeConfig load(@Nonnull InputStream input) throws IOException { Properties p = new Properties(); p.load(input); NodeConfig config = new NodeConfig(); config.setMinElectionTimeout(getIntProperty(p, "election.timeout.min", 3000)); config.setMaxElectionTimeout(getIntProperty(p, "election.timeout.max", 4000)); config.setLogReplicationDelay(getIntProperty(p, "replication.delay", 0)); config.setLogReplicationInterval(getIntProperty(p, "replication.interval", 1000)); config.setLogReplicationReadTimeout(getIntProperty(p, "replication.timeout.read", 900)); config.setMaxReplicationEntries(getIntProperty(p, "replication.entries.max", Log.ALL_ENTRIES)); config.setSnapshotDataLength(getIntProperty(p, "snapshot.data.length", 1024)); config.setMaxReplicationEntriesForNewNode(getIntProperty(p, "new-node.replication.entries.max", Log.ALL_ENTRIES)); config.setNewNodeMaxRound(getIntProperty(p, "new-node.round.max", 10)); config.setNewNodeReadTimeout(getIntProperty(p, "new-node.timeout.read", 3000)); config.setNewNodeAdvanceTimeout(getIntProperty(p, "new-node.timeout.advance", 3000)); config.setPreviousGroupConfigChangeTimeout(getIntProperty(p, "group.config.change.timeout", 0)); config.setNioWorkerThreads(getIntProperty(p, "connector.workers", 0)); return config; } DefaultNodeConfigLoader();  DefaultNodeConfigLoader(String propertyNamePrefix); @Nonnull @Override NodeConfig load(@Nonnull InputStream input);  }