mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
adjust NewDiskFile() paramaters
This commit is contained in:
parent
cd7ce720c7
commit
4b5ba4927f
|
@ -48,7 +48,7 @@ func main() {
|
|||
if err != nil {
|
||||
glog.Fatalf("Open Volume Data File [ERROR]: %v", err)
|
||||
}
|
||||
datBackend := backend.NewDiskFile(*fixVolumePath, datFile)
|
||||
datBackend := backend.NewDiskFile(datFile)
|
||||
defer datBackend.Close()
|
||||
|
||||
superBlock, err := storage.ReadSuperBlock(datBackend)
|
||||
|
|
|
@ -50,7 +50,7 @@ func main() {
|
|||
if err != nil {
|
||||
glog.Fatalf("Read Volume Data %v", err)
|
||||
}
|
||||
datBackend := backend.NewDiskFile(datFileName, datFile)
|
||||
datBackend := backend.NewDiskFile(datFile)
|
||||
defer datBackend.Close()
|
||||
|
||||
newDatFile, err := os.Create(path.Join(*fixVolumePath, fileName+".dat_fixed"))
|
||||
|
|
|
@ -50,7 +50,7 @@ func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *needle.Needle, offset in
|
|||
if err != nil {
|
||||
glog.Fatalf("Write New Volume Data %v", err)
|
||||
}
|
||||
scanner.datBackend = backend.NewDiskFile(newFileName, newDatFile)
|
||||
scanner.datBackend = backend.NewDiskFile(newDatFile)
|
||||
scanner.datBackend.WriteAt(scanner.block.Bytes(), 0)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ type DiskFile struct {
|
|||
fullFilePath string
|
||||
}
|
||||
|
||||
func NewDiskFile(fullFilePath string, f *os.File) *DiskFile {
|
||||
func NewDiskFile(f *os.File) *DiskFile {
|
||||
return &DiskFile{
|
||||
fullFilePath: fullFilePath,
|
||||
fullFilePath: f.Name(),
|
||||
File: f,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestAppend(t *testing.T) {
|
|||
os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
datBackend := backend.NewDiskFile(tempFile.Name(), tempFile)
|
||||
datBackend := backend.NewDiskFile(tempFile)
|
||||
defer datBackend.Close()
|
||||
|
||||
offset, _, _, _ := n.Append(datBackend, CurrentVersion)
|
||||
|
|
|
@ -50,7 +50,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||
return fmt.Errorf("Volume Data file %s.dat does not exist.", fileName)
|
||||
}
|
||||
}
|
||||
v.DataBackend = backend.NewDiskFile(fileName+".dat", dataFile)
|
||||
v.DataBackend = backend.NewDiskFile(dataFile)
|
||||
|
||||
if e != nil {
|
||||
if !os.IsPermission(e) {
|
||||
|
|
|
@ -98,7 +98,7 @@ func (v *Volume) maybeWriteSuperBlock() error {
|
|||
//read-only, but zero length - recreate it!
|
||||
var dataFile *os.File
|
||||
if dataFile, e = os.Create(v.DataBackend.String()); e == nil {
|
||||
v.DataBackend = backend.NewDiskFile(v.DataBackend.String(), dataFile)
|
||||
v.DataBackend = backend.NewDiskFile(dataFile)
|
||||
if _, e = v.DataBackend.WriteAt(v.SuperBlock.Bytes(), 0); e == nil {
|
||||
v.readOnly = false
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
|
|||
defer oldIdxFile.Close()
|
||||
|
||||
oldDatFile, err := os.Open(oldDatFileName)
|
||||
oldDatBackend := backend.NewDiskFile(oldDatFileName, oldDatFile)
|
||||
oldDatBackend := backend.NewDiskFile(oldDatFile)
|
||||
defer oldDatBackend.Close()
|
||||
|
||||
if indexSize, err = verifyIndexFileIntegrity(oldIdxFile); err != nil {
|
||||
|
@ -198,7 +198,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
|
|||
if dst, err = os.OpenFile(newDatFileName, os.O_RDWR, 0644); err != nil {
|
||||
return fmt.Errorf("open dat file %s failed: %v", newDatFileName, err)
|
||||
}
|
||||
dstDatBackend := backend.NewDiskFile(newDatFileName, dst)
|
||||
dstDatBackend := backend.NewDiskFile(dst)
|
||||
defer dstDatBackend.Close()
|
||||
|
||||
if idx, err = os.OpenFile(newIdxFileName, os.O_RDWR, 0644); err != nil {
|
||||
|
@ -328,7 +328,7 @@ func (v *Volume) copyDataAndGenerateIndexFile(dstName, idxName string, prealloca
|
|||
v: v,
|
||||
now: uint64(time.Now().Unix()),
|
||||
nm: NewBtreeNeedleMap(idx),
|
||||
dstBackend: backend.NewDiskFile(dstName, dst),
|
||||
dstBackend: backend.NewDiskFile(dst),
|
||||
writeThrottler: util.NewWriteThrottler(compactionBytePerSecond),
|
||||
}
|
||||
err = ScanVolumeFile(v.dir, v.Collection, v.Id, v.needleMapKind, scanner)
|
||||
|
@ -342,7 +342,7 @@ func (v *Volume) copyDataBasedOnIndexFile(dstName, idxName string) (err error) {
|
|||
if dst, err = os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||
return
|
||||
}
|
||||
dstDatBackend := backend.NewDiskFile(dstName, dst)
|
||||
dstDatBackend := backend.NewDiskFile(dst)
|
||||
defer dstDatBackend.Close()
|
||||
|
||||
if idx, err = os.OpenFile(idxName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||
|
|
Loading…
Reference in a new issue