Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
c272abb0
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / 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,发现更多精彩内容 >>
提交
c272abb0
编写于
11月 08, 2015
作者:
Z
zhangxin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加追加EOF标志位的线程
上级
414f6f90
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
14 deletion
+50
-14
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/buffer/AppendEOFFlagThread.java
...cloud/skywalking/reciever/buffer/AppendEOFFlagThread.java
+35
-0
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/buffer/DataBufferThreadContainer.java
...skywalking/reciever/buffer/DataBufferThreadContainer.java
+12
-14
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/conf/Config.java
...in/java/com/ai/cloud/skywalking/reciever/conf/Config.java
+3
-0
未找到文件。
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/buffer/AppendEOFFlagThread.java
0 → 100644
浏览文件 @
c272abb0
package
com.ai.cloud.skywalking.reciever.buffer
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
class
AppendEOFFlagThread
extends
Thread
{
private
Logger
logger
=
LogManager
.
getLogger
(
AppendEOFFlagThread
.
class
);
private
File
[]
dataBufferFiles
;
public
AppendEOFFlagThread
(
File
[]
dataBufferFiles
)
{
this
.
dataBufferFiles
=
dataBufferFiles
;
}
@Override
public
void
run
()
{
BufferedWriter
bufferedWriter
;
for
(
File
file
:
dataBufferFiles
)
{
try
{
logger
.
info
(
"Add EOF flags to unprocessed data file[{}]"
,
file
.
getName
());
bufferedWriter
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
file
.
getParent
(),
file
.
getName
()),
true
));
bufferedWriter
.
write
(
"EOF\n"
);
bufferedWriter
.
flush
();
bufferedWriter
.
close
();
}
catch
(
IOException
e
)
{
logger
.
info
(
"Add EOF flags to the unprocessed data file failed."
,
e
);
}
}
}
}
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/buffer/DataBufferThreadContainer.java
浏览文件 @
c272abb0
...
...
@@ -5,17 +5,17 @@ import org.apache.commons.io.comparator.NameFileComparator;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.concurrent.ThreadLocalRandom
;
import
static
com
.
ai
.
cloud
.
skywalking
.
reciever
.
conf
.
Config
.
Buffer
.
MAX_THREAD_NUMBER
;
import
static
com
.
ai
.
cloud
.
skywalking
.
reciever
.
conf
.
Config
.
Persistence
.
MAX_APPEND_EOF_FLAGS_THREAD_NUMBER
;
public
class
DataBufferThreadContainer
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
DataBufferThreadContainer
.
class
);
private
static
List
<
DataBufferThread
>
buffers
=
new
ArrayList
<
DataBufferThread
>();
...
...
@@ -34,19 +34,17 @@ public class DataBufferThreadContainer {
File
parentDir
=
new
File
(
Config
.
Buffer
.
DATA_BUFFER_FILE_PARENT_DIRECTORY
);
NameFileComparator
sizeComparator
=
new
NameFileComparator
();
File
[]
dataFileList
=
sizeComparator
.
sort
(
parentDir
.
listFiles
());
BufferedWriter
bufferedWriter
;
for
(
File
file
:
dataFileList
)
{
try
{
logger
.
info
(
"Add EOF flags to unprocessed data file[{}]"
,
file
.
getName
());
bufferedWriter
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
file
.
getParent
(),
file
.
getName
()),
true
));
bufferedWriter
.
write
(
"EOF\n"
);
bufferedWriter
.
flush
();
bufferedWriter
.
close
();
}
catch
(
IOException
e
)
{
logger
.
info
(
"Add EOF flags to the unprocessed data file failed."
,
e
);
int
step
=
(
int
)
Math
.
ceil
(
dataFileList
.
length
*
1.0
/
MAX_APPEND_EOF_FLAGS_THREAD_NUMBER
);
int
start
=
0
,
end
=
0
;
while
(
true
)
{
if
(
end
+
step
>=
dataFileList
.
length
)
{
new
AppendEOFFlagThread
(
Arrays
.
copyOf
(
dataFileList
,
start
)).
start
();
break
;
}
end
+=
step
;
new
AppendEOFFlagThread
(
Arrays
.
copyOfRange
(
dataFileList
,
start
,
end
)).
start
();
start
=
end
;
}
logger
.
info
(
"Data buffer thread size {} begin to init "
,
MAX_THREAD_NUMBER
);
for
(
int
i
=
0
;
i
<
MAX_THREAD_NUMBER
;
i
++)
{
DataBufferThread
dataBufferThread
=
new
DataBufferThread
();
...
...
skywalking-server/src/main/java/com/ai/cloud/skywalking/reciever/conf/Config.java
浏览文件 @
c272abb0
...
...
@@ -48,6 +48,9 @@ public class Config {
// 处理文件完成之后,等待时间
public
static
long
SWITCH_FILE_WAIT_TIME
=
5000L
;
// 追加EOF标志位的线程数量
public
static
final
int
MAX_APPEND_EOF_FLAGS_THREAD_NUMBER
=
11
;
}
public
static
class
RegisterPersistence
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录