org.jboss.netty.util.ThreadNameDeterminer Java Examples

The following examples show how to use org.jboss.netty.util.ThreadNameDeterminer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RpcChannelFactory.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
public static synchronized ServerSocketChannelFactory createServerChannelFactory(String name, int workerNum) {
  name = name + "-" + serverCount.incrementAndGet();
  if(LOG.isInfoEnabled()){
    LOG.info("Create " + name + " ServerSocketChannelFactory. Worker:" + workerNum);
  }
  ThreadFactoryBuilder builder = new ThreadFactoryBuilder();
  ThreadFactory bossFactory = builder.setNameFormat(name + " Server Boss #%d").build();
  ThreadFactory workerFactory = builder.setNameFormat(name + " Server Worker #%d").build();

  NioServerBossPool bossPool =
      new NioServerBossPool(Executors.newCachedThreadPool(bossFactory), 1, ThreadNameDeterminer.CURRENT);
  NioWorkerPool workerPool =
      new NioWorkerPool(Executors.newCachedThreadPool(workerFactory), workerNum, ThreadNameDeterminer.CURRENT);

  return new NioServerSocketChannelFactory(bossPool, workerPool);
}
 
Example #2
Source File: RpcChannelFactory.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
public static synchronized ClientSocketChannelFactory createClientChannelFactory(String name, int workerNum) {
  name = name + "-" + clientCount.incrementAndGet();
  if(LOG.isDebugEnabled()){
    LOG.debug("Create " + name + " ClientSocketChannelFactory. Worker:" + workerNum);
  }

  ThreadFactoryBuilder builder = new ThreadFactoryBuilder();
  ThreadFactory bossFactory = builder.setNameFormat(name + " Boss #%d").build();
  ThreadFactory workerFactory = builder.setNameFormat(name + " Worker #%d").build();

  NioClientBossPool bossPool = new NioClientBossPool(Executors.newCachedThreadPool(bossFactory), 1,
      new HashedWheelTimer(), ThreadNameDeterminer.CURRENT);
  NioWorkerPool workerPool = new NioWorkerPool(Executors.newCachedThreadPool(workerFactory), workerNum,
      ThreadNameDeterminer.CURRENT);

  return new NioClientSocketChannelFactory(bossPool, workerPool);
}
 
Example #3
Source File: AbstractNioSelector.java    From simple-netty-source with Apache License 2.0 5 votes vote down vote up
/**
 * Start the {@link AbstractNioWorker} and return the {@link Selector} that will be used for
 * the {@link AbstractNioChannel}'s when they get registered
 */
private void openSelector(ThreadNameDeterminer determiner) {
    try {
        selector = SelectorUtil.open();
    } catch (Throwable t) {
        throw new ChannelException("Failed to create a selector.", t);
    }

    // Start the worker thread with the new Selector.
    boolean success = false;
    try {
        DeadLockProofWorker.start(executor, newThreadRenamingRunnable(id, determiner));
        success = true;
    } finally {
        if (!success) {
            // Release the Selector if the execution fails.
            try {
                selector.close();
            } catch (Throwable t) {
                logger.warn("Failed to close a selector.", t);
            }
            selector = null;
            // The method will return to the caller at this point.
        }
    }
    assert selector != null && selector.isOpen();
}
 
Example #4
Source File: AbstractNioSelector.java    From android-netty with Apache License 2.0 5 votes vote down vote up
/**
 * Start the {@link AbstractNioWorker} and return the {@link Selector} that
 * will be used for the {@link AbstractNioChannel}'s when they get
 * registered
 */
private void openSelector(ThreadNameDeterminer determiner) {
	try {
		selector = Selector.open();
	} catch (Throwable t) {
		throw new ChannelException("Failed to create a selector.", t);
	}

	// Start the worker thread with the new Selector.
	boolean success = false;
	try {
		DeadLockProofWorker.start(executor, newThreadRenamingRunnable(id, determiner));
		success = true;
	} finally {
		if (!success) {
			// Release the Selector if the execution fails.
			try {
				selector.close();
			} catch (Throwable e) {
				e.printStackTrace();
			}
			selector = null;
			// The method will return to the caller at this point.
		}
	}
	assert selector != null && selector.isOpen();
}
 
Example #5
Source File: PinpointServerAcceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private ServerBootstrap createBootStrap(int bossCount, int workerCount) {
    // profiler, collector
    ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Boss", true));
    NioServerBossPool nioServerBossPool = new NioServerBossPool(boss, bossCount, ThreadNameDeterminer.CURRENT);

    ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Worker", true));
    NioWorkerPool nioWorkerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);

    NioServerSocketChannelFactory nioClientSocketChannelFactory = new NioServerSocketChannelFactory(nioServerBossPool, nioWorkerPool);
    return new ServerBootstrap(nioClientSocketChannelFactory);
}
 
Example #6
Source File: ClientChannelFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public ChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
    ExecutorService boss = newCachedThreadPool("Pinpoint-Client-Boss");
    BossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);

    ExecutorService worker = newCachedThreadPool("Pinpoint-Client-Worker");
    WorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
    return new NioClientSocketChannelFactory(bossPool, workerPool);
}
 
Example #7
Source File: AbstractNioWorker.java    From android-netty with Apache License 2.0 4 votes vote down vote up
@Override
protected ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner) {
    return new ThreadRenamingRunnable(this, "New I/O worker #" + id, determiner);
}
 
