KafkaBrokerConfigurationDiff extends AbstractResourceDiff { boolean isDesiredPropertyDefaultValue(String key, Config config) { Optional<ConfigEntry> entry = config.entries().stream().filter(configEntry -> configEntry.name().equals(key)).findFirst(); if (entry.isPresent()) { return entry.get().isDefault(); } return false; } KafkaBrokerConfigurationDiff(Config brokerConfigs, String desired, KafkaVersion kafkaVersion, int brokerId); boolean canBeUpdatedDynamically(); Collection<AlterConfigOp> getConfigDiff(); int getDiffSize(); @Override boolean isEmpty(); static final Pattern IGNORABLE_PROPERTIES; }
@Test public void testDefaultValue() { KafkaBrokerConfigurationDiff kcd = new KafkaBrokerConfigurationDiff(getCurrentConfiguration(emptyList()), getDesiredConfiguration(emptyList()), kafkaVersion, brokerId); assertThat(kcd.isDesiredPropertyDefaultValue("offset.metadata.max.bytes", getCurrentConfiguration(emptyList())), is(true)); }
@Test public void testNonDefaultValue() { List<ConfigEntry> ces = singletonList(new ConfigEntry("offset.metadata.max.bytes", "4097")); KafkaBrokerConfigurationDiff kcd = new KafkaBrokerConfigurationDiff(getCurrentConfiguration(ces), getDesiredConfiguration(emptyList()), kafkaVersion, brokerId); assertThat(kcd.isDesiredPropertyDefaultValue("offset.metadata.max.bytes", getCurrentConfiguration(ces)), is(false)); }