use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestZKLogSegmentMetadataStore method setup.
@Before
public void setup() throws Exception {
zkc = TestZooKeeperClientBuilder.newBuilder().uri(createDLMURI("/")).sessionTimeoutMs(zkSessionTimeoutMs).build();
scheduler = OrderedScheduler.newBuilder().name("test-zk-logsegment-metadata-store").corePoolSize(1).build();
DistributedLogConfiguration conf = new DistributedLogConfiguration();
conf.addConfiguration(baseConf);
this.uri = createDLMURI("/" + runtime.getMethodName());
lsmStore = new ZKLogSegmentMetadataStore(conf, zkc, scheduler);
zkc.get().create("/" + runtime.getMethodName(), new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
this.rootZkPath = "/" + runtime.getMethodName();
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestZKAccessControlManager method setup.
@Before
public void setup() throws Exception {
executorService = Executors.newSingleThreadScheduledExecutor();
zkc = TestZooKeeperClientBuilder.newBuilder().uri(createURI("/")).build();
conf = new DistributedLogConfiguration();
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestLedgerAllocatorPool method testNonAvailableAllocator.
@Test(timeout = 60000)
public void testNonAvailableAllocator() throws Exception {
String allocationPath = "/nonAvailableAllocator";
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.addConfiguration(dlConf);
confLocal.setEnsembleSize(2 * numBookies);
confLocal.setWriteQuorumSize(2 * numBookies);
int numAllocators = 3;
LedgerAllocatorPool pool = new LedgerAllocatorPool(allocationPath, numAllocators, confLocal, zkc, bkc, allocationExecutor);
for (int i = 0; i < numAllocators; i++) {
try {
pool.allocate();
FutureUtils.result(pool.tryObtain(newTxn(), NULL_LISTENER));
fail("Should fail to allocate ledger if there are enought bookies");
} catch (SimpleLedgerAllocator.AllocationException ae) {
assertEquals(SimpleLedgerAllocator.Phase.ERROR, ae.getPhase());
}
}
for (int i = 0; i < numAllocators; i++) {
try {
pool.allocate();
FutureUtils.result(pool.tryObtain(newTxn(), NULL_LISTENER));
fail("Should fail to allocate ledger if there aren't available allocators");
} catch (SimpleLedgerAllocator.AllocationException ae) {
assertEquals(SimpleLedgerAllocator.Phase.ERROR, ae.getPhase());
} catch (IOException ioe) {
// expected
}
}
Utils.close(pool);
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestConfigurationSubscription method testAddReloadBasicsConfig.
@Test(timeout = 60000)
public void testAddReloadBasicsConfig() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
DeterministicScheduler 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(null, conf.getProperty("prop1"));
// add
writer.setProperty("prop1", "1");
writer.save();
// ensure the file change reloading event can be triggered
ensureConfigReloaded();
mockScheduler.tick(100, TimeUnit.MILLISECONDS);
assertEquals("1", conf.getProperty("prop1"));
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestConfigurationSubscription method testExceptionInConfigLoad.
@Test(timeout = 60000)
public void testExceptionInConfigLoad() throws Exception {
PropertiesWriter writer = new PropertiesWriter();
writer.setProperty("prop1", "1");
writer.save();
DeterministicScheduler 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);
final AtomicInteger count = new AtomicInteger(1);
conf.addConfigurationListener(new ConfigurationListener() {
@Override
public void configurationChanged(ConfigurationEvent event) {
LOG.info("config changed {}", event);
// Throw after so we actually see the update anyway.
if (!event.isBeforeUpdate()) {
count.getAndIncrement();
throw new RuntimeException("config listener threw and exception");
}
}
});
int i = 0;
int initial = 0;
while (count.get() == initial) {
writer.setProperty("prop1", Integer.toString(i++));
writer.save();
mockScheduler.tick(100, TimeUnit.MILLISECONDS);
}
initial = count.get();
while (count.get() == initial) {
writer.setProperty("prop1", Integer.toString(i++));
writer.save();
mockScheduler.tick(100, TimeUnit.MILLISECONDS);
}
}
Aggregations