aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Russell <ryanrussell@users.noreply.github.com>2022-09-14 12:29:55 -0500
committerGitHub <noreply@github.com>2022-09-14 10:29:55 -0700
commit72d8a9f9a8cdf2b55f45065753f2680c48694eda (patch)
tree0d314d73e503ffe14669863a8001e3973ccfbdfb
parente22335ba78403585cb094aadb2ece2eba3610543 (diff)
downloadseaweedfs-72d8a9f9a8cdf2b55f45065753f2680c48694eda.tar.xz
seaweedfs-72d8a9f9a8cdf2b55f45065753f2680c48694eda.zip
refactor(exclusive_locker): `Interval` readability batch of updates (#3668)
* refactor(filechunk_manifest): `localProcesed` -> `localProcessed` Signed-off-by: Ryan Russell <git@ryanrussell.org> * refactor: `saveChunkedFileIntevalToStorage` -> `saveChunkedFileIntervalToStorage` Signed-off-by: Ryan Russell <git@ryanrussell.org> * refactor: `SafeRenewInteval` -> `SafeRenewInterval` Signed-off-by: Ryan Russell <git@ryanrussell.org> * refactor: `InitLockInteval` -> `InitLockInterval` Signed-off-by: Ryan Russell <git@ryanrussell.org> * refactor: `RenewInteval` -> `RenewInterval` Signed-off-by: Ryan Russell <git@ryanrussell.org> Signed-off-by: Ryan Russell <git@ryanrussell.org>
-rw-r--r--weed/filer/filechunk_manifest.go12
-rw-r--r--weed/mount/dirty_pages_chunked.go4
-rw-r--r--weed/wdclient/exclusive_locks/exclusive_locker.go12
3 files changed, 14 insertions, 14 deletions
diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go
index 3a70e4fa3..8807e3e57 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 59a4e7874..9cc17e2f4 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 291d4cf99..03112cb08 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)
}
}