Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
a0f31552
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a0f31552
编写于
1月 20, 2015
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
refactor localmessage manager
上级
81178f8e
ab3cba82
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
33 addition
and
34 deletion
+33
-34
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageProducer.java
...dianping/cat/message/internal/DefaultMessageProducer.java
+0
-1
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+2
-2
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/LocalMessageBucketManager.java
...dianping/cat/consumer/dump/LocalMessageBucketManager.java
+3
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/LogviewUploader.java
.../java/com/dianping/cat/consumer/dump/LogviewUploader.java
+22
-22
cat-consumer/src/main/resources/META-INF/plexus/components.xml
...onsumer/src/main/resources/META-INF/plexus/components.xml
+1
-1
cat-hadoop/src/main/java/com/dianping/cat/hadoop/build/ComponentsConfigurator.java
...com/dianping/cat/hadoop/build/ComponentsConfigurator.java
+2
-2
cat-hadoop/src/main/java/com/dianping/cat/hadoop/hdfs/HdfsUploader.java
.../main/java/com/dianping/cat/hadoop/hdfs/HdfsUploader.java
+1
-1
cat-hadoop/src/main/resources/META-INF/plexus/components.xml
cat-hadoop/src/main/resources/META-INF/plexus/components.xml
+2
-2
未找到文件。
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageProducer.java
浏览文件 @
a0f31552
...
...
@@ -36,7 +36,6 @@ public class DefaultMessageProducer implements MessageProducer {
@Override
public
void
logError
(
String
message
,
Throwable
cause
)
{
cause
.
printStackTrace
();
if
(
Cat
.
getManager
().
isCatEnabled
())
{
if
(
shouldLog
(
cause
))
{
StringWriter
writer
=
new
StringWriter
(
2048
);
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
a0f31552
...
...
@@ -48,7 +48,7 @@ import com.dianping.cat.core.config.ConfigDao;
import
com.dianping.cat.core.dal.HourlyReportContentDao
;
import
com.dianping.cat.core.dal.HourlyReportDao
;
import
com.dianping.cat.core.dal.ProjectDao
;
import
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
;
import
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
;
import
com.dianping.cat.message.spi.core.MessageConsumer
;
import
com.dianping.cat.message.spi.core.MessagePathBuilder
;
import
com.dianping.cat.service.DefaultReportManager
;
...
...
@@ -130,7 +130,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
MessageBucketManager
.
class
,
LocalMessageBucketManager
.
ID
,
LocalMessageBucketManager
.
class
)
//
.
req
(
ServerConfigManager
.
class
,
MessagePathBuilder
.
class
,
ServerStatisticManager
.
class
)
//
.
req
(
Logview
Uploader
.
class
));
.
req
(
Hdfs
Uploader
.
class
));
return
all
;
}
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/LocalMessageBucketManager.java
浏览文件 @
a0f31552
...
...
@@ -28,7 +28,7 @@ import com.dianping.cat.Cat;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
;
import
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.MessageProducer
;
...
...
@@ -61,7 +61,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
private
MessagePathBuilder
m_pathBuilder
;
@Inject
private
Logview
Uploader
m_logviewUploader
;
private
Hdfs
Uploader
m_logviewUploader
;
private
String
m_localIp
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
...
...
@@ -119,7 +119,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
m_baseDir
=
new
File
(
m_configManager
.
getHdfsLocalBaseDir
(
ServerConfigManager
.
DUMP_DIR
));
Threads
.
forGroup
(
"cat"
).
start
(
new
BlockDumper
(
m_buckets
,
m_messageBlocks
,
m_serverStateManager
));
Threads
.
forGroup
(
"cat"
).
start
(
new
OldMessageMov
er
(
this
,
m_buckets
,
m_logviewUploader
,
m_configManager
));
Threads
.
forGroup
(
"cat"
).
start
(
new
LogviewUpload
er
(
this
,
m_buckets
,
m_logviewUploader
,
m_configManager
));
if
(
m_configManager
.
isLocalMode
())
{
m_gzipThreads
=
1
;
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/
OldMessageMov
er.java
→
cat-consumer/src/main/java/com/dianping/cat/consumer/dump/
LogviewUpload
er.java
浏览文件 @
a0f31552
...
...
@@ -16,12 +16,12 @@ import org.unidal.helper.Threads.Task;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.configuration.ServerConfigManager
;
import
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
;
import
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.storage.message.LocalMessageBucket
;
public
class
OldMessageMov
er
implements
Task
{
public
class
LogviewUpload
er
implements
Task
{
private
LocalMessageBucketManager
m_bucketManager
;
...
...
@@ -29,14 +29,14 @@ public class OldMessageMover implements Task {
private
ConcurrentHashMap
<
String
,
LocalMessageBucket
>
m_buckets
;
private
Logview
Uploader
m_logviewUploader
;
private
Hdfs
Uploader
m_logviewUploader
;
private
ServerConfigManager
m_configManager
;
private
static
final
long
ONE_HOUR
=
60
*
60
*
1000L
;
public
OldMessageMov
er
(
LocalMessageBucketManager
bucketManager
,
ConcurrentHashMap
<
String
,
LocalMessageBucket
>
buckets
,
Logview
Uploader
logviewUploader
,
public
LogviewUpload
er
(
LocalMessageBucketManager
bucketManager
,
ConcurrentHashMap
<
String
,
LocalMessageBucket
>
buckets
,
Hdfs
Uploader
logviewUploader
,
ServerConfigManager
configManager
)
{
m_baseDir
=
new
File
(
configManager
.
getHdfsLocalBaseDir
(
ServerConfigManager
.
DUMP_DIR
));
m_bucketManager
=
bucketManager
;
...
...
@@ -56,7 +56,7 @@ public class OldMessageMover implements Task {
private
void
deleteOldMessages
()
{
final
List
<
String
>
paths
=
new
ArrayList
<
String
>();
final
Set
<
String
>
validPaths
=
query
ValidPath
(
m_configManager
.
getLogViewMaxStroageTime
());
final
Set
<
String
>
validPaths
=
find
ValidPath
(
m_configManager
.
getLogViewMaxStroageTime
());
Scanners
.
forDir
().
scan
(
m_baseDir
,
new
FileMatcher
()
{
@Override
...
...
@@ -80,16 +80,29 @@ public class OldMessageMover implements Task {
});
if
(
paths
.
size
()
>
0
)
{
processFiles
(
paths
,
false
);
process
Logview
Files
(
paths
,
false
);
}
}
private
Set
<
String
>
findValidPath
(
int
storageDays
)
{
Set
<
String
>
strs
=
new
HashSet
<
String
>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
long
currentTimeMillis
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
storageDays
;
i
++)
{
Date
date
=
new
Date
(
currentTimeMillis
-
i
*
24
*
60
*
60
*
1000L
);
strs
.
add
(
sdf
.
format
(
date
));
}
return
strs
;
}
@Override
public
String
getName
()
{
return
"LocalMessageBucketManager-OldMessageMover"
;
}
private
void
processFiles
(
final
List
<
String
>
paths
,
boolean
upload
)
{
private
void
process
Logview
Files
(
final
List
<
String
>
paths
,
boolean
upload
)
{
String
ip
=
NetworkInterfaceManager
.
INSTANCE
.
getLocalHostAddress
();
Transaction
t
=
Cat
.
newTransaction
(
"System"
,
"Delete"
+
"-"
+
ip
);
...
...
@@ -130,19 +143,6 @@ public class OldMessageMover implements Task {
t
.
complete
();
}
private
Set
<
String
>
queryValidPath
(
int
day
)
{
Set
<
String
>
strs
=
new
HashSet
<
String
>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
long
currentTimeMillis
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
day
;
i
++)
{
Date
date
=
new
Date
(
currentTimeMillis
-
i
*
24
*
60
*
60
*
1000L
);
strs
.
add
(
sdf
.
format
(
date
));
}
return
strs
;
}
@Override
public
void
run
()
{
boolean
active
=
true
;
...
...
@@ -223,7 +223,7 @@ public class OldMessageMover implements Task {
});
if
(
paths
.
size
()
>
0
)
{
processFiles
(
paths
,
true
);
process
Logview
Files
(
paths
,
true
);
}
}
...
...
cat-consumer/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
a0f31552
...
...
@@ -328,7 +328,7 @@
<role>
com.dianping.cat.statistic.ServerStatisticManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
</role>
<role>
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
</role>
</requirement>
</requirements>
</component>
...
...
cat-hadoop/src/main/java/com/dianping/cat/hadoop/build/ComponentsConfigurator.java
浏览文件 @
a0f31552
...
...
@@ -10,7 +10,7 @@ import com.dianping.cat.configuration.ServerConfigManager;
import
com.dianping.cat.hadoop.hdfs.FileSystemManager
;
import
com.dianping.cat.hadoop.hdfs.HdfsMessageBucket
;
import
com.dianping.cat.hadoop.hdfs.HdfsMessageBucketManager
;
import
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
;
import
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
;
import
com.dianping.cat.message.spi.MessageCodec
;
import
com.dianping.cat.message.spi.codec.PlainTextMessageCodec
;
import
com.dianping.cat.message.spi.core.MessagePathBuilder
;
...
...
@@ -29,7 +29,7 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
all
.
add
(
C
(
FileSystemManager
.
class
)
//
.
req
(
ServerConfigManager
.
class
));
all
.
add
(
C
(
Logview
Uploader
.
class
)
//
all
.
add
(
C
(
Hdfs
Uploader
.
class
)
//
.
req
(
FileSystemManager
.
class
));
all
.
add
(
C
(
MessageBucket
.
class
,
HdfsMessageBucket
.
ID
,
HdfsMessageBucket
.
class
)
//
...
...
cat-hadoop/src/main/java/com/dianping/cat/hadoop/hdfs/
Logview
Uploader.java
→
cat-hadoop/src/main/java/com/dianping/cat/hadoop/hdfs/
Hdfs
Uploader.java
浏览文件 @
a0f31552
...
...
@@ -22,7 +22,7 @@ import com.dianping.cat.configuration.ServerConfigManager;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
public
class
Logview
Uploader
implements
LogEnabled
{
public
class
Hdfs
Uploader
implements
LogEnabled
{
@Inject
private
FileSystemManager
m_fileSystemManager
;
...
...
cat-hadoop/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
a0f31552
...
...
@@ -10,8 +10,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
</role>
<implementation>
com.dianping.cat.hadoop.hdfs.
Logview
Uploader
</implementation>
<role>
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
</role>
<implementation>
com.dianping.cat.hadoop.hdfs.
Hdfs
Uploader
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.hadoop.hdfs.FileSystemManager
</role>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录