Package private timer constructor that provides a useful name for the timer thread. @param config The config object used to pull out the tick interval @param name A name to stash in the timer @return A timer
(final Config config, final String name)
| 658 | * @return A timer |
| 659 | */ |
| 660 | static HashedWheelTimer newTimer(final Config config, final String name) { |
| 661 | class TimerThreadNamer implements ThreadNameDeterminer { |
| 662 | @Override |
| 663 | public String determineThreadName(String currentThreadName, |
| 664 | String proposedThreadName) throws Exception { |
| 665 | return "AsyncHBase Timer " + name + " #" + TIMER_THREAD_ID.incrementAndGet(); |
| 666 | } |
| 667 | } |
| 668 | if (config == null) { |
| 669 | return new HashedWheelTimer(Executors.defaultThreadFactory(), |
| 670 | new TimerThreadNamer(), 100, MILLISECONDS, 512); |
| 671 | } |
| 672 | return new HashedWheelTimer(Executors.defaultThreadFactory(), |
| 673 | new TimerThreadNamer(), config.getShort("hbase.timer.tick"), |
| 674 | MILLISECONDS, config.getInt("hbase.timer.ticks_per_wheel")); |
| 675 | } |
| 676 | |
| 677 | /** Creates a default channel factory in case we haven't been given one. |
| 678 | * The factory will use Netty defaults and provide thread naming rules for |
no test coverage detected