use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestDynamicConfigurationFactory method getConfigFactory.
private DynamicConfigurationFactory getConfigFactory(File configFile) {
String streamConfigPath = configFile.getParent();
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1);
ConcurrentBaseConfiguration defaultConf = new ConcurrentConstConfiguration(new DistributedLogConfiguration());
return new DynamicConfigurationFactory(executorService, 100, TimeUnit.MILLISECONDS);
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestDynamicDistributedLogConfiguration method testDefaults.
@Test(timeout = 20000)
public void testDefaults() throws Exception {
// Default config defines retention period plus two other params, but eaves ack quorum unspecified
DistributedLogConfiguration underlyingConfig = new DistributedLogConfiguration();
underlyingConfig.setRetentionPeriodHours(99);
underlyingConfig.setProperty("rpsHardWriteLimit", 99);
ConcurrentConstConfiguration defaultConfig = new ConcurrentConstConfiguration(underlyingConfig);
DynamicDistributedLogConfiguration config = new DynamicDistributedLogConfiguration(defaultConfig);
assertEquals(99, config.getRetentionPeriodHours());
assertEquals(99, config.getRpsHardWriteLimit());
config.setProperty(DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS, 5);
// Config checks primary then secondary then const defaults
assertEquals(5, config.getRetentionPeriodHours());
assertEquals(99, config.getRpsHardWriteLimit());
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestZKLogMetadataForWriter method testCreateLogMetadataWithCustomMetadata.
@Test(timeout = 60000)
public void testCreateLogMetadataWithCustomMetadata() throws Exception {
URI uri = DLMTestUtil.createDLMURI(zkPort, "");
String logName = testName.getMethodName();
String logIdentifier = "<default>";
List<String> pathsToDelete = Lists.newArrayList();
DLMetadata.create(new BKDLConfig(zkServers, "/ledgers")).update(uri);
DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(new DistributedLogConfiguration()).uri(uri).build();
DistributedLogManager dlm = namespace.openLog(logName);
dlm.createOrUpdateMetadata(logName.getBytes("UTF-8"));
dlm.close();
testCreateLogMetadataWithMissingPaths(uri, logName, logIdentifier, pathsToDelete, true, false);
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class AbstractFeatureProvider method getFeatureProvider.
public static FeatureProvider getFeatureProvider(String rootScope, DistributedLogConfiguration conf, StatsLogger statsLogger) throws IOException {
Class<? extends FeatureProvider> featureProviderClass;
try {
featureProviderClass = conf.getFeatureProviderClass();
} catch (ConfigurationException e) {
throw new IOException("Can't initialize the feature provider : ", e);
}
// create feature provider
Constructor<? extends FeatureProvider> constructor;
try {
constructor = featureProviderClass.getDeclaredConstructor(String.class, DistributedLogConfiguration.class, StatsLogger.class);
} catch (NoSuchMethodException e) {
throw new IOException("No constructor found for feature provider class " + featureProviderClass + " : ", e);
}
try {
return constructor.newInstance(rootScope, conf, statsLogger);
} catch (InstantiationException e) {
throw new IOException("Failed to instantiate feature provider : ", e);
} catch (IllegalAccessException e) {
throw new IOException("Encountered illegal access when instantiating feature provider : ", e);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if (targetException instanceof IOException) {
throw (IOException) targetException;
} else {
throw new IOException("Encountered invocation target exception while instantiating feature provider : ", e);
}
}
}
use of com.twitter.distributedlog.DistributedLogConfiguration in project distributedlog by twitter.
the class TestRegionUnavailable method setup.
@Before
@Override
public void setup() throws Exception {
DistributedLogConfiguration localConf = new DistributedLogConfiguration();
localConf.addConfiguration(conf);
localConf.setFeatureProviderClass(TestFeatureProvider.class);
DistributedLogConfiguration remoteConf = new DistributedLogConfiguration();
remoteConf.addConfiguration(conf);
super.setup();
int localPort = 9010;
int remotePort = 9020;
for (int i = 0; i < numServersPerDC; i++) {
localCluster.add(createDistributedLogServer(localConf, localPort + i));
remoteCluster.add(createDistributedLogServer(remoteConf, remotePort + i));
}
Map<SocketAddress, String> regionMap = new HashMap<SocketAddress, String>();
for (DLServer server : localCluster) {
regionMap.put(server.getAddress(), "local");
}
for (DLServer server : remoteCluster) {
regionMap.put(server.getAddress(), "remote");
}
client = createTwoRegionDLClient("two_regions_client", regionMap);
}
Aggregations