Browse Source
refactor(storage): readability improvements (#3703)
Signed-off-by: Ryan Russell <git@ryanrussell.org>
Signed-off-by: Ryan Russell <git@ryanrussell.org>
pull/3707/head
Ryan Russell
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with
9 additions and
9 deletions
-
weed/storage/backend/memory_map/memory_map_windows.go
-
weed/storage/needle/file_id_test.go
-
weed/storage/needle/needle_parse_upload.go
-
weed/storage/needle/needle_write.go
-
weed/storage/store.go
-
weed/storage/store_ec.go
-
weed/storage/store_vacuum.go
-
weed/storage/volume_vacuum.go
-
weed/storage/volume_write.go
|
@ -153,7 +153,7 @@ func allocate(hMapFile windows.Handle, offset uint64, length uint64, write bool) |
|
|
|
|
|
|
|
|
mBuffer := MemoryBuffer{} |
|
|
mBuffer := MemoryBuffer{} |
|
|
|
|
|
|
|
|
//align memory allocations to the minium virtal memory allocation size
|
|
|
|
|
|
|
|
|
//align memory allocations to the minium virtual memory allocation size
|
|
|
dwSysGran := systemInfo.dwAllocationGranularity |
|
|
dwSysGran := systemInfo.dwAllocationGranularity |
|
|
|
|
|
|
|
|
start := (offset / uint64(dwSysGran)) * uint64(dwSysGran) |
|
|
start := (offset / uint64(dwSysGran)) * uint64(dwSysGran) |
|
|
|
@ -15,7 +15,7 @@ func TestParseFileIdFromString(t *testing.T) { |
|
|
fidStr1 = "100, 12345678" |
|
|
fidStr1 = "100, 12345678" |
|
|
_, err = ParseFileIdFromString(fidStr1) |
|
|
_, err = ParseFileIdFromString(fidStr1) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
t.Errorf("%s : needlId invalid syntax", fidStr1) |
|
|
|
|
|
|
|
|
t.Errorf("%s : needleId invalid syntax", fidStr1) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fidStr1 = "100,123456789" |
|
|
fidStr1 = "100,123456789" |
|
|
|
@ -195,7 +195,7 @@ func parseMultipart(r *http.Request, sizeLimit int64, pu *ParsedUpload) (e error |
|
|
} |
|
|
} |
|
|
contentType := part.Header.Get("Content-Type") |
|
|
contentType := part.Header.Get("Content-Type") |
|
|
if contentType != "" && contentType != "application/octet-stream" && mtype != contentType { |
|
|
if contentType != "" && contentType != "application/octet-stream" && mtype != contentType { |
|
|
pu.MimeType = contentType // only return mime type if not deductable
|
|
|
|
|
|
|
|
|
pu.MimeType = contentType // only return mime type if not deducible
|
|
|
mtype = contentType |
|
|
mtype = contentType |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -128,7 +128,7 @@ func (n *Needle) Append(w backend.BackendStorageFile, version Version) (offset u |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if offset >= MaxPossibleVolumeSize && n.Size.IsValid() { |
|
|
if offset >= MaxPossibleVolumeSize && n.Size.IsValid() { |
|
|
err = fmt.Errorf("Volume Size %d Exeededs %d", offset, MaxPossibleVolumeSize) |
|
|
|
|
|
|
|
|
err = fmt.Errorf("Volume Size %d Exceeded %d", offset, MaxPossibleVolumeSize) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -62,7 +62,7 @@ type Store struct { |
|
|
GrpcPort int |
|
|
GrpcPort int |
|
|
PublicUrl string |
|
|
PublicUrl string |
|
|
Locations []*DiskLocation |
|
|
Locations []*DiskLocation |
|
|
dataCenter string // optional informaton, overwriting master setting if exists
|
|
|
|
|
|
|
|
|
dataCenter string // optional information, overwriting master setting if exists
|
|
|
rack string // optional information, overwriting master setting if exists
|
|
|
rack string // optional information, overwriting master setting if exists
|
|
|
connected bool |
|
|
connected bool |
|
|
NeedleMapKind NeedleMapKind |
|
|
NeedleMapKind NeedleMapKind |
|
|
|
@ -339,7 +339,7 @@ func (s *Store) recoverOneRemoteEcShardInterval(needleId types.NeedleId, ecVolum |
|
|
ecVolume.ShardLocationsLock.RLock() |
|
|
ecVolume.ShardLocationsLock.RLock() |
|
|
for shardId, locations := range ecVolume.ShardLocations { |
|
|
for shardId, locations := range ecVolume.ShardLocations { |
|
|
|
|
|
|
|
|
// skip currnent shard or empty shard
|
|
|
|
|
|
|
|
|
// skip current shard or empty shard
|
|
|
if shardId == shardIdToRecover { |
|
|
if shardId == shardIdToRecover { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
|
@ -10,7 +10,7 @@ import ( |
|
|
|
|
|
|
|
|
func (s *Store) CheckCompactVolume(volumeId needle.VolumeId) (float64, error) { |
|
|
func (s *Store) CheckCompactVolume(volumeId needle.VolumeId) (float64, error) { |
|
|
if v := s.findVolume(volumeId); v != nil { |
|
|
if v := s.findVolume(volumeId); v != nil { |
|
|
glog.V(3).Infof("volumd %d garbage level: %f", volumeId, v.garbageLevel()) |
|
|
|
|
|
|
|
|
glog.V(3).Infof("volume %d garbage level: %f", volumeId, v.garbageLevel()) |
|
|
return v.garbageLevel(), nil |
|
|
return v.garbageLevel(), nil |
|
|
} |
|
|
} |
|
|
return 0, fmt.Errorf("volume id %d is not found during check compact", volumeId) |
|
|
return 0, fmt.Errorf("volume id %d is not found during check compact", volumeId) |
|
|
|
@ -167,7 +167,7 @@ func (v *Volume) CommitCompact() error { |
|
|
if e = v.load(true, false, v.needleMapKind, 0); e != nil { |
|
|
if e = v.load(true, false, v.needleMapKind, 0); e != nil { |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
glog.V(3).Infof("Finish commiting volume %d", v.Id) |
|
|
|
|
|
|
|
|
glog.V(3).Infof("Finish committing volume %d", v.Id) |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -81,7 +81,7 @@ func removeVolumeFiles(filename string) { |
|
|
// compaction
|
|
|
// compaction
|
|
|
os.Remove(filename + ".cpd") |
|
|
os.Remove(filename + ".cpd") |
|
|
os.Remove(filename + ".cpx") |
|
|
os.Remove(filename + ".cpx") |
|
|
// level db indx file
|
|
|
|
|
|
|
|
|
// level db index file
|
|
|
os.RemoveAll(filename + ".ldb") |
|
|
os.RemoveAll(filename + ".ldb") |
|
|
// marker for damaged or incomplete volume
|
|
|
// marker for damaged or incomplete volume
|
|
|
os.Remove(filename + ".note") |
|
|
os.Remove(filename + ".note") |
|
|