|
@@ -13,11 +13,11 @@ import (
|
|
"git.wecise.com/wecise/odb-go/dbo"
|
|
"git.wecise.com/wecise/odb-go/dbo"
|
|
"git.wecise.com/wecise/odb-go/odb"
|
|
"git.wecise.com/wecise/odb-go/odb"
|
|
"git.wecise.com/wecise/odb-go/odbc"
|
|
"git.wecise.com/wecise/odb-go/odbc"
|
|
- "github.com/scylladb/go-set/strset"
|
|
|
|
- "github.com/spf13/cast"
|
|
|
|
"gitee.com/wecisecode/util/merrs"
|
|
"gitee.com/wecisecode/util/merrs"
|
|
"gitee.com/wecisecode/util/mfmt"
|
|
"gitee.com/wecisecode/util/mfmt"
|
|
"gitee.com/wecisecode/util/rc"
|
|
"gitee.com/wecisecode/util/rc"
|
|
|
|
+ "github.com/scylladb/go-set/strset"
|
|
|
|
+ "github.com/spf13/cast"
|
|
)
|
|
)
|
|
|
|
|
|
var mcfg = odbc.Config
|
|
var mcfg = odbc.Config
|
|
@@ -108,7 +108,11 @@ func (ds *DataSync) Run() (done <-chan error) {
|
|
key := regexp.MustCompile(`\W`).ReplaceAllString(strings.Split(ds.fromodbserver, ",")[0]+"_"+ds.fromkeyspace+"_"+strings.Split(ds.toodbserver, ",")[0]+"_"+ds.tokeyspace, "_")
|
|
key := regexp.MustCompile(`\W`).ReplaceAllString(strings.Split(ds.fromodbserver, ",")[0]+"_"+ds.fromkeyspace+"_"+strings.Split(ds.toodbserver, ",")[0]+"_"+ds.tokeyspace, "_")
|
|
ds.syncstatus = NewSyncStatus(key)
|
|
ds.syncstatus = NewSyncStatus(key)
|
|
if !mcfg.GetBool("reload") {
|
|
if !mcfg.GetBool("reload") {
|
|
- ds.syncstatus.Load()
|
|
|
|
|
|
+ e := ds.syncstatus.Load()
|
|
|
|
+ if e != nil {
|
|
|
|
+ ret <- e
|
|
|
|
+ return ret
|
|
|
|
+ }
|
|
}
|
|
}
|
|
go ds.run(ret)
|
|
go ds.run(ret)
|
|
return ret
|
|
return ret
|
|
@@ -136,6 +140,7 @@ func (ds *DataSync) run(ret chan error) {
|
|
defer cancel()
|
|
defer cancel()
|
|
ds.ctx = ctx
|
|
ds.ctx = ctx
|
|
ds.cancel = cancel
|
|
ds.cancel = cancel
|
|
|
|
+ logger.Info("resume sync data, from", len(fromdatas), "configure")
|
|
for {
|
|
for {
|
|
ds.wg = &sync.WaitGroup{}
|
|
ds.wg = &sync.WaitGroup{}
|
|
ds.syncstatus.Resume()
|
|
ds.syncstatus.Resume()
|
|
@@ -189,7 +194,7 @@ func (ds *DataSync) startsyncproc(wg *sync.WaitGroup, rc *rc.RoutinesController,
|
|
// 同步一块数据
|
|
// 同步一块数据
|
|
// mqlfrom 可以是类名 或 查询语句
|
|
// mqlfrom 可以是类名 或 查询语句
|
|
func (ds *DataSync) syncdata(mqlfrom string) error {
|
|
func (ds *DataSync) syncdata(mqlfrom string) error {
|
|
- // 同一格式化为查询语句
|
|
|
|
|
|
+ // 统一格式化为查询语句
|
|
mqlfrom = FormatMQL(mqlfrom)
|
|
mqlfrom = FormatMQL(mqlfrom)
|
|
// 已完成同步进度
|
|
// 已完成同步进度
|
|
fromclass, fields, condition, e := ds.LastSyncProgress(mqlfrom)
|
|
fromclass, fields, condition, e := ds.LastSyncProgress(mqlfrom)
|