Skip to content

Commit

Permalink
fix threadpools shutdown problems (issues 14) (#31)
Browse files Browse the repository at this point in the history
单测待补充,先合并
  • Loading branch information
yangl authored and xmtsui committed May 28, 2018
1 parent d94046b commit 02da69f
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
</execution>
</executions>
<configuration>
<configFile>${user.dir}/.middleware-common/AlipayFormatter.xml</configFile>
<configFile>${project.basedir}/.middleware-common/AlipayFormatter.xml</configFile>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public class ConnectionEventExecutor {
Logger logger = BoltLoggerFactory.getLogger("CommonDefault");
ExecutorService executor = new ThreadPoolExecutor(1, 1, 60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(10000),
new NamedThreadFactory("Bolt-conn-event-executor"));
new NamedThreadFactory("Bolt-conn-event-executor", true));

/**
* Process event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ private void initializeExecutor() {
this.executorInitialized = true;
this.asyncCreateConnectionExecutor = new ThreadPoolExecutor(minPoolSize, maxPoolSize,
keepAliveTime, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize),
new NamedThreadFactory("Bolt-conn-warmup-executor"));
new NamedThreadFactory("Bolt-conn-warmup-executor", true));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void start() {
long period = SystemProperties.conn_monitor_period();

this.executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory(
"ConnectionMonitorThread"), new ThreadPoolExecutor.AbortPolicy());
"ConnectionMonitorThread", true), new ThreadPoolExecutor.AbortPolicy());
MonitorTask monitorTask = new MonitorTask();
this.executor.scheduleAtFixedRate(monitorTask, initialDelay, period, TimeUnit.MILLISECONDS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/alipay/remoting/ProcessorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ProcessorManager {
public ProcessorManager() {
defaultExecutor = new ThreadPoolExecutor(minPoolSize, maxPoolSize, keepAliveTime,
TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize), new NamedThreadFactory(
"Bolt-default-executor"));
"Bolt-default-executor", true));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/alipay/remoting/TimerHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class TimerHolder {

private static class DefaultInstance {
static final Timer INSTANCE = new HashedWheelTimer(new NamedThreadFactory(
"DefaultTimer" + defaultTickDuration), defaultTickDuration,
TimeUnit.MILLISECONDS);
"DefaultTimer" + defaultTickDuration, true),
defaultTickDuration, TimeUnit.MILLISECONDS);
}

private TimerHolder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public class RpcConnectionFactory implements ConnectionFactory {
.getRuntime()
.availableProcessors() + 1,
new NamedThreadFactory(
"Rpc-netty-client-worker"));
"Rpc-netty-client-worker",
true));

private Bootstrap bootstrap;

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/alipay/remoting/rpc/RpcServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ public class RpcServer extends RemotingServer {
private final EventLoopGroup bossGroup = new NioEventLoopGroup(
1,
new NamedThreadFactory(
"Rpc-netty-server-boss"));
"Rpc-netty-server-boss",
true));
/** worker event loop group. Reuse I/O worker threads between rpc servers. */
private final static NioEventLoopGroup workerGroup = new NioEventLoopGroup(
Runtime
.getRuntime()
.availableProcessors() * 2,
new NamedThreadFactory(
"Rpc-netty-server-worker"));
"Rpc-netty-server-worker",
true));

/** address parser to get custom args */
private RemotingAddressParser addressParser;
Expand Down

0 comments on commit 02da69f

Please sign in to comment.