@@ -40,11 +40,11 @@ import (
4040 "github.com/pingcap/tidb/lightning/pkg/errormanager"
4141 "github.com/pingcap/tidb/lightning/pkg/progress"
4242 tidbconfig "github.com/pingcap/tidb/pkg/config"
43+ "github.com/pingcap/tidb/pkg/ingestor/ingestctrl"
4344 "github.com/pingcap/tidb/pkg/keyspace"
4445 tidbkv "github.com/pingcap/tidb/pkg/kv"
4546 "github.com/pingcap/tidb/pkg/lightning/backend"
4647 "github.com/pingcap/tidb/pkg/lightning/backend/encode"
47- "github.com/pingcap/tidb/pkg/lightning/backend/local"
4848 "github.com/pingcap/tidb/pkg/lightning/backend/tidb"
4949 "github.com/pingcap/tidb/pkg/lightning/common"
5050 "github.com/pingcap/tidb/pkg/lightning/config"
@@ -240,7 +240,7 @@ type Controller struct {
240240 preInfoGetter PreImportInfoGetter
241241 precheckItemBuilder * PrecheckItemBuilder
242242 encBuilder encode.EncodingBuilder
243- tikvModeSwitcher local .TiKVModeSwitcher
243+ tikvModeSwitcher ingestctrl .TiKVModeSwitcher
244244
245245 keyspaceName string
246246 resourceGroupName string
@@ -369,19 +369,19 @@ func NewImportControllerWithPauser(
369369 encodingBuilder = tidb .NewEncodingBuilder ()
370370 backendObj = tidb .NewTiDBBackend (ctx , db , cfg , errorMgr )
371371 case config .BackendLocal :
372- var rLimit local .RlimT
373- rLimit , err = local .GetSystemRLimit ()
372+ var rLimit ingestctrl .RlimT
373+ rLimit , err = ingestctrl .GetSystemRLimit ()
374374 if err != nil {
375375 return nil , err
376376 }
377- maxOpenFiles := int (rLimit / local .RlimT (cfg .App .TableConcurrency ))
377+ maxOpenFiles := int (rLimit / ingestctrl .RlimT (cfg .App .TableConcurrency ))
378378 // check overflow
379379 if maxOpenFiles < 0 {
380380 maxOpenFiles = math .MaxInt32
381381 }
382382
383383 addrs := strings .Split (cfg .TiDB .PdAddr , "," )
384- pdCli , err = pd .NewClientWithContext (ctx , componentName , addrs , tls .ToPDSecurityOption (), local .PDClientOptions ()... )
384+ pdCli , err = pd .NewClientWithContext (ctx , componentName , addrs , tls .ToPDSecurityOption (), ingestctrl .PDClientOptions ()... )
385385 if err != nil {
386386 return nil , errors .Trace (err )
387387 }
@@ -402,14 +402,14 @@ func NewImportControllerWithPauser(
402402 }
403403
404404 // simple wraps PD client, so no need to close it separately.
405- pdCliForTiKV , err := local .NewCodecPDClient (pdCli , p .KeyspaceName )
405+ pdCliForTiKV , err := ingestctrl .NewCodecPDClient (pdCli , p .KeyspaceName )
406406 if err != nil {
407407 return nil , common .ErrCreatePDClient .Wrap (err ).GenWithStackByArgs ()
408408 }
409409
410410 initGlobalConfig (tls .ToTiKVSecurityConfig ())
411411
412- encodingBuilder = local .NewEncodingBuilder (ctx )
412+ encodingBuilder = ingestctrl .NewEncodingBuilder (ctx )
413413
414414 // get resource group name.
415415 exec := common.SQLWithRetry {
@@ -445,8 +445,8 @@ func NewImportControllerWithPauser(
445445 if isRaftKV2 {
446446 raftKV2SwitchModeDuration = cfg .Cron .SwitchMode .Duration
447447 }
448- backendConfig := local .NewBackendConfig (cfg , maxOpenFiles , p .KeyspaceName , p .ResourceGroupName , p .TaskType , raftKV2SwitchModeDuration )
449- backendObj , err = local .NewBackend (ctx , tls , backendConfig , pdCliForTiKV )
448+ backendConfig := ingestctrl .NewBackendConfig (cfg , maxOpenFiles , p .KeyspaceName , p .ResourceGroupName , p .TaskType , raftKV2SwitchModeDuration )
449+ backendObj , err = ingestctrl .NewBackend (ctx , tls , backendConfig , pdCliForTiKV )
450450 if err != nil {
451451 return nil , common .NormalizeOrWrapErr (common .ErrUnknown , err )
452452 }
@@ -479,7 +479,7 @@ func NewImportControllerWithPauser(
479479
480480 var wrapper backend.TargetInfoGetter
481481 if cfg .TikvImporter .Backend == config .BackendLocal {
482- wrapper = local .NewTargetInfoGetter (tls , db , pdHTTPCli )
482+ wrapper = ingestctrl .NewTargetInfoGetter (tls , db , pdHTTPCli )
483483 } else {
484484 wrapper = tidb .NewTargetInfoGetter (db )
485485 }
@@ -544,7 +544,7 @@ func NewImportControllerWithPauser(
544544 preInfoGetter : preInfoGetter ,
545545 precheckItemBuilder : preCheckBuilder ,
546546 encBuilder : encodingBuilder ,
547- tikvModeSwitcher : local .NewTiKVModeSwitcher (tls .TLSConfig (), pdHTTPCli , logutil .Logger (ctx )),
547+ tikvModeSwitcher : ingestctrl .NewTiKVModeSwitcher (tls .TLSConfig (), pdHTTPCli , logutil .Logger (ctx )),
548548
549549 keyspaceName : p .KeyspaceName ,
550550 resourceGroupName : p .ResourceGroupName ,
@@ -760,7 +760,7 @@ func verifyLocalFile(ctx context.Context, cpdb checkpoints.DB, dir string) error
760760 for tableName , engineIDs := range targetTables {
761761 for _ , engineID := range engineIDs {
762762 _ , eID := backend .MakeUUID (tableName , int64 (engineID ))
763- file := local .Engine {UUID : eID }
763+ file := ingestctrl .Engine {UUID : eID }
764764 err := file .Exist (dir )
765765 if err != nil {
766766 logutil .Logger (ctx ).Error ("can't find local file" ,
@@ -1705,7 +1705,7 @@ func (rc *Controller) enforceDiskQuota(ctx context.Context) {
17051705 return
17061706 }
17071707
1708- localBackend := rc .backend .(* local .Backend )
1708+ localBackend := rc .backend .(* ingestctrl .Backend )
17091709 go func () {
17101710 // locker is assigned when we detect the disk quota is exceeded.
17111711 // before the disk quota is confirmed exceeded, we keep the diskQuotaLock
@@ -1733,7 +1733,7 @@ func (rc *Controller) enforceDiskQuota(ctx context.Context) {
17331733 }
17341734
17351735 quota := int64 (rc .cfg .TikvImporter .DiskQuota )
1736- largeEngines , inProgressLargeEngines , totalDiskSize , totalMemSize := local .CheckDiskQuota (localBackend , quota )
1736+ largeEngines , inProgressLargeEngines , totalDiskSize , totalMemSize := ingestctrl .CheckDiskQuota (localBackend , quota )
17371737 if m , ok := metric .FromContext (ctx ); ok {
17381738 m .LocalStorageUsageBytesGauge .WithLabelValues ("disk" ).Set (float64 (totalDiskSize ))
17391739 m .LocalStorageUsageBytesGauge .WithLabelValues ("mem" ).Set (float64 (totalMemSize ))
0 commit comments