Skip to content

Commit e2c5d52

Browse files
authored
PBM-1506 GCS support concurrent downloading (#1104)
* add gcs download * add download for shared logic * move common logic to storage/download.go * update storage * update gcs download * add NewDownloadStat * add gcs to physical restore
1 parent d6ef021 commit e2c5d52

File tree

7 files changed

+671
-436
lines changed

7 files changed

+671
-436
lines changed

pbm/restore/phys/phys.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"go.mongodb.org/mongo-driver/bson/primitive"
99

1010
"github.com/percona/percona-backup-mongodb/pbm/errors"
11-
"github.com/percona/percona-backup-mongodb/pbm/storage/s3"
11+
"github.com/percona/percona-backup-mongodb/pbm/storage"
1212
)
1313

1414
type RestoreStat struct {
1515
RS map[string]map[string]RestoreRSMetrics `bson:"rs,omitempty" json:"rs,omitempty"`
1616
}
1717
type RestoreRSMetrics struct {
18-
DistTxn DistTxnStat `bson:"txn,omitempty" json:"txn,omitempty"`
19-
Download s3.DownloadStat `bson:"download,omitempty" json:"download,omitempty"`
18+
DistTxn DistTxnStat `bson:"txn,omitempty" json:"txn,omitempty"`
19+
Download storage.DownloadStat `bson:"download,omitempty" json:"download,omitempty"`
2020
}
2121

2222
type DistTxnStat struct {
@@ -35,8 +35,8 @@ type DistTxnStat struct {
3535
}
3636

3737
type RestoreShardStat struct {
38-
Txn DistTxnStat `json:"txn"`
39-
D *s3.DownloadStat `json:"d"`
38+
Txn DistTxnStat `json:"txn"`
39+
D *storage.DownloadStat `json:"d"`
4040
}
4141

4242
type TxnState string

pbm/restore/physical.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/percona/percona-backup-mongodb/pbm/log"
4040
"github.com/percona/percona-backup-mongodb/pbm/restore/phys"
4141
"github.com/percona/percona-backup-mongodb/pbm/storage"
42+
"github.com/percona/percona-backup-mongodb/pbm/storage/gcs"
4243
"github.com/percona/percona-backup-mongodb/pbm/storage/s3"
4344
"github.com/percona/percona-backup-mongodb/pbm/topo"
4445
"github.com/percona/percona-backup-mongodb/pbm/util"
@@ -1271,17 +1272,25 @@ func (r *PhysRestore) dumpMeta(meta *RestoreMeta, s defs.Status, msg string) err
12711272
return nil
12721273
}
12731274

1274-
func (r *PhysRestore) copyFiles() (*s3.DownloadStat, error) {
1275-
var stat *s3.DownloadStat
1275+
func (r *PhysRestore) copyFiles() (*storage.DownloadStat, error) {
1276+
var stat *storage.DownloadStat
12761277
readFn := r.bcpStg.SourceReader
1277-
if t, ok := r.bcpStg.(*s3.S3); ok {
1278+
1279+
switch t := r.bcpStg.(type) {
1280+
case *s3.S3:
1281+
d := t.NewDownload(r.confOpts.NumDownloadWorkers, r.confOpts.MaxDownloadBufferMb, r.confOpts.DownloadChunkMb)
1282+
readFn = d.SourceReader
1283+
defer func() {
1284+
s := d.Stat()
1285+
stat = &s
1286+
r.log.Debug("download stat: %s", s)
1287+
}()
1288+
case *gcs.GCS:
12781289
d := t.NewDownload(r.confOpts.NumDownloadWorkers, r.confOpts.MaxDownloadBufferMb, r.confOpts.DownloadChunkMb)
12791290
readFn = d.SourceReader
1280-
12811291
defer func() {
12821292
s := d.Stat()
12831293
stat = &s
1284-
12851294
r.log.Debug("download stat: %s", s)
12861295
}()
12871296
}

0 commit comments

Comments
 (0)