Search in sources :

Example 1 with StatsProvider

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

the class LocalBookkeeperEnsemble method stop.

public void stop() throws Exception {
    LOG.debug("Local ZK/BK stopping ...");
    for (BookieServer bookie : bs) {
        bookie.shutdown();
    }
    for (StatsProvider statsProvider : statsProviders) {
        statsProvider.stop();
    }
    zkc.close();
    zks.shutdown();
    serverFactory.shutdown();
    LOG.debug("Local ZK/BK stopped");
}
Also used : StatsProvider(org.apache.bookkeeper.stats.StatsProvider) BookieServer(org.apache.bookkeeper.proto.BookieServer)

Example 2 with StatsProvider

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

the class StreamBenchmark method parseCommandLine.

protected void parseCommandLine(String[] args) throws Exception {
    BasicParser parser = new BasicParser();
    CommandLine cmdline = parser.parse(options, args);
    if (cmdline.hasOption("h")) {
        printUsage();
        System.exit(0);
    }
    if (cmdline.hasOption("u")) {
        this.uri = URI.create(cmdline.getOptionValue("u"));
    } else {
        printUsage();
        System.exit(0);
    }
    this.conf = new DistributedLogConfiguration();
    if (cmdline.hasOption("c")) {
        String configFile = cmdline.getOptionValue("c");
        this.conf.loadConf(new File(configFile).toURI().toURL());
    }
    if (cmdline.hasOption("p")) {
        statsProvider = ReflectionUtils.newInstance(cmdline.getOptionValue("p"), StatsProvider.class);
    } else {
        statsProvider = new NullStatsProvider();
    }
    if (cmdline.hasOption("s")) {
        this.streamName = cmdline.getOptionValue("s");
    } else {
        printUsage();
        System.exit(0);
    }
    parseCommandLine(cmdline);
}
Also used : BasicParser(org.apache.commons.cli.BasicParser) DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) CommandLine(org.apache.commons.cli.CommandLine) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) StatsProvider(org.apache.bookkeeper.stats.StatsProvider) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) File(java.io.File)

Example 3 with StatsProvider

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

the class Benchmarker method run.

