Search in sources :

Example 16 with DistributedLogConfiguration

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);
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Example 17 with DistributedLogConfiguration

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());
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) Test(org.junit.Test)

Example 18 with DistributedLogConfiguration

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);
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) DistributedLogNamespace(com.twitter.distributedlog.namespace.DistributedLogNamespace) DistributedLogManager(com.twitter.distributedlog.DistributedLogManager) BKDLConfig(com.twitter.distributedlog.metadata.BKDLConfig) URI(java.net.URI) Test(org.junit.Test)

Example 19 with DistributedLogConfiguration

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);
        }
    }
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 20 with DistributedLogConfiguration

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);
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) HashMap(java.util.HashMap) DLServer(com.twitter.distributedlog.service.DistributedLogCluster.DLServer) SocketAddress(java.net.SocketAddress) Before(org.junit.Before)

Aggregations

DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)50 Test (org.junit.Test)32 URI (java.net.URI)12 IOException (java.io.IOException)7 DynamicDistributedLogConfiguration (com.twitter.distributedlog.config.DynamicDistributedLogConfiguration)6 WriteResponse (com.twitter.distributedlog.thrift.service.WriteResponse)6 Before (org.junit.Before)6 ZooKeeperClient (com.twitter.distributedlog.ZooKeeperClient)5 ServerConfiguration (com.twitter.distributedlog.service.config.ServerConfiguration)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 StreamManagerImpl (com.twitter.distributedlog.service.stream.StreamManagerImpl)4 Future (com.twitter.util.Future)4 ArrayList (java.util.ArrayList)4 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 DistributedLogManager (com.twitter.distributedlog.DistributedLogManager)3 ConcurrentConstConfiguration (com.twitter.distributedlog.config.ConcurrentConstConfiguration)3 PropertiesWriter (com.twitter.distributedlog.config.PropertiesWriter)3 DistributedLogNamespace (com.twitter.distributedlog.namespace.DistributedLogNamespace)3 StreamConfigProvider (com.twitter.distributedlog.service.config.StreamConfigProvider)3 Stream (com.twitter.distributedlog.service.stream.Stream)3