refactor(keeper): modify log and optimize code
This commit is contained in:
parent
bea62b713b
commit
57e48a5ae6
|
@ -332,7 +332,7 @@ func (r *Reporter) handlerFunc() gin.HandlerFunc {
|
||||||
|
|
||||||
logger.Tracef("report data:%s", string(data))
|
logger.Tracef("report data:%s", string(data))
|
||||||
if e := json.Unmarshal(data, &report); e != nil {
|
if e := json.Unmarshal(data, &report); e != nil {
|
||||||
logger.Errorf("error occurred while unmarshal request, data:%s, error:%s", data, err)
|
logger.Errorf("error occurred while unmarshal request, data:%s, error:%v", data, e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var sqls []string
|
var sqls []string
|
||||||
|
|
|
@ -58,7 +58,7 @@ func NewCommand(conf *config.Config) *Command {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
imp := &Command{
|
return &Command{
|
||||||
client: client,
|
client: client,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
username: conf.TDengine.Username,
|
username: conf.TDengine.Username,
|
||||||
|
@ -70,7 +70,6 @@ func NewCommand(conf *config.Config) *Command {
|
||||||
RawQuery: fmt.Sprintf("db=%s&precision=ms", conf.Metrics.Database.Name),
|
RawQuery: fmt.Sprintf("db=%s&precision=ms", conf.Metrics.Database.Name),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return imp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *Command) Process(conf *config.Config) {
|
func (cmd *Command) Process(conf *config.Config) {
|
||||||
|
@ -101,7 +100,7 @@ func (cmd *Command) Process(conf *config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *Command) ProcessTransfer(conf *config.Config) {
|
func (cmd *Command) ProcessTransfer(conf *config.Config) {
|
||||||
fromTime, err := time.Parse("2006-01-02T15:04:05Z07:00", conf.FromTime)
|
fromTime, err := time.Parse(time.RFC3339, conf.FromTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("parse fromTime error, msg:%s", err)
|
logger.Errorf("parse fromTime error, msg:%s", err)
|
||||||
return
|
return
|
||||||
|
@ -401,7 +400,6 @@ func (cmd *Command) TransferTaosdClusterBasicInfo() error {
|
||||||
|
|
||||||
// cluster_info
|
// cluster_info
|
||||||
func (cmd *Command) TransferTableToDst(sql string, dstTable string, tagNum int) error {
|
func (cmd *Command) TransferTableToDst(sql string, dstTable string, tagNum int) error {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
|
|
|
@ -41,33 +41,31 @@ func (s *sysMonitor) collect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
|
|
||||||
for output := range s.outputs {
|
for output := range s.outputs {
|
||||||
select {
|
select {
|
||||||
case output <- *s.status:
|
case output <- *s.status:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sysMonitor) Register(c chan<- SysStatus) {
|
func (s *sysMonitor) Register(c chan<- SysStatus) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
if s.outputs == nil {
|
if s.outputs == nil {
|
||||||
s.outputs = map[chan<- SysStatus]struct{}{
|
s.outputs = map[chan<- SysStatus]struct{}{}
|
||||||
c: {},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s.outputs[c] = struct{}{}
|
|
||||||
}
|
}
|
||||||
s.Unlock()
|
s.outputs[c] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sysMonitor) Deregister(c chan<- SysStatus) {
|
func (s *sysMonitor) Deregister(c chan<- SysStatus) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
if s.outputs != nil {
|
if s.outputs != nil {
|
||||||
delete(s.outputs, c)
|
delete(s.outputs, c)
|
||||||
}
|
}
|
||||||
s.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var SysMonitor = &sysMonitor{status: &SysStatus{}}
|
var SysMonitor = &sysMonitor{status: &SysStatus{}}
|
||||||
|
|
Loading…
Reference in New Issue