void run() throws Exception {
    logger.info("Running benchmark.");
    BasicParser parser = new BasicParser();
    CommandLine cmdline = parser.parse(options, args);
    if (cmdline.hasOption("h")) {
        printUsage();
        System.exit(0);
    }
    if (cmdline.hasOption("s")) {
        String serversetPathStr = cmdline.getOptionValue("s");
        serversetPaths = Arrays.asList(StringUtils.split(serversetPathStr, ','));
    }
    if (cmdline.hasOption("fn")) {
        String finagleNameStr = cmdline.getOptionValue("fn");
        finagleNames = Arrays.asList(StringUtils.split(finagleNameStr, ','));
    }
    if (cmdline.hasOption("i")) {
        shardId = Integer.parseInt(cmdline.getOptionValue("i"));
    }
    if (cmdline.hasOption("d")) {
        durationMins = Integer.parseInt(cmdline.getOptionValue("d"));
    }
    if (cmdline.hasOption("sp")) {
        streamPrefix = cmdline.getOptionValue("sp");
    }
    if (cmdline.hasOption("sc")) {
        numStreams = Integer.parseInt(cmdline.getOptionValue("sc"));
    }
    if (cmdline.hasOption("ms")) {
        msgSize = Integer.parseInt(cmdline.getOptionValue("ms"));
    }
    if (cmdline.hasOption("r")) {
        rate = Integer.parseInt(cmdline.getOptionValue("r"));
    }
    if (cmdline.hasOption("mr")) {
        maxRate = Integer.parseInt(cmdline.getOptionValue("mr"));
    }
    if (cmdline.hasOption("cr")) {
        changeRate = Integer.parseInt(cmdline.getOptionValue("cr"));
    }
    if (cmdline.hasOption("ci")) {
        changeRateSeconds = Integer.parseInt(cmdline.getOptionValue("ci"));
    }
    if (cmdline.hasOption("t")) {
        concurrency = Integer.parseInt(cmdline.getOptionValue("t"));
    }
    if (cmdline.hasOption("m")) {
        mode = cmdline.getOptionValue("m");
    }
    if (cmdline.hasOption("u")) {
        dlUri = URI.create(cmdline.getOptionValue("u"));
    }
    if (cmdline.hasOption("bs")) {
        batchSize = Integer.parseInt(cmdline.getOptionValue("bs"));
        Preconditions.checkArgument("write" != mode, "batchSize supported only for mode=write");
    }
    if (cmdline.hasOption("c")) {
        String configFile = cmdline.getOptionValue("c");
        conf.loadConf(new File(configFile).toURI().toURL());
    }
    if (cmdline.hasOption("rps")) {
        readersPerStream = Integer.parseInt(cmdline.getOptionValue("rps"));
    }
    if (cmdline.hasOption("msid")) {
        maxStreamId = Integer.parseInt(cmdline.getOptionValue("msid"));
    }
    if (cmdline.hasOption("ti")) {
        truncationInterval = Integer.parseInt(cmdline.getOptionValue("ti"));
    }
    if (cmdline.hasOption("ssid")) {
        startStreamId = Integer.parseInt(cmdline.getOptionValue("ssid"));
    }
    if (cmdline.hasOption("esid")) {
        endStreamId = Integer.parseInt(cmdline.getOptionValue("esid"));
    }
    if (cmdline.hasOption("hccs")) {
        hostConnectionCoreSize = Integer.parseInt(cmdline.getOptionValue("hccs"));
    }
    if (cmdline.hasOption("hcl")) {
        hostConnectionLimit = Integer.parseInt(cmdline.getOptionValue("hcl"));
    }
    if (cmdline.hasOption("sb")) {
        sendBufferSize = Integer.parseInt(cmdline.getOptionValue("sb"));
    }
    if (cmdline.hasOption("rb")) {
        recvBufferSize = Integer.parseInt(cmdline.getOptionValue("rb"));
    }
    thriftmux = cmdline.hasOption("mx");
    handshakeWithClientInfo = cmdline.hasOption("hsci");
    readFromHead = cmdline.hasOption("rfh");
    enableBatching = cmdline.hasOption("bt");
    if (cmdline.hasOption("bbs")) {
        batchBufferSize = Integer.parseInt(cmdline.getOptionValue("bbs"));
    }
    if (cmdline.hasOption("bfi")) {
        batchFlushIntervalMicros = Integer.parseInt(cmdline.getOptionValue("bfi"));
    }
    Preconditions.checkArgument(shardId >= 0, "shardId must be >= 0");
    Preconditions.checkArgument(numStreams > 0, "numStreams must be > 0");
    Preconditions.checkArgument(durationMins > 0, "durationMins must be > 0");
    Preconditions.checkArgument(streamPrefix != null, "streamPrefix must be defined");
    Preconditions.checkArgument(hostConnectionCoreSize > 0, "host connection core size must be > 0");
    Preconditions.checkArgument(hostConnectionLimit > 0, "host connection limit must be > 0");
    if (cmdline.hasOption("p")) {
        statsProvider = ReflectionUtils.newInstance(cmdline.getOptionValue("p"), StatsProvider.class);
    } else {
        statsProvider = new NullStatsProvider();
    }
    logger.info("Starting stats provider : {}.", statsProvider.getClass());
    statsProvider.start(conf);
    Worker w = null;
    if (mode.startsWith("read")) {
        w = runReader();
    } else if (mode.startsWith("write")) {
        w = runWriter();
    } else if (mode.startsWith("dlwrite")) {
        w = runDLWriter();
    } else if (mode.startsWith("dlread")) {
        w = runDLReader();
    }
    if (w == null) {
        throw new IOException("Unknown mode " + mode + " to run the benchmark.");
    }
    Thread workerThread = new Thread(w, mode + "-benchmark-thread");
    workerThread.start();
    TimeUnit.MINUTES.sleep(durationMins);
    logger.info("{} minutes passed, exiting...", durationMins);
    w.close();
    if (null != statsProvider) {
        statsProvider.stop();
    }
    Runtime.getRuntime().exit(0);
}
Also used : BasicParser(org.apache.commons.cli.BasicParser) CommandLine(org.apache.commons.cli.CommandLine) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) StatsProvider(org.apache.bookkeeper.stats.StatsProvider) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) IOException(java.io.IOException) File(java.io.File)

Example 4 with StatsProvider

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

the class MonitorServiceApp method runCmd.

