Skip to content

Commit 82b2cce

Browse files
author
Peng Hu
committed
add lombok code
1 parent a29e0cb commit 82b2cce

File tree

2 files changed

+28
-76
lines changed

2 files changed

+28
-76
lines changed

src/main/java/info/xiaomo/gengine/network/netty/NettyTcpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private synchronized void connect() {
102102

103103
for (int i = channels.size(); i < nettyClientConfig.getMaxConnectCount(); i++) {
104104
ChannelFuture channelFuture = bootstrap.connect(nettyClientConfig.getIp(), nettyClientConfig.getPort());
105-
channelFuture.awaitUninterruptibly(10000); //最多等待10秒,如果服务器一直未开启情况下,房子阻塞当前线程
105+
channelFuture.awaitUninterruptibly(10000); //最多等待10秒,如果服务器一直未开启情况下,防止阻塞当前线程
106106
channels.add(channelFuture.channel());
107107
channelFuture.addListener(future -> {
108108
if (future.isSuccess()) {
Lines changed: 27 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package info.xiaomo.gengine.thread;
22

3+
import lombok.Data;
4+
import org.simpleframework.xml.Element;
5+
import org.simpleframework.xml.Root;
6+
37
import java.util.concurrent.LinkedBlockingQueue;
48
import java.util.concurrent.ThreadPoolExecutor;
59
import java.util.concurrent.TimeUnit;
6-
import org.simpleframework.xml.Element;
7-
import org.simpleframework.xml.Root;
810

911
/**
1012
* 线程池配置
@@ -13,86 +15,36 @@
1315
* 2017-03-30
1416
*/
1517
@Root
18+
@Data
1619
public class ThreadPoolExecutorConfig {
1720

18-
// 线程池名称
19-
@Element(required = false)
20-
private String name;
21-
22-
// 核心线程池值
23-
@Element(required = true)
24-
private int corePoolSize = 20;
25-
26-
// 线程池最大值
27-
@Element(required = true)
28-
private int maxPoolSize = 200;
29-
30-
// 线程池保持活跃时间(秒)
31-
@Element(required = true)
32-
private long keepAliveTime = 30L;
33-
34-
// 心跳间隔(大于0开启定时监测线程)
35-
@Element(required = false)
36-
private int heart;
37-
38-
// 缓存命令数
39-
@Element(required = false)
40-
private int commandSize = 100000;
41-
42-
public ThreadPoolExecutor newThreadPoolExecutor() throws RuntimeException {
43-
return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS,
44-
new LinkedBlockingQueue<>(commandSize), new IoThreadFactory());
45-
}
46-
47-
public String getName() {
48-
return name;
49-
}
50-
51-
public void setName(String name) {
52-
this.name = name;
53-
}
54-
55-
public int getCorePoolSize() {
56-
return corePoolSize;
57-
}
58-
59-
@Deprecated
60-
public void setCorePoolSize(int corePoolSize) {
61-
this.corePoolSize = corePoolSize;
62-
}
63-
64-
public int getMaxPoolSize() {
65-
return maxPoolSize;
66-
}
67-
68-
@Deprecated
69-
public void setMaxPoolSize(int maxPoolSize) {
70-
this.maxPoolSize = maxPoolSize;
71-
}
21+
// 线程池名称
22+
@Element(required = false)
23+
private String name;
7224

73-
public long getKeepAliveTime() {
74-
return keepAliveTime;
75-
}
25+
// 核心线程池值
26+
@Element()
27+
private int corePoolSize = 20;
7628

77-
@Deprecated
78-
public void setKeepAliveTime(long keepAliveTime) {
79-
this.keepAliveTime = keepAliveTime;
80-
}
29+
// 线程池最大值
30+
@Element()
31+
private int maxPoolSize = 200;
8132

82-
public int getHeart() {
83-
return heart;
84-
}
33+
// 线程池保持活跃时间(秒)
34+
@Element()
35+
private long keepAliveTime = 30L;
8536

86-
public void setHeart(int heart) {
87-
this.heart = heart;
88-
}
37+
// 心跳间隔(大于0开启定时监测线程)
38+
@Element(required = false)
39+
private int heart;
8940

90-
public int getCommandSize() {
91-
return commandSize < 10000 ? 10000 : commandSize;
92-
}
41+
// 缓存命令数
42+
@Element(required = false)
43+
private int commandSize = 100000;
9344

94-
public void setCommandSize(int commandSize) {
95-
this.commandSize = commandSize;
96-
}
45+
public ThreadPoolExecutor newThreadPoolExecutor() throws RuntimeException {
46+
return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS,
47+
new LinkedBlockingQueue<>(commandSize), new IoThreadFactory());
48+
}
9749

9850
}

0 commit comments

Comments
 (0)