Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
967ed8f7
S
SkyWalking
项目概览
gdyjdao
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
967ed8f7
编写于
3月 19, 2020
作者:
K
kezhenxu94
提交者:
GitHub
3月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make `CommandService` daemon to avoid blocking target application shutting down gracefully (#4541)
上级
28ac73bf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
16 deletion
+17
-16
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/CommandService.java
...he/skywalking/apm/agent/core/commands/CommandService.java
+17
-16
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/CommandService.java
浏览文件 @
967ed8f7
...
...
@@ -17,8 +17,13 @@
package
org.apache.skywalking.apm.agent.core.commands
;
import
java.util.ArrayList
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
org.apache.skywalking.apm.agent.core.boot.BootService
;
import
org.apache.skywalking.apm.agent.core.boot.DefaultImplementor
;
import
org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory
;
import
org.apache.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.apache.skywalking.apm.agent.core.logging.api.ILog
;
import
org.apache.skywalking.apm.agent.core.logging.api.LogManager
;
...
...
@@ -29,19 +34,16 @@ import org.apache.skywalking.apm.network.trace.component.command.CommandDeserial
import
org.apache.skywalking.apm.network.trace.component.command.UnsupportedCommandException
;
import
org.apache.skywalking.apm.util.RunnableWithExceptionProtection
;
import
java.util.ArrayList
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
@DefaultImplementor
public
class
CommandService
implements
BootService
,
Runnable
{
private
static
final
ILog
LOGGER
=
LogManager
.
getLogger
(
CommandService
.
class
);
private
volatile
boolean
isRunning
=
true
;
private
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
private
LinkedBlockingQueue
<
BaseCommand
>
commands
=
new
LinkedBlockingQueue
<
BaseCommand
>(
64
);
private
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
(
new
DefaultNamedThreadFactory
(
"CommandService"
)
);
private
LinkedBlockingQueue
<
BaseCommand
>
commands
=
new
LinkedBlockingQueue
<>(
64
);
private
CommandSerialNumberCache
serialNumberCache
=
new
CommandSerialNumberCache
();
@Override
...
...
@@ -50,12 +52,9 @@ public class CommandService implements BootService, Runnable {
@Override
public
void
boot
()
throws
Throwable
{
executorService
.
submit
(
new
RunnableWithExceptionProtection
(
this
,
new
RunnableWithExceptionProtection
.
CallbackWhenException
()
{
@Override
public
void
handle
(
final
Throwable
t
)
{
LOGGER
.
error
(
t
,
"CommandService failed to execute commands"
);
}
}));
executorService
.
submit
(
new
RunnableWithExceptionProtection
(
this
,
t
->
LOGGER
.
error
(
t
,
"CommandService failed to execute commands"
))
);
}
@Override
...
...
@@ -94,7 +93,7 @@ public class CommandService implements BootService, Runnable {
@Override
public
void
shutdown
()
throws
Throwable
{
isRunning
=
false
;
commands
.
drainTo
(
new
ArrayList
<
BaseCommand
>());
commands
.
drainTo
(
new
ArrayList
<>());
executorService
.
shutdown
();
}
...
...
@@ -111,8 +110,10 @@ public class CommandService implements BootService, Runnable {
boolean
success
=
this
.
commands
.
offer
(
baseCommand
);
if
(!
success
&&
LOGGER
.
isWarnEnable
())
{
LOGGER
.
warn
(
"Command[{}, {}] cannot add to command list. because the command list is full."
,
baseCommand
.
getCommand
(),
baseCommand
.
getSerialNumber
());
LOGGER
.
warn
(
"Command[{}, {}] cannot add to command list. because the command list is full."
,
baseCommand
.
getCommand
(),
baseCommand
.
getSerialNumber
()
);
}
}
catch
(
UnsupportedCommandException
e
)
{
if
(
LOGGER
.
isWarnEnable
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录