void runCmd(CommandLine cmdline) throws IOException {
    StatsProvider statsProvider = new NullStatsProvider();
    if (cmdline.hasOption("p")) {
        String providerClass = cmdline.getOptionValue("p");
        statsProvider = ReflectionUtils.newInstance(providerClass, StatsProvider.class);
    }
    StatsReceiver statsReceiver = NullStatsReceiver.get();
    final MonitorService monitorService = new MonitorService(getOptionalStringArg(cmdline, "u"), getOptionalStringArg(cmdline, "c"), getOptionalStringArg(cmdline, "s"), getOptionalIntegerArg(cmdline, "i"), getOptionalIntegerArg(cmdline, "d"), getOptionalStringArg(cmdline, "f"), getOptionalIntegerArg(cmdline, "n"), getOptionalIntegerArg(cmdline, "t"), getOptionalIntegerArg(cmdline, "hck"), getOptionalBooleanArg(cmdline, "hsci"), getOptionalBooleanArg(cmdline, "w"), statsReceiver, statsProvider);
    monitorService.runServer();
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            logger.info("Closing monitor service.");
            monitorService.close();
            logger.info("Closed monitor service.");
        }
    });
    try {
        monitorService.join();
    } catch (InterruptedException ie) {
        logger.warn("Interrupted when waiting monitor service to be finished : ", ie);
    }
}
Also used : StatsReceiver(com.twitter.finagle.stats.StatsReceiver) NullStatsReceiver(com.twitter.finagle.stats.NullStatsReceiver) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) StatsProvider(org.apache.bookkeeper.stats.StatsProvider) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider)

Example 5 with StatsProvider

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

the class DistributedLogServerApp method runCmd.

private void runCmd(CommandLine cmdline) throws IllegalArgumentException, IOException, ConfigurationException {
    final StatsReceiver statsReceiver = NullStatsReceiver.get();
    Optional<String> confOptional = getOptionalStringArg(cmdline, "c");
    DistributedLogConfiguration dlConf = new DistributedLogConfiguration();
    if (confOptional.isPresent()) {
        String configFile = confOptional.get();
        try {
            dlConf.loadConf(new File(configFile).toURI().toURL());
        } catch (ConfigurationException e) {
            throw new IllegalArgumentException("Failed to load distributedlog configuration from " + configFile + ".");
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Failed to load distributedlog configuration from malformed " + configFile + ".");
        }
    }
    // load the stats provider
    final StatsProvider statsProvider = getOptionalStringArg(cmdline, "pd").transform(new Function<String, StatsProvider>() {

        @Nullable
        @Override
        public StatsProvider apply(@Nullable String name) {
            return ReflectionUtils.newInstance(name, StatsProvider.class);
        }
    }).or(new NullStatsProvider());
    final DistributedLogServer server = DistributedLogServer.runServer(getOptionalStringArg(cmdline, "u"), confOptional, getOptionalStringArg(cmdline, "sc"), getOptionalIntegerArg(cmdline, "p"), getOptionalIntegerArg(cmdline, "sp"), getOptionalIntegerArg(cmdline, "si"), getOptionalBooleanArg(cmdline, "a"), getOptionalBooleanArg(cmdline, "mx"), statsReceiver, statsProvider);
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            logger.info("Closing DistributedLog Server.");
            server.close();
            logger.info("Closed DistributedLog Server.");
            statsProvider.stop();
        }
    });
    try {
        server.join();
    } catch (InterruptedException e) {
        logger.warn("Interrupted when waiting distributedlog server to be finished : ", e);
    }
    logger.info("DistributedLog Service Interrupted.");
    server.close();
    logger.info("Closed DistributedLog Server.");
    statsProvider.stop();
}
Also used : MalformedURLException(java.net.MalformedURLException) StatsReceiver(com.twitter.finagle.stats.StatsReceiver) NullStatsReceiver(com.twitter.finagle.stats.NullStatsReceiver) DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) Function(com.google.common.base.Function) ConfigurationException(org.apache.commons.configuration.ConfigurationException) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) StatsProvider(org.apache.bookkeeper.stats.StatsProvider) NullStatsProvider(org.apache.bookkeeper.stats.NullStatsProvider) File(java.io.File) Nullable(javax.annotation.Nullable)

Aggregations

StatsProvider (org.apache.bookkeeper.stats.StatsProvider)5 NullStatsProvider (org.apache.bookkeeper.stats.NullStatsProvider)4 File (java.io.File)3 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)2 NullStatsReceiver (com.twitter.finagle.stats.NullStatsReceiver)2 StatsReceiver (com.twitter.finagle.stats.StatsReceiver)2 BasicParser (org.apache.commons.cli.BasicParser)2 CommandLine (org.apache.commons.cli.CommandLine)2 Function (com.google.common.base.Function)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Nullable (javax.annotation.Nullable)1 BookieServer (org.apache.bookkeeper.proto.BookieServer)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1