Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
OpenAtomFoundation
pika
提交
4c240f70
pika
项目概览
镜像
/
OpenAtomFoundation
/
pika
11 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
pika
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c240f70
编写于
4月 20, 2017
作者:
K
KernelMaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1) change some log; 2) compact-cron: free/total >? 3) config set compact-cron
上级
4a24bd2a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
13 deletion
+45
-13
conf/pika.conf
conf/pika.conf
+2
-2
include/pika_conf.h
include/pika_conf.h
+5
-0
src/pika_admin.cc
src/pika_admin.cc
+24
-0
src/pika_client_conn.cc
src/pika_client_conn.cc
+2
-2
src/pika_conf.cc
src/pika_conf.cc
+2
-2
src/pika_server.cc
src/pika_server.cc
+10
-7
未找到文件。
conf/pika.conf
浏览文件 @
4c240f70
...
...
@@ -56,8 +56,8 @@ db-sync-speed : -1
# network-interface : eth1
# replication
# slaveof : master-ip:master-port
# CronTask, format: start:end-ratio, like 02
:04-
60, pika will check to schedule compaction between 2 to 4 o'clock everyday
# if the
db
size/disksize > 60%
# CronTask, format: start:end-ratio, like 02
-04/
60, pika will check to schedule compaction between 2 to 4 o'clock everyday
# if the
free
size/disksize > 60%
# compact-cron :
###################
...
...
include/pika_conf.h
浏览文件 @
4c240f70
...
...
@@ -138,6 +138,11 @@ public:
RWLock
l
(
&
rwlock_
,
true
);
db_sync_speed_
=
value
;
}
void
SetCompactCron
(
const
std
::
string
&
value
)
{
RWLock
l
(
&
rwlock_
,
true
);
compact_cron_
=
value
;
}
int
Load
();
int
ConfigRewrite
();
...
...
src/pika_admin.cc
浏览文件 @
4c240f70
...
...
@@ -1077,6 +1077,30 @@ void ConfigCmd::ConfigSet(std::string& ret) {
}
g_pika_conf
->
SetDbSyncSpeed
(
ival
);
ret
=
"+OK
\r\n
"
;
}
else
if
(
set_item
==
"compact-cron"
)
{
bool
invalid
=
false
;
std
::
string
::
size_type
len
=
value
.
length
();
std
::
string
::
size_type
colon
=
value
.
find
(
"-"
);
std
::
string
::
size_type
underline
=
value
.
find
(
"/"
);
if
(
colon
==
std
::
string
::
npos
||
underline
==
std
::
string
::
npos
||
colon
>=
underline
||
colon
+
1
>=
len
||
colon
+
1
==
underline
||
underline
+
1
>=
len
)
{
invalid
=
true
;
}
else
{
int
start
=
std
::
atoi
(
value
.
substr
(
0
,
colon
).
c_str
());
int
end
=
std
::
atoi
(
value
.
substr
(
colon
+
1
,
underline
).
c_str
());
int
usage
=
std
::
atoi
(
value
.
substr
(
underline
+
1
).
c_str
());
if
(
start
<
0
||
start
>
23
||
end
<
0
||
end
>
23
||
usage
<
0
||
usage
>
100
)
{
invalid
=
true
;
}
}
if
(
invalid
)
{
ret
=
"-ERR invalid compact-cron
\r\n
"
;
return
;
}
else
{
g_pika_conf
->
SetCompactCron
(
value
);
ret
=
"+OK
\r\n
"
;
}
}
else
{
ret
=
"-ERR No such configure item
\r\n
"
;
}
...
...
src/pika_client_conn.cc
浏览文件 @
4c240f70
...
...
@@ -46,7 +46,7 @@ std::string PikaClientConn::DoCmd(const std::string& opt) {
// Check authed
if
(
!
auth_stat_
.
IsAuthed
(
cinfo_ptr
))
{
LOG
(
WARNING
)
<<
"("
<<
ip_port
()
<<
")Authentication required"
;
//
LOG(WARNING) << "(" << ip_port() << ")Authentication required";
return
"-ERR NOAUTH Authentication required.
\r\n
"
;
}
...
...
@@ -140,7 +140,7 @@ std::string PikaClientConn::DoCmd(const std::string& opt) {
if
(
opt
==
kCmdNameAuth
)
{
if
(
!
auth_stat_
.
ChecknUpdate
(
c_ptr
->
res
().
raw_message
()))
{
LOG
(
WARNING
)
<<
"("
<<
ip_port
()
<<
")Wrong Password"
;
//
LOG(WARNING) << "(" << ip_port() << ")Wrong Password";
}
}
return
c_ptr
->
res
().
message
();
...
...
src/pika_conf.cc
浏览文件 @
4c240f70
...
...
@@ -107,8 +107,8 @@ int PikaConf::Load()
GetConfStr
(
"compact-cron"
,
&
compact_cron_
);
if
(
compact_cron_
!=
""
)
{
std
::
string
::
size_type
len
=
compact_cron_
.
length
();
std
::
string
::
size_type
colon
=
compact_cron_
.
find
(
"
:
"
);
std
::
string
::
size_type
underline
=
compact_cron_
.
find
(
"
-
"
);
std
::
string
::
size_type
colon
=
compact_cron_
.
find
(
"
-
"
);
std
::
string
::
size_type
underline
=
compact_cron_
.
find
(
"
/
"
);
if
(
colon
==
std
::
string
::
npos
||
underline
==
std
::
string
::
npos
||
colon
>=
underline
||
colon
+
1
>=
len
||
colon
+
1
==
underline
||
underline
+
1
>=
len
)
{
...
...
src/pika_server.cc
浏览文件 @
4c240f70
...
...
@@ -1105,8 +1105,8 @@ void PikaServer::AutoCompactRange() {
if
(
cc
==
""
)
{
return
;
}
else
{
std
::
string
::
size_type
colon
=
cc
.
find
(
"
:
"
);
std
::
string
::
size_type
underline
=
cc
.
find
(
"
-
"
);
std
::
string
::
size_type
colon
=
cc
.
find
(
"
-
"
);
std
::
string
::
size_type
underline
=
cc
.
find
(
"
/
"
);
int
start
=
std
::
atoi
(
cc
.
substr
(
0
,
colon
).
c_str
());
int
end
=
std
::
atoi
(
cc
.
substr
(
colon
+
1
,
underline
).
c_str
());
int
usage
=
std
::
atoi
(
cc
.
substr
(
underline
+
1
).
c_str
());
...
...
@@ -1121,7 +1121,8 @@ void PikaServer::AutoCompactRange() {
}
else
{
have_scheduled_crontask_
=
false
;
}
// LOG(INFO) << "start: " << start << " end: " << end << " usage " << usage <<
// " have_scheduled: " << have_scheduled_crontask_ << " in_window: " << in_window;
if
(
!
have_scheduled_crontask_
&&
in_window
)
{
struct
statfs
disk_info
;
int
ret
=
statfs
(
g_pika_conf
->
db_path
().
c_str
(),
&
disk_info
);
...
...
@@ -1131,14 +1132,16 @@ void PikaServer::AutoCompactRange() {
}
uint64_t
total_size
=
disk_info
.
f_bsize
*
disk_info
.
f_blocks
;
uint64_t
free_size
=
disk_info
.
f_bsize
*
disk_info
.
f_blocks
;
uint64_t
db_size
=
slash
::
Du
(
g_pika_conf
->
db_path
());
if
((
db_size
/
total_size
)
*
100
>=
usage
)
{
// LOG(INFO) << "free_size: " << free_size << " disk_size: " << total_size <<
// " cal: " << ((double)free_size / total_size) * 100;
if
(((
double
)
free_size
/
total_size
)
*
100
>=
usage
)
{
nemo
::
Status
s
=
db_
->
Compact
(
nemo
::
kALL
);
if
(
s
.
ok
())
{
LOG
(
INFO
)
<<
"schedule compactRange,
dbsize: "
<<
db
_size
<<
" disksize: "
<<
total_size
;
LOG
(
INFO
)
<<
"schedule compactRange,
freesize: "
<<
free
_size
<<
" disksize: "
<<
total_size
;
}
else
{
LOG
(
INFO
)
<<
"schedule compactRange Failed,
dbsize: "
<<
db
_size
<<
" disksize: "
<<
total_size
LOG
(
INFO
)
<<
"schedule compactRange Failed,
freesize: "
<<
free
_size
<<
" disksize: "
<<
total_size
<<
" error: "
<<
s
.
ToString
();
}
have_scheduled_crontask_
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录