Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

refactor(exclusive_locker): `Interval` readability batch of updates (#3668)

Ryan Russell72d8a9f9a8cd
diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go
index 3a70e4fa3f..8807e3e570 100644
--- a/weed/filer/filechunk_manifest.go
+++ b/weed/filer/filechunk_manifest.go
@@ -169,19 +169,19 @@ func retriedStreamFetchChunkData(writer io.Writer, urlStrings []string, cipherKe
for waitTime := time.Second; waitTime < util.RetryWaitTime; waitTime += waitTime / 2 {
for _, urlString := range urlStrings {
- var localProcesed int
+ var localProcessed int
shouldRetry, err = util.ReadUrlAsStream(urlString+"?readDeleted=true", cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) {
- if totalWritten > localProcesed {
- toBeSkipped := totalWritten - localProcesed
+ if totalWritten > localProcessed {
+ toBeSkipped := totalWritten - localProcessed
if len(data) <= toBeSkipped {
- localProcesed += len(data)
+ localProcessed += len(data)
return // skip if already processed
}
data = data[toBeSkipped:]
- localProcesed += toBeSkipped
+ localProcessed += toBeSkipped
}
writer.Write(data)
- localProcesed += len(data)
+ localProcessed += len(data)
totalWritten += len(data)
})
if !shouldRetry {
diff --git a/weed/mount/dirty_pages_chunked.go b/weed/mount/dirty_pages_chunked.go
index 59a4e7874c..9cc17e2f45 100644
--- a/weed/mount/dirty_pages_chunked.go
+++ b/weed/mount/dirty_pages_chunked.go
@@ -33,7 +33,7 @@ func newMemoryChunkPages(fh *FileHandle, chunkSize int64) *ChunkedDirtyPages {
swapFileDir := fh.wfs.option.getTempFilePageDir()
dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.wfs.concurrentWriters, chunkSize,
- dirtyPages.saveChunkedFileIntevalToStorage, fh.wfs.option.ConcurrentWriters, swapFileDir)
+ dirtyPages.saveChunkedFileIntervalToStorage, fh.wfs.option.ConcurrentWriters, swapFileDir)
return dirtyPages
}
@@ -65,7 +65,7 @@ func (pages *ChunkedDirtyPages) ReadDirtyDataAt(data []byte, startOffset int64)
return pages.uploadPipeline.MaybeReadDataAt(data, startOffset)
}
-func (pages *ChunkedDirtyPages) saveChunkedFileIntevalToStorage(reader io.Reader, offset int64, size int64, cleanupFn func()) {
+func (pages *ChunkedDirtyPages) saveChunkedFileIntervalToStorage(reader io.Reader, offset int64, size int64, cleanupFn func()) {
mtime := time.Now().UnixNano()
defer cleanupFn()
diff --git a/weed/wdclient/exclusive_locks/exclusive_locker.go b/weed/wdclient/exclusive_locks/exclusive_locker.go
index 291d4cf992..03112cb08d 100644
--- a/weed/wdclient/exclusive_locks/exclusive_locker.go
+++ b/weed/wdclient/exclusive_locks/exclusive_locker.go
@@ -11,9 +11,9 @@ import (
)
const (
- RenewInteval = 4 * time.Second
- SafeRenewInteval = 3 * time.Second
- InitLockInteval = 1 * time.Second
+ RenewInterval = 4 * time.Second
+ SafeRenewInterval = 3 * time.Second
+ InitLockInterval = 1 * time.Second
)
type ExclusiveLocker struct {
@@ -37,7 +37,7 @@ func (l *ExclusiveLocker) IsLocked() bool {
}
func (l *ExclusiveLocker) GetToken() (token int64, lockTsNs int64) {
- for time.Unix(0, atomic.LoadInt64(&l.lockTsNs)).Add(SafeRenewInteval).Before(time.Now()) {
+ for time.Unix(0, atomic.LoadInt64(&l.lockTsNs)).Add(SafeRenewInterval).Before(time.Now()) {
// wait until now is within the safe lock period, no immediate renewal to change the token
time.Sleep(100 * time.Millisecond)
}
@@ -68,7 +68,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
return err
}); err != nil {
println("lock:", err.Error())
- time.Sleep(InitLockInteval)
+ time.Sleep(InitLockInterval)
} else {
break
}
@@ -101,7 +101,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
l.isLocked = false
return
} else {
- time.Sleep(RenewInteval)
+ time.Sleep(RenewInterval)
}
}