static Pair<EventLoopGroup, Class<? extends Channel>> getEventLoopConfig(Configuration conf) { String name = conf.get(EVENT_LOOP_CONFIG); if (StringUtils.isBlank(name)) { // create new event loop group if config is empty return Pair.<EventLoopGroup, Class<? extends Channel>> newPair( new NioEventLoopGroup(0, new DefaultThreadFactory("AsyncFSWAL", true, Thread.MAX_PRIORITY)), NioSocketChannel.class); } return EVENT_LOOP_CONFIG_MAP.get(name); }
public DefaultThreadFactory(Class<?> poolType, boolean daemon, int priority) { this(toPoolName(poolType), daemon, priority); }
@Override public Thread newThread(Runnable r) { Thread t = newThread(new DefaultRunnableDecorator(r), prefix + nextId.incrementAndGet()); try { if (t.isDaemon() != daemon) { t.setDaemon(daemon); } if (t.getPriority() != priority) { t.setPriority(priority); } } catch (Exception ignored) { // Doesn't matter even if failed to set. } return t; }
public NettyRpcClient(Configuration configuration, String clusterId, SocketAddress localAddress, MetricsConnection metrics) { super(configuration, clusterId, localAddress, metrics); Pair<EventLoopGroup, Class<? extends Channel>> groupAndChannelClass = NettyRpcClientConfigHelper .getEventLoopConfig(conf); if (groupAndChannelClass == null) { // Use our own EventLoopGroup. this.group = new NioEventLoopGroup(0, new DefaultThreadFactory("IPC-NioEventLoopGroup", true, Thread.MAX_PRIORITY)); this.channelClass = NioSocketChannel.class; this.shutdownGroupWhenClose = true; } else { this.group = groupAndChannelClass.getFirst(); this.channelClass = groupAndChannelClass.getSecond(); this.shutdownGroupWhenClose = false; } }
public NettyEventLoopGroupConfig(Configuration conf, String threadPoolName) { boolean useEpoll = useEpoll(conf); int workerCount = conf.getInt("hbase.netty.worker.count", 0); ThreadFactory eventLoopThreadFactory = new DefaultThreadFactory(threadPoolName, true, Thread.MAX_PRIORITY); if (useEpoll) { group = new EpollEventLoopGroup(workerCount, eventLoopThreadFactory); serverChannelClass = EpollServerSocketChannel.class; clientChannelClass = EpollSocketChannel.class; } else { group = new NioEventLoopGroup(workerCount, eventLoopThreadFactory); serverChannelClass = NioServerSocketChannel.class; clientChannelClass = NioSocketChannel.class; } }
} else { eventLoopGroup = new NioEventLoopGroup(0, new DefaultThreadFactory("NettyRpcServer", true, Thread.MAX_PRIORITY)); channelClass = NioServerSocketChannel.class;
public NettyRpcClient(Configuration configuration, String clusterId, SocketAddress localAddress, MetricsConnection metrics) { super(configuration, clusterId, localAddress, metrics); Pair<EventLoopGroup, Class<? extends Channel>> groupAndChannelClass = NettyRpcClientConfigHelper .getEventLoopConfig(conf); if (groupAndChannelClass == null) { // Use our own EventLoopGroup. this.group = new NioEventLoopGroup(0, new DefaultThreadFactory("IPC-NioEventLoopGroup", true, Thread.MAX_PRIORITY)); this.channelClass = NioSocketChannel.class; this.shutdownGroupWhenClose = true; } else { this.group = groupAndChannelClass.getFirst(); this.channelClass = groupAndChannelClass.getSecond(); this.shutdownGroupWhenClose = false; } }
/** * Calls {@link UnorderedThreadPoolEventExecutor#UnorderedThreadPoolEventExecutor(int, * ThreadFactory, java.util.concurrent.RejectedExecutionHandler)} using {@link DefaultThreadFactory}. */ public UnorderedThreadPoolEventExecutor(int corePoolSize, RejectedExecutionHandler handler) { this(corePoolSize, new DefaultThreadFactory(UnorderedThreadPoolEventExecutor.class), handler); }
/** * Calls {@link UnorderedThreadPoolEventExecutor#UnorderedThreadPoolEventExecutor(int, ThreadFactory)} * using {@link DefaultThreadFactory}. */ public UnorderedThreadPoolEventExecutor(int corePoolSize) { this(corePoolSize, new DefaultThreadFactory(UnorderedThreadPoolEventExecutor.class)); }
public DefaultEventLoop(EventLoopGroup parent) { this(parent, new DefaultThreadFactory(DefaultEventLoop.class)); }
public DefaultEventExecutor(EventExecutorGroup parent) { this(parent, new DefaultThreadFactory(DefaultEventExecutor.class)); }
@Override protected ThreadFactory newDefaultThreadFactory() { return new DefaultThreadFactory(getClass(), Thread.MAX_PRIORITY); }
protected ThreadFactory newDefaultThreadFactory() { return new DefaultThreadFactory(getClass()); }
public NettyRpcClient(Configuration configuration, String clusterId, SocketAddress localAddress, MetricsConnection metrics) { super(configuration, clusterId, localAddress, metrics); Pair<EventLoopGroup, Class<? extends Channel>> groupAndChannelClass = NettyRpcClientConfigHelper .getEventLoopConfig(conf); if (groupAndChannelClass == null) { // Use our own EventLoopGroup. this.group = new NioEventLoopGroup(0, new DefaultThreadFactory("IPC-NioEventLoopGroup", true, Thread.MAX_PRIORITY)); this.channelClass = NioSocketChannel.class; this.shutdownGroupWhenClose = true; } else { this.group = groupAndChannelClass.getFirst(); this.channelClass = groupAndChannelClass.getSecond(); this.shutdownGroupWhenClose = false; } }