use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestFederatedZKLogMetadataStore method setup.
@Before
public void setup() throws Exception {
zkc = TestZooKeeperClientBuilder.newBuilder().uri(createDLMURI("/")).sessionTimeoutMs(zkSessionTimeoutMs).build();
scheduler = OrderedScheduler.newBuilder().name("test-zk-logmetadata-store").corePoolSize(2).build();
DistributedLogConfiguration conf = new DistributedLogConfiguration();
conf.addConfiguration(baseConf);
this.uri = createDLMURI("/" + runtime.getMethodName());
FederatedZKLogMetadataStore.createFederatedNamespace(uri, zkc);
metadataStore = new FederatedZKLogMetadataStore(conf, uri, zkc, scheduler);
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestDynamicConfigurationFeatureProvider method testLoadFeaturesFromOverlay.
/**
* {@link https://issues.apache.org/jira/browse/DL-40}
*/
@DistributedLogAnnotations.FlakyTest
@Ignore
@Test(timeout = 60000)
public void testLoadFeaturesFromOverlay() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
writer.setProperty("feature_2", "5000");
writer.save();
PropertiesWriter overlayWriter = new PropertiesWriter();
overlayWriter.setProperty("feature_2", "6000");
overlayWriter.setProperty("feature_4", "6000");
overlayWriter.save();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setDynamicConfigReloadIntervalSec(Integer.MAX_VALUE).setFileFeatureProviderBaseConfigPath(writer.getFile().toURI().toURL().getPath()).setFileFeatureProviderOverlayConfigPath(overlayWriter.getFile().toURI().toURL().getPath());
DynamicConfigurationFeatureProvider provider = new DynamicConfigurationFeatureProvider("", conf, NullStatsLogger.INSTANCE);
provider.start();
ensureConfigReloaded();
Feature feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(10000, feature1.availability());
Feature feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(6000, feature2.availability());
Feature feature3 = provider.getFeature("feature_3");
assertFalse(feature3.isAvailable());
assertEquals(0, feature3.availability());
Feature feature4 = provider.getFeature("feature_4");
assertTrue(feature4.isAvailable());
assertEquals(6000, feature4.availability());
Feature feature5 = provider.getFeature("unknown_feature");
assertFalse(feature5.isAvailable());
assertEquals(0, feature5.availability());
provider.stop();
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestDynamicConfigurationFeatureProvider method testLoadFeaturesFromBase.
@Test(timeout = 60000)
public void testLoadFeaturesFromBase() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("feature_1", "10000");
writer.setProperty("feature_2", "5000");
writer.save();
DistributedLogConfiguration conf = new DistributedLogConfiguration().setDynamicConfigReloadIntervalSec(Integer.MAX_VALUE).setFileFeatureProviderBaseConfigPath(writer.getFile().toURI().toURL().getPath());
DynamicConfigurationFeatureProvider provider = new DynamicConfigurationFeatureProvider("", conf, NullStatsLogger.INSTANCE);
provider.start();
ensureConfigReloaded();
Feature feature1 = provider.getFeature("feature_1");
assertTrue(feature1.isAvailable());
assertEquals(10000, feature1.availability());
Feature feature2 = provider.getFeature("feature_2");
assertTrue(feature2.isAvailable());
assertEquals(5000, feature2.availability());
Feature feature3 = provider.getFeature("feature_3");
assertFalse(feature3.isAvailable());
assertEquals(0, feature3.availability());
Feature feature4 = provider.getFeature("unknown_feature");
assertFalse(feature4.isAvailable());
assertEquals(0, feature4.availability());
provider.stop();
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestZKLogMetadataStore method setup.
@Before
public void setup() throws Exception {
zkc = TestZooKeeperClientBuilder.newBuilder().uri(createDLMURI("/")).sessionTimeoutMs(zkSessionTimeoutMs).build();
scheduler = OrderedScheduler.newBuilder().name("test-zk-logmetadata-store").corePoolSize(1).build();
DistributedLogConfiguration conf = new DistributedLogConfiguration();
conf.addConfiguration(baseConf);
this.uri = createDLMURI("/" + runtime.getMethodName());
metadataStore = new ZKLogMetadataStore(conf, uri, zkc, scheduler);
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestConfigurationSubscription method testInitialConfigLoad.
@Test(timeout = 60000)
public void testInitialConfigLoad() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("prop1", "1");
writer.setProperty("prop2", "abc");
writer.setProperty("prop3", "123.0");
writer.setProperty("prop4", "11132");
writer.setProperty("prop5", "true");
writer.save();
ScheduledExecutorService mockScheduler = new DeterministicScheduler();
FileConfigurationBuilder builder = new PropertiesConfigurationBuilder(writer.getFile().toURI().toURL());
ConcurrentConstConfiguration conf = new ConcurrentConstConfiguration(new DistributedLogConfiguration());
List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(builder);
ConfigurationSubscription confSub = new ConfigurationSubscription(conf, fileConfigBuilders, mockScheduler, 100, TimeUnit.MILLISECONDS);
assertEquals(1, conf.getInt("prop1"));
assertEquals("abc", conf.getString("prop2"));
assertEquals(123.0, conf.getFloat("prop3"), 0);
assertEquals(11132, conf.getInt("prop4"));
assertEquals(true, conf.getBoolean("prop5"));
}
Aggregations