Search in sources :

Example 1 with StatsLogger

use of org.apache.bookkeeper.stats.StatsLogger in project pulsar by yahoo.

the class LocalBookkeeperEnsemble method runBookies.

private void runBookies(ServerConfiguration baseConf) throws Exception {
    LOG.info("Starting Bookie(s)");
    // Create Bookie Servers (B1, B2, B3)
    bs = new BookieServer[numberOfBookies];
    bsConfs = new ServerConfiguration[numberOfBookies];
    statsProviders = new StatsProvider[numberOfBookies];
    for (int i = 0; i < numberOfBookies; i++) {
        File bkDataDir = isNotBlank(bkDataDirName) ? Files.createDirectories(Paths.get(bkDataDirName + Integer.toString(i))).toFile() : Files.createTempDirectory("bk" + Integer.toString(i) + "test").toFile();
        if (this.clearOldData) {
            cleanDirectory(bkDataDir);
        }
        bsConfs[i] = new ServerConfiguration(baseConf);
        // override settings
        bsConfs[i].setBookiePort(initialPort + i);
        bsConfs[i].setZkServers("127.0.0.1:" + ZooKeeperDefaultPort);
        bsConfs[i].setJournalDirName(bkDataDir.getPath());
        bsConfs[i].setLedgerDirNames(new String[] { bkDataDir.getPath() });
        bsConfs[i].setAllowLoopback(true);
        bsConfs[i].setGcWaitTime(60000);
        String statsFilePath = FileSystems.getDefault().getPath(bkDataDir.getAbsolutePath(), "bookie-stats.json").toString();
        // Initialize Stats Provider
        statsProviders[i] = new DataSketchesMetricsProvider();
        bsConfs[i].setProperty("dataSketchesMetricsJsonFileReporter", statsFilePath);
        statsProviders[i].start(bsConfs[i]);
        StatsLogger statsLogger = statsProviders[i].getStatsLogger("");
        bs[i] = new BookieServer(bsConfs[i], statsLogger);
        bs[i].start();
        LOG.debug("Local BK[{}] started (port: {}, data_directory: {})", i, initialPort + i, bkDataDir.getAbsolutePath());
    }
}
Also used : DataSketchesMetricsProvider(org.apache.bokkeeper.stats.datasketches.DataSketchesMetricsProvider) NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) File(java.io.File)

Example 2 with StatsLogger

use of org.apache.bookkeeper.stats.StatsLogger 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 3 with StatsLogger

use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.

the class StreamBenchmark method run.

protected void run(String[] args) throws Exception {
    logger.info("Parsing arguments for benchmark : {}", args);
    // parse command line
    parseCommandLine(args);
    statsProvider.start(conf);
    // run the benchmark
    StatsLogger statsLogger = statsProvider.getStatsLogger("dl");
    DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(conf).uri(uri).statsLogger(statsLogger).build();
    try {
        benchmark(namespace, streamName, statsProvider.getStatsLogger("benchmark"));
    } finally {
        namespace.close();
        statsProvider.stop();
    }
}
Also used : StatsLogger(org.apache.bookkeeper.stats.StatsLogger) DistributedLogNamespace(com.twitter.distributedlog.namespace.DistributedLogNamespace)

Example 4 with StatsLogger

use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.

the class TestStatsFilter method testServiceSuccess.

@Test(timeout = 60000)
public void testServiceSuccess() throws Exception {
    StatsLogger stats = new NullStatsLogger();
    StatsFilter<String, String> filter = new StatsFilter<String, String>(stats);
    Future<String> result = filter.apply("", new ConstantService<String, String>(Future.value("result")));
    assertEquals("result", Await.result(result));
}
Also used : NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) Test(org.junit.Test)

Example 5 with StatsLogger

use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.

the class TestStatsFilter method testServiceFailure.

@Test(timeout = 60000)
public void testServiceFailure() throws Exception {
    StatsLogger stats = new NullStatsLogger();
    StatsFilter<String, String> filter = new StatsFilter<String, String>(stats);
    try {
        filter.apply("", new RuntimeExService<String, String>());
    } catch (RuntimeException ex) {
    }
}
Also used : NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) Test(org.junit.Test)

Aggregations

StatsLogger (org.apache.bookkeeper.stats.StatsLogger)6 NullStatsLogger (org.apache.bookkeeper.stats.NullStatsLogger)4 Test (org.junit.Test)2 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)1 DynamicConfigurationFactory (com.twitter.distributedlog.config.DynamicConfigurationFactory)1 DistributedLogNamespace (com.twitter.distributedlog.namespace.DistributedLogNamespace)1 DistributedLogService (com.twitter.distributedlog.thrift.service.DistributedLogService)1 Server (com.twitter.finagle.builder.Server)1 ServerBuilder (com.twitter.finagle.builder.ServerBuilder)1 NullStatsReceiver (com.twitter.finagle.stats.NullStatsReceiver)1 StatsReceiver (com.twitter.finagle.stats.StatsReceiver)1 ClientIdRequiredFilter (com.twitter.finagle.thrift.ClientIdRequiredFilter)1 Transport (com.twitter.finagle.transport.Transport)1 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetSocketAddress (java.net.InetSocketAddress)1 DataSketchesMetricsProvider (org.apache.bokkeeper.stats.datasketches.DataSketchesMetricsProvider)1 ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)1 BookieServer (org.apache.bookkeeper.proto.BookieServer)1