Skip to content

Commit aab4723

Browse files
committed
[pinpoint-apm#9932] Removed thrift dependency of Agent module`
1 parent fef0848 commit aab4723

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/concurrent/executor/AsyncQueueingExecutor.java

+10-18
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
public class AsyncQueueingExecutor<T> {
3434

3535
private final Logger logger;
36-
private final boolean isWarn;
3736

3837
private final LinkedBlockingQueue<T> queue;
3938
private final AtomicBoolean isRun = new AtomicBoolean(true);
@@ -51,7 +50,6 @@ public AsyncQueueingExecutor(int queueSize, String executorName, AsyncQueueingEx
5150
Objects.requireNonNull(executorName, "executorName");
5251

5352
this.logger = LogManager.getLogger(this.getClass().getName() + "@" + executorName);
54-
this.isWarn = logger.isWarnEnabled();
5553

5654
// BEFORE executeThread start
5755
this.maxDrainSize = 10;
@@ -66,27 +64,27 @@ public AsyncQueueingExecutor(int queueSize, String executorName, AsyncQueueingEx
6664

6765
private Thread createExecuteThread(String executorName) {
6866
final ThreadFactory threadFactory = new PinpointThreadFactory(executorName, true);
69-
Thread thread = threadFactory.newThread(this::doAccept);
67+
Thread thread = threadFactory.newThread(this::doExecute);
7068
thread.start();
7169
return thread;
7270
}
7371

74-
private void doAccept() {
72+
private void doExecute() {
7573
long timeout = 2000;
7674
drainStartEntry:
7775
while (isRun()) {
7876
try {
7977
final Collection<T> dtoList = getDrainQueue();
8078
final int drainSize = takeN(dtoList, this.maxDrainSize);
8179
if (drainSize > 0) {
82-
doAccept(dtoList);
80+
doExecute(dtoList);
8381
continue;
8482
}
8583

8684
while (isRun()) {
8785
final T dto = takeOne(timeout);
8886
if (dto != null) {
89-
doAccept(dto);
87+
doExecute(dto);
9088
continue drainStartEntry;
9189
} else {
9290
pollTimeout(timeout);
@@ -113,7 +111,7 @@ private void flushQueue() {
113111
if (debugEnabled) {
114112
logger.debug("flushData size {}", drainSize);
115113
}
116-
doAccept(elementList);
114+
doExecute(elementList);
117115
}
118116
}
119117

@@ -136,32 +134,26 @@ protected void pollTimeout(long timeout) {
136134

137135
public boolean execute(T data) {
138136
if (data == null) {
139-
if (isWarn) {
140-
logger.warn("execute(). data is null");
141-
}
137+
logger.warn("execute(). data is null");
142138
return false;
143139
}
144140
if (!isRun.get()) {
145-
if (isWarn) {
146-
logger.warn("{} is shutdown. discard data:{}", executorName, data);
147-
}
141+
logger.warn("{} is shutdown. discard data:{}", executorName, data);
148142
return false;
149143
}
150144
boolean offer = queue.offer(data);
151145
if (!offer) {
152-
if (isWarn) {
153-
logger.warn("{} Drop data. queue is full. size:{}", executorName, queue.size());
154-
}
146+
logger.warn("{} Drop data. queue is full. size:{}", executorName, queue.size());
155147
}
156148
return offer;
157149
}
158150

159151

160-
private void doAccept(Collection<T> elements) {
152+
private void doExecute(Collection<T> elements) {
161153
this.listener.execute(elements);
162154
}
163155

164-
private void doAccept(T element) {
156+
private void doExecute(T element) {
165157
this.listener.execute(element);
166158
}
167159

0 commit comments

Comments
 (0)