Search in sources :

Example 6 with PropertiesWriter

use of org.apache.distributedlog.common.config.PropertiesWriter in project bookkeeper by apache.

the class TestDynamicConfigurationFactory method testMissingConfig.

/**
 * If the file is missing, get-config should not fail, and the file should be picked up if its added.
 * If the file is removed externally same should apply.
 */
@Test(timeout = 60000)
public void testMissingConfig() throws Exception {
    PropertiesWriter writer = new PropertiesWriter();
    DynamicConfigurationFactory factory = getConfigFactory(writer.getFile());
    Optional<DynamicDistributedLogConfiguration> conf = factory.getDynamicConfiguration(writer.getFile().getPath());
    writer.setProperty(DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS, "1");
    writer.save();
    waitForConfig(conf.get(), 1);
    File configFile = writer.getFile();
    configFile.delete();
    Thread.sleep(1000);
    PropertiesWriter writer2 = new PropertiesWriter(writer.getFile());
    writer2.setProperty(DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS, "2");
    writer2.save();
    waitForConfig(conf.get(), 2);
}
Also used : PropertiesWriter(org.apache.distributedlog.common.config.PropertiesWriter) File(java.io.File) Test(org.junit.Test)

Aggregations

PropertiesWriter (org.apache.distributedlog.common.config.PropertiesWriter)6 Test (org.junit.Test)6 Feature (org.apache.bookkeeper.feature.Feature)3 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)3 File (java.io.File)1 Ignore (org.junit.Ignore)1