use of org.apache.bookkeeper.stats.NullStatsProvider 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);
}
use of org.apache.bookkeeper.stats.NullStatsProvider 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);
}
use of org.apache.bookkeeper.stats.NullStatsProvider 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);
}
}
use of org.apache.bookkeeper.stats.NullStatsProvider 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();
}
Aggregations