Example #8
Source File: AbstractNioWorker.java    From android-netty with Apache License 2.0 4 votes vote down vote up
AbstractNioWorker(Executor executor, ThreadNameDeterminer determiner) {
    super(executor, determiner);
}
 
Example #9
Source File: NioClientBoss.java    From android-netty with Apache License 2.0 4 votes vote down vote up
@Override
protected ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner) {
    return new ThreadRenamingRunnable(this, "New I/O boss #" + id, determiner);
}
 
Example #10
Source File: NioClientBoss.java    From android-netty with Apache License 2.0 4 votes vote down vote up
NioClientBoss(Executor bossExecutor, Timer timer, ThreadNameDeterminer determiner) {
    super(bossExecutor, determiner);
    this.timer = timer;
}
 
Example #11
Source File: AbstractNioSelector.java    From android-netty with Apache License 2.0 4 votes vote down vote up
AbstractNioSelector(Executor executor, ThreadNameDeterminer determiner) {
	this.executor = executor;
	openSelector(determiner);
}
 
Example #12
Source File: NioWorkerPool.java    From android-netty with Apache License 2.0 4 votes vote down vote up
public NioWorkerPool(Executor workerExecutor, int workerCount, ThreadNameDeterminer determiner) {
	super(workerExecutor, workerCount, false);
	this.determiner = determiner;
	init();
}
 
Example #13
Source File: NioWorker.java    From android-netty with Apache License 2.0 4 votes vote down vote up
public NioWorker(Executor executor, ThreadNameDeterminer determiner) {
	super(executor, determiner);
}
 
Example #14
Source File: TimerFactory.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
public static HashedWheelTimer createHashedWheelTimer(PinpointThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel) {
    return new HashedWheelTimer(threadFactory, ThreadNameDeterminer.CURRENT, tickDuration, unit, ticksPerWheel);
}
 
Example #15
Source File: AbstractNioWorker.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
@Override
protected ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner) {
    return new ThreadRenamingRunnable(this, "New I/O worker #" + id, determiner);
}
 
Example #16
Source File: AbstractNioWorker.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
AbstractNioWorker(Executor executor, ThreadNameDeterminer determiner) {
    super(executor, determiner);
}
 
Example #17
Source File: NioServerBoss.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
@Override
protected ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner) {
    return new ThreadRenamingRunnable(this,
            "New I/O server boss #" + id, determiner);
}
 
Example #18
Source File: NioServerBoss.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
NioServerBoss(Executor bossExecutor, ThreadNameDeterminer determiner) {
    super(bossExecutor, determiner);
}
 
Example #19
Source File: NioClientBoss.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
@Override
protected ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner) {
    return new ThreadRenamingRunnable(this, "New I/O boss #" + id, determiner);
}
 
Example #20
Source File: NioClientBoss.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
NioClientBoss(Executor bossExecutor, Timer timer, ThreadNameDeterminer determiner) {
    super(bossExecutor, determiner);
    this.timer = timer;
}
 
Example #21
Source File: AbstractNioSelector.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
public AbstractNioSelector(Executor executor, ThreadNameDeterminer determiner) {
    this.executor = executor;
    openSelector(determiner);
}
 
Example #22
Source File: NioWorkerPool.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
public NioWorkerPool(Executor workerExecutor, int workerCount, ThreadNameDeterminer determiner) {
    super(workerExecutor, workerCount, false);
    this.determiner = determiner;
    init();
}
 
Example #23
Source File: NioWorker.java    From simple-netty-source with Apache License 2.0 4 votes vote down vote up
public NioWorker(Executor executor, ThreadNameDeterminer determiner) {
    super(executor, determiner);
}
 
Example #24
Source File: NioClientBossPool.java    From simple-netty-source with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new instance
 *
 * @param bossExecutor  the Executor to use for server the {@link NioClientBoss}
 * @param bossCount     the number of {@link NioClientBoss} instances this {@link NioClientBossPool} will hold
 * @param timer         the Timer to use for handle connect timeouts
 * @param determiner    the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
 *                      if you not want to set one explicit.
 */
public NioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer determiner) {
    super(bossExecutor, bossCount, false);
    this.determiner = determiner;
    this.timer = timer;
    init();
}
 
Example #25
Source File: NioClientBossPool.java    From android-netty with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new instance
 *
 * @param bossExecutor  the Executor to use for server the {@link NioClientBoss}
 * @param bossCount     the number of {@link NioClientBoss} instances this {@link NioClientBossPool} will hold
 * @param timer         the Timer to use for handle connect timeouts
 * @param determiner    the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
 *                      if you not want to set one explicit.
 */
public NioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer determiner) {
    super(bossExecutor, bossCount, false);
    this.determiner = determiner;
    this.timer = timer;
    init();
}
 
Example #26
Source File: NioServerBossPool.java    From simple-netty-source with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new instance
 *
 * @param bossExecutor  the {@link Executor} to use for server the {@link NioServerBoss}
 * @param bossCount     the number of {@link NioServerBoss} instances this {@link NioServerBossPool} will hold
 * @param determiner    the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
 *                      if you not want to set one explicit.
 */
public NioServerBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer determiner) {
    super(bossExecutor, bossCount, false);
    this.determiner = determiner;
    init();
}
 
Example #27
Source File: AbstractNioSelector.java    From android-netty with Apache License 2.0 votes vote down vote up
protected abstract ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner); 
Example #28
Source File: AbstractNioSelector.java    From simple-netty-source with Apache License 2.0 votes vote down vote up
protected abstract ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner);