-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic modification of configuration files&&Slow log #2103
Dynamic modification of configuration files&&Slow log #2103
Conversation
…the functionality.
codis/pkg/utils/configAux.go
Outdated
w := bufio.NewWriter(f) | ||
|
||
for _, item := range c.items { | ||
var lineStr string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放到for循环外面
codis/pkg/proxy/config.go
Outdated
@@ -133,6 +133,11 @@ metrics_report_statsd_prefix = "" | |||
` | |||
|
|||
type Config struct { | |||
ConfigFileName string `toml:"-" json:"config_file_name"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 照配置文件中的顺序放置这些成员,不要上来就放到最上面。
2 为何下面三个成员没有 json?
codis/pkg/proxy/mapper.go
Outdated
@@ -318,3 +320,30 @@ func getHashKey(multi []*redis.Resp, opstr string) []byte { | |||
} | |||
return nil | |||
} | |||
|
|||
func getWholeCmd(multi []*redis.Resp, cmd []byte) int { | |||
var index = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var (
index = 0
bytes = 0
)
codis/pkg/proxy/mapper.go
Outdated
} | ||
bytes += len(multi[i].Value) | ||
|
||
// 如果cmd已经满了,那么最后腾出来一个more长度的位置添加more信息 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成英文
codis/pkg/proxy/proxy.go
Outdated
@@ -10,7 +10,9 @@ import ( | |||
"os" | |||
"os/exec" | |||
"path/filepath" | |||
"pika/codis/v2/pkg/proxy/redis" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意下 import 里面这些包路径的顺序,把这行放到 import 最下面
codis/pkg/proxy/session.go
Outdated
log.Errorf("%s remote:%s, start_time(us):%d, duration(us): [%d, %d, %d], %d, tasksLen:%d", | ||
time.Unix(r.ReceiveTime/1e9, 0).Format("2006-01-02 15:04:05"), s.Conn.RemoteAddr(), r.ReceiveTime/1e3, d0, d1, d2, duration, r.TasksLen) | ||
} | ||
//if s.config.SlowlogLogSlowerThan > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为何注释掉?
codis/pkg/proxy/session.go
Outdated
|
||
r.Resp = SlowLogGetByNum(num) | ||
} else if len(r.Multi) == 4 { | ||
var id int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var (
id int64
num int64
err error
)
codis/pkg/proxy/slowlog.go
Outdated
PIKA_SLOWLOG_LENGTH_MAX = 10000000 | ||
) | ||
|
||
type Mutex struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种封装有何意义?
codis/pkg/proxy/slowlog.go
Outdated
num = int64(PSlowLog.logList.Len()) | ||
} | ||
var res = make([]*redis.Resp, 0, num) | ||
var iter = PSlowLog.logList.Front() // 从最新的数据开始 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面的注释改成英文
codis/pkg/utils/configAux.go
Outdated
return err | ||
} | ||
|
||
// 拿到一行并去除两边空白字符 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释全部改成英文
codis/pkg/utils/configAux.go
Outdated
for i := 0; i < obj.NumField(); i++ { | ||
fieldInfo := obj.Type().Field(i) | ||
name := fieldInfo.Tag.Get("toml") | ||
// 检查字段的toml tag是否合法 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成英文注释
codis/pkg/utils/configAux.go
Outdated
log.Infof("Show config, len = %d\n", len(c.items)) | ||
for index, item := range c.items { | ||
if item.confType == TypeComment { | ||
// 注释的格式: id: context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成英文注释
codis/pkg/utils/configAux.go
Outdated
// 注释的格式: id: context | ||
log.Infof("%d: %s\n", index, item.name) | ||
} else { | ||
// 配置文件的格式: id: key = value 或者 id: key value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成英文注释
55c5e46
to
8f9451e
Compare
codis/pkg/proxy/proxy.go
Outdated
} | ||
} | ||
|
||
func (s *Proxy) ConfigSet(key, value string) *redis.Resp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s 统一改成 p
codis/pkg/utils/configAux.go
Outdated
type DeployConfig struct { | ||
items []*ConfItem | ||
confMap map[string]*ConfItem | ||
sep string //配置项中key、value分隔符 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英文注释
7a045a7
to
864988a
Compare
864988a
to
f19eab2
Compare
codis/pkg/utils/configAux.go
Outdated
if found { | ||
item.value = value | ||
} else { | ||
item := &ConfItem{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
构造函数内赋值
…tion#2103) * Dynamic modification of configuration files.Check the correctness of the functionality. * Modified some specification issues. * Dynamically modify Codis configuration file and add slow query logs.
…tion#2103) * Dynamic modification of configuration files.Check the correctness of the functionality. * Modified some specification issues. * Dynamically modify Codis configuration file and add slow query logs.
Related issue : #2086
1.Add the Codis config command for dynamic configuration at the Codis level.
2. Add slow logging at the Codis level to record commands that exceed the execution time threshold.