Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
makalaaneesh committed Jan 29, 2025
1 parent 0337345 commit a5cd1fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions yb-voyager/cmd/importDataFileTaskImporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (fti *FileTaskImporter) AllBatchesImported() error {
}

func (fti *FileTaskImporter) SubmitNextBatch() error {
if fti.batchProducer.Done() {
if fti.AllBatchesSubmitted() {
return fmt.Errorf("no more batches to submit")
}
batch, err := fti.batchProducer.NextBatch()
Expand All @@ -92,7 +92,7 @@ func (fti *FileTaskImporter) SubmitNextBatch() error {
}

func (fti *FileTaskImporter) importBatch(batch *Batch) {
err := batch.MarkPending()
err := batch.MarkInProgress()
if err != nil {
utils.ErrExit("marking batch as pending: %d: %s", batch.Number, err)
}
Expand Down
23 changes: 11 additions & 12 deletions yb-voyager/cmd/importDataState.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,17 +744,16 @@ func (bw *BatchWriter) Done(isLastBatch bool, offsetEnd int64, byteCount int64)
//============================================================================

type Batch struct {
Number int64
TableNameTup sqlname.NameTuple
SchemaName string
FilePath string // Path of the batch file.
BaseFilePath string // Path of the original data file.
OffsetStart int64
OffsetEnd int64
RecordCount int64
ByteCount int64
TmpConnectionString string
Interrupted bool
Number int64
TableNameTup sqlname.NameTuple
SchemaName string
FilePath string // Path of the batch file.
BaseFilePath string // Path of the original data file.
OffsetStart int64
OffsetEnd int64
RecordCount int64
ByteCount int64
Interrupted bool
}

func (batch *Batch) Open() (*os.File, error) {
Expand Down Expand Up @@ -783,7 +782,7 @@ func (batch *Batch) IsDone() bool {
return strings.HasSuffix(batch.FilePath, ".D")
}

func (batch *Batch) MarkPending() error {
func (batch *Batch) MarkInProgress() error {
// Rename the file to .P
inProgressFilePath := batch.getInProgressFilePath()
log.Infof("Renaming file from %q to %q", batch.FilePath, inProgressFilePath)
Expand Down
6 changes: 3 additions & 3 deletions yb-voyager/cmd/importDataTestUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ func (d *dummyTDB) MaxBatchSizeInBytes() int64 {
return d.maxSizeBytes
}

type TestDB struct {
type TestTargetDB struct {
testcontainers.TestContainer
tgtdb.TargetDB
}

var testYugabyteDBTarget *TestDB
var testYugabyteDBTarget *TestTargetDB

func setupYugabyteTestDb(t *testing.T) {
yugabytedbContainer := testcontainers.NewTestContainer("yugabytedb", nil)
err := yugabytedbContainer.Start(context.Background())
testutils.FatalIfError(t, err)
host, port, err := yugabytedbContainer.GetHostPort()
testutils.FatalIfError(t, err)
testYugabyteDBTarget = &TestDB{
testYugabyteDBTarget = &TestTargetDB{
TestContainer: yugabytedbContainer,
TargetDB: tgtdb.NewTargetDB(&tgtdb.TargetConf{
TargetDBType: "yugabytedb",
Expand Down

0 comments on commit a5cd1fa

Please sign in to comment.