Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
edaee500
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,发现更多精彩内容 >>
提交
edaee500
编写于
3月 16, 2012
作者:
S
sean.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dev
上级
8d61e6c4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
216 addition
and
0 deletion
+216
-0
cat-job/src/main/java/com/dianping/cat/job/hdfs/LogViewIndexStore.java
...ain/java/com/dianping/cat/job/hdfs/LogViewIndexStore.java
+26
-0
cat-job/src/main/java/com/dianping/cat/job/hdfs/LogviewBucket.java
...rc/main/java/com/dianping/cat/job/hdfs/LogviewBucket.java
+125
-0
cat-job/src/main/java/com/dianping/cat/storage/mysql/LogView.java
...src/main/java/com/dianping/cat/storage/mysql/LogView.java
+65
-0
未找到文件。
cat-job/src/main/java/com/dianping/cat/job/hdfs/LogViewIndexStore.java
0 → 100644
浏览文件 @
edaee500
package
com.dianping.cat.job.hdfs
;
import
com.dianping.cat.storage.mysql.LogView
;
public
class
LogViewIndexStore
{
public
void
delete
()
{
// TODO Auto-generated method stub
}
public
void
close
()
{
// TODO Auto-generated method stub
}
public
LogView
getLogViewByMessageId
(
String
id
)
{
// TODO Auto-generated method stub
return
null
;
}
public
boolean
insert
(
LogView
logView
)
{
return
false
;
}
}
cat-job/src/main/java/com/dianping/cat/job/hdfs/LogviewBucket.java
0 → 100644
浏览文件 @
edaee500
package
com.dianping.cat.job.hdfs
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.dianping.cat.storage.Bucket
;
import
com.dianping.cat.storage.hdfs.HdfsDataStore
;
import
com.dianping.cat.storage.mysql.LogView
;
/**
* @author sean.wang
* @since Mar 9, 2012
*/
public
class
LogviewBucket
implements
Bucket
<
byte
[]>
{
private
LogViewIndexStore
indexStore
;
private
HdfsDataStore
dataStore
;
private
String
logicalPath
;
private
String
hdfsPath
;
@Override
public
void
close
()
throws
IOException
{
this
.
indexStore
.
close
();
}
@Override
public
void
deleteAndCreate
()
throws
IOException
{
this
.
initialize
(
null
,
null
,
this
.
logicalPath
);
}
@Override
public
List
<
byte
[]>
findAllByIds
(
List
<
String
>
ids
)
throws
IOException
{
List
<
byte
[]>
values
=
new
ArrayList
<
byte
[]>(
ids
.
size
());
for
(
String
id
:
ids
)
{
byte
[]
value
=
this
.
findById
(
id
);
values
.
add
(
value
);
}
return
values
;
}
@Override
public
List
<
String
>
findAllIdsByTag
(
String
tag
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
byte
[]
findById
(
String
id
)
throws
IOException
{
LogView
logview
=
this
.
indexStore
.
getLogViewByMessageId
(
id
);
if
(
logview
==
null
)
{
return
null
;
}
return
dataStore
.
get
(
logview
.
getOffset
(),
logview
.
getLength
());
}
@Override
public
void
flush
()
throws
IOException
{
}
@Override
public
byte
[]
findPreviousById
(
String
id
,
String
tagName
)
throws
IOException
{
LogView
logview
=
this
.
indexStore
.
getLogViewByMessageId
(
id
);
if
(
logview
==
null
)
{
return
null
;
}
return
dataStore
.
get
(
logview
.
getOffset
(),
logview
.
getLength
());
}
@Override
public
byte
[]
findNextById
(
String
id
,
String
tagName
)
throws
IOException
{
LogView
logview
=
this
.
indexStore
.
getLogViewByMessageId
(
id
);
if
(
logview
==
null
)
{
return
null
;
}
return
dataStore
.
get
(
logview
.
getOffset
(),
logview
.
getLength
());
}
/**
* @param baseDir
* e.g /data/appdata/cat/
* @param logicalPath
* e.g /a/b/c
*/
@Override
public
void
initialize
(
Class
<?>
type
,
File
baseDir
,
String
logicalPath
)
throws
IOException
{
this
.
logicalPath
=
logicalPath
;
File
file
=
new
File
(
baseDir
,
logicalPath
);
File
parent
=
file
.
getParentFile
();
parent
.
mkdirs
();
String
hdfsDir
=
parent
.
getAbsolutePath
();
String
filename
=
new
File
(
logicalPath
).
getName
()
+
"-"
+
InetAddress
.
getLocalHost
().
getHostAddress
();
this
.
hdfsPath
=
new
File
(
hdfsDir
,
filename
).
getAbsolutePath
();
}
@Override
public
boolean
storeById
(
String
id
,
byte
[]
data
,
String
...
tags
)
throws
IOException
{
LogView
logView
=
new
LogView
();
logView
.
setOffset
(
this
.
dataStore
.
length
());
logView
.
setLength
(
data
.
length
);
logView
.
setPath
(
this
.
hdfsPath
);
if
(
tags
!=
null
)
{
for
(
String
tag
:
tags
)
{
if
(
tag
.
startsWith
(
"r:"
))
{
logView
.
setTagRequest
(
tag
);
}
if
(
tag
.
startsWith
(
"s:"
))
{
logView
.
setTagSession
(
tag
);
}
if
(
tag
.
startsWith
(
"t:"
))
{
logView
.
setTagThread
(
tag
);
}
}
}
this
.
dataStore
.
append
(
data
);
return
this
.
indexStore
.
insert
(
logView
);
}
}
cat-job/src/main/java/com/dianping/cat/storage/mysql/LogView.java
0 → 100644
浏览文件 @
edaee500
package
com.dianping.cat.storage.mysql
;
public
class
LogView
{
private
long
offset
;
private
int
length
;
private
String
path
;
private
String
tagThread
;
private
String
tagSession
;
private
String
tagRequest
;
public
long
getOffset
()
{
return
offset
;
}
public
void
setOffset
(
long
offset
)
{
this
.
offset
=
offset
;
}
public
int
getLength
()
{
return
length
;
}
public
void
setLength
(
int
length
)
{
this
.
length
=
length
;
}
public
String
getPath
()
{
return
path
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
String
getTagThread
()
{
return
tagThread
;
}
public
void
setTagThread
(
String
tagThread
)
{
this
.
tagThread
=
tagThread
;
}
public
String
getTagSession
()
{
return
tagSession
;
}
public
void
setTagSession
(
String
tagSession
)
{
this
.
tagSession
=
tagSession
;
}
public
String
getTagRequest
()
{
return
tagRequest
;
}
public
void
setTagRequest
(
String
tagRequest
)
{
this
.
tagRequest
=
tagRequest
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录