aboutsummaryrefslogtreecommitdiff
path: root/weed/util/chunk_cache
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-05-22 09:54:31 -0700
committerchrislu <chris.lu@gmail.com>2025-05-22 09:54:31 -0700
commit0d62be44846354c3c37b857028297edd4b8df17b (patch)
treec89320a7d58351030f1b740c7267f56bf0206429 /weed/util/chunk_cache
parentd8c574a5ef1a811f9a0d447097d9edfcc0c1d84c (diff)
downloadseaweedfs-origin/changing-to-zap.tar.xz
seaweedfs-origin/changing-to-zap.zip
Diffstat (limited to 'weed/util/chunk_cache')
-rw-r--r--weed/util/chunk_cache/chunk_cache.go18
-rw-r--r--weed/util/chunk_cache/chunk_cache_on_disk.go8
-rw-r--r--weed/util/chunk_cache/on_disk_cache_layer.go14
3 files changed, 20 insertions, 20 deletions
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go
index 7eee41b9b..b0affbcd4 100644
--- a/weed/util/chunk_cache/chunk_cache.go
+++ b/weed/util/chunk_cache/chunk_cache.go
@@ -4,7 +4,7 @@ import (
"errors"
"sync"
- "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/util/log"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
)
@@ -66,13 +66,13 @@ func (c *TieredChunkCache) IsInCache(fileId string, lockNeeded bool) (answer boo
item := c.memCache.cache.Get(fileId)
if item != nil {
- glog.V(4).Infof("fileId %s is in memcache", fileId)
+ log.V(-1).Infof("fileId %s is in memcache", fileId)
return true
}
fid, err := needle.ParseFileIdFromString(fileId)
if err != nil {
- glog.V(4).Infof("failed to parse file id %s", fileId)
+ log.V(-1).Infof("failed to parse file id %s", fileId)
return false
}
@@ -80,7 +80,7 @@ func (c *TieredChunkCache) IsInCache(fileId string, lockNeeded bool) (answer boo
for k, v := range diskCacheLayer.diskCaches {
_, ok := v.nm.Get(fid.Key)
if ok {
- glog.V(4).Infof("fileId %s is in diskCaches[%d].volume[%d]", fileId, i, k)
+ log.V(-1).Infof("fileId %s is in diskCaches[%d].volume[%d]", fileId, i, k)
return true
}
}
@@ -100,7 +100,7 @@ func (c *TieredChunkCache) ReadChunkAt(data []byte, fileId string, offset uint64
if minSize <= c.onDiskCacheSizeLimit0 {
n, err = c.memCache.readChunkAt(data, fileId, offset)
if err != nil {
- glog.Errorf("failed to read from memcache: %s", err)
+ log.Errorf("failed to read from memcache: %s", err)
}
if n == int(len(data)) {
return n, nil
@@ -109,7 +109,7 @@ func (c *TieredChunkCache) ReadChunkAt(data []byte, fileId string, offset uint64
fid, err := needle.ParseFileIdFromString(fileId)
if err != nil {
- glog.Errorf("failed to parse file id %s", fileId)
+ log.Errorf("failed to parse file id %s", fileId)
return 0, nil
}
@@ -143,9 +143,9 @@ func (c *TieredChunkCache) SetChunk(fileId string, data []byte) {
c.Lock()
defer c.Unlock()
- glog.V(4).Infof("SetChunk %s size %d\n", fileId, len(data))
+ log.V(-1).Infof("SetChunk %s size %d\n", fileId, len(data))
if c.IsInCache(fileId, false) {
- glog.V(4).Infof("fileId %s is already in cache", fileId)
+ log.V(-1).Infof("fileId %s is already in cache", fileId)
return
}
@@ -160,7 +160,7 @@ func (c *TieredChunkCache) doSetChunk(fileId string, data []byte) {
fid, err := needle.ParseFileIdFromString(fileId)
if err != nil {
- glog.Errorf("failed to parse file id %s", fileId)
+ log.Errorf("failed to parse file id %s", fileId)
return
}
diff --git a/weed/util/chunk_cache/chunk_cache_on_disk.go b/weed/util/chunk_cache/chunk_cache_on_disk.go
index 87f05d399..c67e51f27 100644
--- a/weed/util/chunk_cache/chunk_cache_on_disk.go
+++ b/weed/util/chunk_cache/chunk_cache_on_disk.go
@@ -7,7 +7,7 @@ import (
"github.com/syndtr/goleveldb/leveldb/opt"
- "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/util/log"
"github.com/seaweedfs/seaweedfs/weed/storage"
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
@@ -63,7 +63,7 @@ func LoadOrCreateChunkCacheVolume(fileName string, preallocate int64) (*ChunkCac
return nil, fmt.Errorf("cannot write cache index %s.idx: %v", v.fileName, err)
}
- glog.V(1).Infoln("loading leveldb", v.fileName+".ldb")
+ log.V(2).Infoln("loading leveldb", v.fileName+".ldb")
opts := &opt.Options{
BlockCacheCapacity: 2 * 1024 * 1024, // default value is 8MiB
WriteBuffer: 1 * 1024 * 1024, // default value is 4MiB
@@ -92,9 +92,9 @@ func (v *ChunkCacheVolume) doReset() {
v.Shutdown()
os.Truncate(v.fileName+".dat", 0)
os.Truncate(v.fileName+".idx", 0)
- glog.V(4).Infof("cache removeAll %s ...", v.fileName+".ldb")
+ log.V(-1).Infof("cache removeAll %s ...", v.fileName+".ldb")
os.RemoveAll(v.fileName + ".ldb")
- glog.V(4).Infof("cache removed %s", v.fileName+".ldb")
+ log.V(-1).Infof("cache removed %s", v.fileName+".ldb")
}
func (v *ChunkCacheVolume) Reset() (*ChunkCacheVolume, error) {
diff --git a/weed/util/chunk_cache/on_disk_cache_layer.go b/weed/util/chunk_cache/on_disk_cache_layer.go
index fdbaef7c2..af1d79b42 100644
--- a/weed/util/chunk_cache/on_disk_cache_layer.go
+++ b/weed/util/chunk_cache/on_disk_cache_layer.go
@@ -2,7 +2,7 @@ package chunk_cache
import (
"fmt"
- "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/util/log"
"github.com/seaweedfs/seaweedfs/weed/storage"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"path"
@@ -25,7 +25,7 @@ func NewOnDiskCacheLayer(dir, namePrefix string, diskSize int64, segmentCount in
fileName := path.Join(dir, fmt.Sprintf("%s_%d", namePrefix, i))
diskCache, err := LoadOrCreateChunkCacheVolume(fileName, volumeSize)
if err != nil {
- glog.Errorf("failed to add cache %s : %v", fileName, err)
+ log.Errorf("failed to add cache %s : %v", fileName, err)
} else {
c.diskCaches = append(c.diskCaches, diskCache)
}
@@ -47,7 +47,7 @@ func (c *OnDiskCacheLayer) setChunk(needleId types.NeedleId, data []byte) {
if c.diskCaches[0].fileSize+int64(len(data)) > c.diskCaches[0].sizeLimit {
t, resetErr := c.diskCaches[len(c.diskCaches)-1].Reset()
if resetErr != nil {
- glog.Errorf("failed to reset cache file %s", c.diskCaches[len(c.diskCaches)-1].fileName)
+ log.Errorf("failed to reset cache file %s", c.diskCaches[len(c.diskCaches)-1].fileName)
return
}
for i := len(c.diskCaches) - 1; i > 0; i-- {
@@ -57,7 +57,7 @@ func (c *OnDiskCacheLayer) setChunk(needleId types.NeedleId, data []byte) {
}
if err := c.diskCaches[0].WriteNeedle(needleId, data); err != nil {
- glog.V(0).Infof("cache write %v size %d: %v", needleId, len(data), err)
+ log.V(3).Infof("cache write %v size %d: %v", needleId, len(data), err)
}
}
@@ -72,7 +72,7 @@ func (c *OnDiskCacheLayer) getChunk(needleId types.NeedleId) (data []byte) {
continue
}
if err != nil {
- glog.Errorf("failed to read cache file %s id %d", diskCache.fileName, needleId)
+ log.Errorf("failed to read cache file %s id %d", diskCache.fileName, needleId)
continue
}
if len(data) != 0 {
@@ -94,7 +94,7 @@ func (c *OnDiskCacheLayer) getChunkSlice(needleId types.NeedleId, offset, length
continue
}
if err != nil {
- glog.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
+ log.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
continue
}
if len(data) != 0 {
@@ -114,7 +114,7 @@ func (c *OnDiskCacheLayer) readChunkAt(buffer []byte, needleId types.NeedleId, o
continue
}
if err != nil {
- glog.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
+ log.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
continue
}
if n > 0 {