Skip to content

Commit

Permalink
rename import-server to tikv-importer (pingcap#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
holys authored Apr 16, 2018
1 parent 3a07584 commit 7e0e5ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Config struct {
ProgressStore DBStore `toml:"progress-store"`

Mydumper MydumperRuntime `toml:"mydumper"`
ImportServer ImportServer `toml:"import-server"`
TikvImporter TikvImporter `toml:"tikv-importer"`
PostRestore PostRestore `toml:"post-restore"`

// command line flags
Expand All @@ -58,7 +58,7 @@ type MydumperRuntime struct {
SourceDir string `toml:"data-source-dir"`
}

type ImportServer struct {
type TikvImporter struct {
Addr string `toml:"addr"`
BatchSize int64 `toml:"batch-size"`
}
Expand Down Expand Up @@ -105,8 +105,8 @@ func LoadConfig(args []string) (*Config, error) {
}

// hendle kv import
if cfg.ImportServer.BatchSize <= 0 {
cfg.ImportServer.BatchSize = KVMaxBatchSize
if cfg.TikvImporter.BatchSize <= 0 {
cfg.TikvImporter.BatchSize = KVMaxBatchSize
}

return cfg, nil
Expand Down
4 changes: 2 additions & 2 deletions lightning/lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func initEnv(cfg *config.Config) error {
return errors.Trace(err)
}

kv.ConfigDeliverTxnBatchSize(cfg.ImportServer.BatchSize)
kv.ConfigDeliverTxnBatchSize(cfg.TikvImporter.BatchSize)

if cfg.App.ProfilePort > 0 {
go func() { // TODO : config to enable it in debug mode
Expand Down Expand Up @@ -91,7 +91,7 @@ func (l *Lightning) run() {
}

func (l *Lightning) doCompact() error {
cli, err := kv.NewKVDeliverClient(context.Background(), uuid.Nil, l.cfg.ImportServer.Addr, l.cfg.TiDB.PdAddr)
cli, err := kv.NewKVDeliverClient(context.Background(), uuid.Nil, l.cfg.TikvImporter.Addr, l.cfg.TiDB.PdAddr)
if err != nil {
return errors.Trace(err)
}
Expand Down
15 changes: 9 additions & 6 deletions lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (rc *RestoreControlloer) compact(ctx context.Context) error {
return nil
}

cli, err := kv.NewKVDeliverClient(ctx, uuid.Nil, rc.cfg.ImportServer.Addr, rc.cfg.TiDB.PdAddr)
cli, err := kv.NewKVDeliverClient(ctx, uuid.Nil, rc.cfg.TikvImporter.Addr, rc.cfg.TiDB.PdAddr)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func makeKVDeliver(
tableInfo *TidbTableInfo) (kv.KVDeliver, error) {

uuid := uuid.Must(uuid.NewV4())
return kv.NewKVDeliverClient(ctx, uuid, cfg.ImportServer.Addr, cfg.TiDB.PdAddr)
return kv.NewKVDeliverClient(ctx, uuid, cfg.TikvImporter.Addr, cfg.TiDB.PdAddr)
}

func setSessionVarInt(db *sql.DB, name string, value int) {
Expand Down Expand Up @@ -564,7 +564,7 @@ func NewTableRestore(
tableInfo: tableInfo,
tableMeta: tableMeta,
encoders: encoders,
deliversMgr: kv.NewKVDeliverKeeper(cfg.ImportServer.Addr, cfg.TiDB.PdAddr),
deliversMgr: kv.NewKVDeliverKeeper(cfg.TikvImporter.Addr, cfg.TiDB.PdAddr),
handledRegions: make(map[int]*regionStat),
localChecksums: localChecksums,
}
Expand Down Expand Up @@ -853,7 +853,10 @@ func (exc *RegionRestoreExectuor) Run(
3. load kvs data (into kv deliver server)
4. flush kvs data (into tikv node)
*/
reader, _ := mydump.NewRegionReader(region.File, region.Offset, region.Size)
reader, err := mydump.NewRegionReader(region.File, region.Offset, region.Size)
if err != nil {
return 0, 0, nil, errors.Trace(err)
}
defer reader.Close()

table := exc.tableInfo.Name
Expand All @@ -866,8 +869,8 @@ func (exc *RegionRestoreExectuor) Run(
/*
TODO :
So far, since checksum can not recompute on the same key-value pair,
otherwise this would leds to an incorrect checksum value finally.
So it's important to gaurnate that do checksum on kvs correctly
otherwise this would leads to an incorrect checksum value finally.
So it's important to guarantee that do checksum on kvs correctly
no matter what happens during process of restore ( eg. safe point / error retry ... )
*/

Expand Down
2 changes: 1 addition & 1 deletion tidb-lightning.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ max-size = 128 # MB
max-days = 28
max-backups = 14

[import-server]
[tikv-importer]
addr = "127.0.0.1:8808"
# size of batch to import kv data into TiKV: xxx (GB)
batch-size = 200 # GB
Expand Down

0 comments on commit 7e0e5ca

Please sign in to comment.