diff --git a/src/cmd/tools/dtest/util/seed/generator_test.go b/src/cmd/tools/dtest/util/seed/generator_test.go index 364fb0da06..31a73196dc 100644 --- a/src/cmd/tools/dtest/util/seed/generator_test.go +++ b/src/cmd/tools/dtest/util/seed/generator_test.go @@ -128,18 +128,12 @@ func (t *fileInfoExtractor) visit(fPath string, f os.FileInfo, err error) error t.shards[uint32(shardNum)] = struct{}{} name := f.Name() - first := strings.Index(name, "-") - if first == -1 { - return fmt.Errorf("unable to find '-' in %v", name) + nameSplit := strings.Split(name, "-") + if len(nameSplit) < 2 { + return fmt.Errorf("unable to parse time from %v", name) } - last := strings.LastIndex(name, "-") - if last == -1 { - return fmt.Errorf("unable to find '-' in %v", name) - } - if first == last { - return fmt.Errorf("found only single '-' in %v", name) - } - num, parseErr := strconv.ParseInt(name[first+1:last], 10, 64) + + num, parseErr := strconv.ParseInt(nameSplit[1], 10, 64) if parseErr != nil { return err } diff --git a/src/dbnode/persist/fs/files.go b/src/dbnode/persist/fs/files.go index 96479971b7..be6594d674 100644 --- a/src/dbnode/persist/fs/files.go +++ b/src/dbnode/persist/fs/files.go @@ -633,13 +633,6 @@ func forEachInfoFile( t := matched[i].ID.BlockStart volume := matched[i].ID.VolumeIndex - isLegacy := false - if volume == 0 { - isLegacy, err = isFirstVolumeLegacy(dir, t, checkpointFileSuffix) - if err != nil { - continue - } - } var ( checkpointFilePath string digestsFilePath string @@ -649,6 +642,13 @@ func forEachInfoFile( case persist.FileSetFlushType: switch args.contentType { case persist.FileSetDataContentType: + isLegacy := false + if volume == 0 { + isLegacy, err = isFirstVolumeLegacy(dir, t, checkpointFileSuffix) + if err != nil { + continue + } + } checkpointFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, checkpointFileSuffix, isLegacy) digestsFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, digestFileSuffix, isLegacy) infoFilePath = dataFilesetPathFromTimeAndIndex(dir, t, volume, infoFileSuffix, isLegacy) diff --git a/src/dbnode/persist/fs/index_lookup_prop_test.go b/src/dbnode/persist/fs/index_lookup_prop_test.go index 55b185c9a5..e634381382 100644 --- a/src/dbnode/persist/fs/index_lookup_prop_test.go +++ b/src/dbnode/persist/fs/index_lookup_prop_test.go @@ -107,8 +107,8 @@ func TestIndexLookupWriteRead(t *testing.T) { } // Read the summaries file into memory - summariesFilePath := filesetPathFromTimeLegacy( - shardDirPath, testWriterStart, summariesFileSuffix) + summariesFilePath := dataFilesetPathFromTimeAndIndex( + shardDirPath, testWriterStart, 0, summariesFileSuffix, false) summariesFile, err := os.Open(summariesFilePath) if err != nil { return false, fmt.Errorf("err opening summaries file: %v, ", err) @@ -254,7 +254,7 @@ func genTagIdent() gopter.Gen { } func readIndexFileOffsets(shardDirPath string, numEntries int, start time.Time) (map[string]int64, error) { - indexFilePath := filesetPathFromTimeLegacy(shardDirPath, start, indexFileSuffix) + indexFilePath := dataFilesetPathFromTimeAndIndex(shardDirPath, start, 0, indexFileSuffix, false) buf, err := ioutil.ReadFile(indexFilePath) if err != nil { return nil, fmt.Errorf("err reading index file: %v, ", err) diff --git a/src/dbnode/storage/bootstrap/bootstrapper/fs/source.go b/src/dbnode/storage/bootstrap/bootstrapper/fs/source.go index 61e8afd6e9..27aa8e910c 100644 --- a/src/dbnode/storage/bootstrap/bootstrapper/fs/source.go +++ b/src/dbnode/storage/bootstrap/bootstrapper/fs/source.go @@ -26,6 +26,7 @@ import ( "sync" "time" + "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/persist" "github.com/m3db/m3/src/dbnode/persist/fs" "github.com/m3db/m3/src/dbnode/retention" @@ -33,7 +34,6 @@ import ( "github.com/m3db/m3/src/dbnode/storage/bootstrap" "github.com/m3db/m3/src/dbnode/storage/bootstrap/result" "github.com/m3db/m3/src/dbnode/storage/index/convert" - "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/storage/series" "github.com/m3db/m3/src/dbnode/ts" "github.com/m3db/m3/src/m3ninx/index/segment" diff --git a/src/dbnode/storage/bootstrap/bootstrapper/fs/source_data_test.go b/src/dbnode/storage/bootstrap/bootstrapper/fs/source_data_test.go index eeb53caa4c..95ca8f394e 100644 --- a/src/dbnode/storage/bootstrap/bootstrapper/fs/source_data_test.go +++ b/src/dbnode/storage/bootstrap/bootstrapper/fs/source_data_test.go @@ -31,11 +31,11 @@ import ( "time" "github.com/m3db/m3/src/dbnode/digest" + "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/persist/fs" "github.com/m3db/m3/src/dbnode/retention" "github.com/m3db/m3/src/dbnode/storage/bootstrap" "github.com/m3db/m3/src/dbnode/storage/bootstrap/result" - "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/storage/series" "github.com/m3db/m3/src/x/checked" "github.com/m3db/m3/src/x/context" @@ -107,19 +107,19 @@ func createTempDir(t *testing.T) string { func writeInfoFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) { shardDir := fs.ShardDataDirPath(prefix, namespace, shard) - filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-info.db", xtime.ToNanoseconds(start))) + filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-info.db", xtime.ToNanoseconds(start))) writeFile(t, filePath, data) } func writeDataFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) { shardDir := fs.ShardDataDirPath(prefix, namespace, shard) - filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-data.db", xtime.ToNanoseconds(start))) + filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-data.db", xtime.ToNanoseconds(start))) writeFile(t, filePath, data) } func writeDigestFile(t *testing.T, prefix string, namespace ident.ID, shard uint32, start time.Time, data []byte) { shardDir := fs.ShardDataDirPath(prefix, namespace, shard) - filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-digest.db", xtime.ToNanoseconds(start))) + filePath := path.Join(shardDir, fmt.Sprintf("fileset-%d-0-digest.db", xtime.ToNanoseconds(start))) writeFile(t, filePath, data) }