Skip to content

Commit

Permalink
Allow tuning the number of worker threads or using OIO.
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
  • Loading branch information
octo47 authored and tsuna committed Jan 11, 2013
1 parent b027ca6 commit 7e362ad
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/tools/TSDMain.java
Expand Up @@ -16,6 +16,8 @@
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import org.jboss.netty.channel.socket.ServerSocketChannelFactory;
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -93,6 +95,10 @@ public static void main(String[] args) {
"Web root from which to serve static files (/s URLs).");
argp.addOption("--cachedir", "PATH",
"Directory under which to cache result of requests.");
argp.addOption("--worker-threads", "NUM",
"Number for async io workers (default: cpu * 2).");
argp.addOption("--async-io", "true|false",
"Use async NIO (default true) or traditional blocking io");
argp.addOption("--flush-interval", "MSEC",
"Maximum time for which a new data point can be buffered"
+ " (default: " + DEFAULT_FLUSH_INTERVAL + ").");
Expand All @@ -113,9 +119,23 @@ public static void main(String[] args) {
setDirectoryInSystemProps("tsd.http.cachedir", argp.get("--cachedir"),
CREATE_IF_NEEDED, MUST_BE_WRITEABLE);

final NioServerSocketChannelFactory factory =
new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
final ServerSocketChannelFactory factory;
if (argp.get("--async-io", "true").equalsIgnoreCase("true")) {
final int workers;
if (argp.has("--worker-threads")) {
workers = Integer.parseInt(argp.get("--worker-threads"));
} else {
workers = Runtime.getRuntime().availableProcessors() * 2;
}
factory = new
NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool(),
workers);
} else {
factory = new
OioServerSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
}
final HBaseClient client = CliOptions.clientFromOptions(argp);
try {
// Make sure we don't even start if we can't find out tables.
Expand Down

0 comments on commit 7e362ad

Please sign in to comment.