Changes to try and pass the URL parameters through - in memory flag not working still

This commit is contained in:
Tom Maxwell
2019-09-03 15:41:28 +01:00
parent 9a459d984b
commit d637d86d22
15 changed files with 74 additions and 36 deletions

View File

@@ -112,14 +112,14 @@ func runBackup(cmd *Command, args []string) bool {
return true
}
}
v, err := storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0)
v, err := storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, false)
if err != nil {
fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)
return true
}
if v.SuperBlock.CompactionRevision < uint16(stats.CompactRevision) {
if err = v.Compact(0, 0); err != nil {
if err = v.Compact(0, 0, false); err != nil {
fmt.Printf("Compact Volume before synchronizing %v\n", err)
return true
}
@@ -137,7 +137,7 @@ func runBackup(cmd *Command, args []string) bool {
// remove the old data
v.Destroy()
// recreate an empty volume
v, err = storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0)
v, err = storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, false)
if err != nil {
fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)
return true

View File

@@ -26,6 +26,7 @@ var (
compactVolumeId = cmdCompact.Flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir.")
compactMethod = cmdCompact.Flag.Int("method", 0, "option to choose which compact method. use 0 or 1.")
compactVolumePreallocate = cmdCompact.Flag.Int64("preallocateMB", 0, "preallocate volume disk space")
compactVolumeInMemory = cmdCompact.Flag.Bool("volumeInMemory", false, "create the volume in memory")
)
func runCompact(cmd *Command, args []string) bool {
@@ -35,15 +36,16 @@ func runCompact(cmd *Command, args []string) bool {
}
preallocate := *compactVolumePreallocate * (1 << 20)
inMemory := *compactVolumeInMemory
vid := needle.VolumeId(*compactVolumeId)
v, err := storage.NewVolume(*compactVolumePath, *compactVolumeCollection, vid,
storage.NeedleMapInMemory, nil, nil, preallocate)
storage.NeedleMapInMemory, nil, nil, preallocate, inMemory)
if err != nil {
glog.Fatalf("Load Volume [ERROR] %s\n", err)
}
if *compactMethod == 0 {
if err = v.Compact(preallocate, 0); err != nil {
if err = v.Compact(preallocate, 0, inMemory); err != nil {
glog.Fatalf("Compact Volume [ERROR] %s\n", err)
}
} else {