MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / defaultChannelFactory

Method defaultChannelFactory

src/HBaseClient.java:682–710  ·  view source on GitHub ↗

Creates a default channel factory in case we haven't been given one. The factory will use Netty defaults and provide thread naming rules for easier debugging. @param config The config to pull settings from

(
      final Config config)

Source from the content-addressed store, hash-verified

680 * @param config The config to pull settings from
681 */
682 private static NioClientSocketChannelFactory defaultChannelFactory(
683 final Config config) {
684 class BossThreadNamer implements ThreadNameDeterminer {
685 @Override
686 public String determineThreadName(String currentThreadName,
687 String proposedThreadName) throws Exception {
688 return "AsyncHBase I/O Boss #" + BOSS_THREAD_ID.incrementAndGet();
689 }
690 }
691
692 class WorkerThreadNamer implements ThreadNameDeterminer {
693 @Override
694 public String determineThreadName(String currentThreadName,
695 String proposedThreadName) throws Exception {
696 return "AsyncHBase I/O Worker #" + WORKER_THREAD_ID.incrementAndGet();
697 }
698 }
699
700 final Executor executor = Executors.newCachedThreadPool();
701 final NioClientBossPool boss_pool =
702 new NioClientBossPool(executor, 1, newTimer(config, "Boss Pool"),
703 new BossThreadNamer());
704 final int num_workers = config.hasProperty("hbase.workers.size") ?
705 config.getInt("hbase.workers.size") :
706 Runtime.getRuntime().availableProcessors() * 2;
707 final NioWorkerPool worker_pool = new NioWorkerPool(executor,
708 num_workers, new WorkerThreadNamer());
709 return new NioClientSocketChannelFactory(boss_pool, worker_pool);
710 }
711
712 /** A custom channel factory that doesn't shutdown its executor. */
713 private static final class CustomChannelFactory

Callers 1

HBaseClientMethod · 0.95

Calls 3

newTimerMethod · 0.95
hasPropertyMethod · 0.45
getIntMethod · 0.45

Tested by

no test coverage detected