mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add a debug capability to list all metadata keys
This commit is contained in:
parent
1a7d5b5b5e
commit
10ecf80ca1
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -45,3 +46,7 @@ type BucketAware interface {
|
||||||
OnBucketDeletion(bucket string)
|
OnBucketDeletion(bucket string)
|
||||||
CanDropWholeBucket() bool
|
CanDropWholeBucket() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Debuggable interface {
|
||||||
|
Debug(writer io.Writer)
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/viant/ptrie"
|
"github.com/viant/ptrie"
|
||||||
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -15,6 +16,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ = VirtualFilerStore(&FilerStoreWrapper{})
|
_ = VirtualFilerStore(&FilerStoreWrapper{})
|
||||||
|
_ = Debuggable(&FilerStoreWrapper{})
|
||||||
)
|
)
|
||||||
|
|
||||||
type VirtualFilerStore interface {
|
type VirtualFilerStore interface {
|
||||||
|
@ -333,3 +335,9 @@ func (fsw *FilerStoreWrapper) KvGet(ctx context.Context, key []byte) (value []by
|
||||||
func (fsw *FilerStoreWrapper) KvDelete(ctx context.Context, key []byte) (err error) {
|
func (fsw *FilerStoreWrapper) KvDelete(ctx context.Context, key []byte) (err error) {
|
||||||
return fsw.getDefaultStore().KvDelete(ctx, key)
|
return fsw.getDefaultStore().KvDelete(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fsw *FilerStoreWrapper) Debug(writer io.Writer) {
|
||||||
|
if debuggable, ok := fsw.getDefaultStore().(Debuggable); ok {
|
||||||
|
debuggable.Debug(writer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/syndtr/goleveldb/leveldb/filter"
|
"github.com/syndtr/goleveldb/leveldb/filter"
|
||||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||||
leveldb_util "github.com/syndtr/goleveldb/leveldb/util"
|
leveldb_util "github.com/syndtr/goleveldb/leveldb/util"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
@ -21,6 +22,10 @@ const (
|
||||||
DIR_FILE_SEPARATOR = byte(0x00)
|
DIR_FILE_SEPARATOR = byte(0x00)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = filer.Debuggable(&LevelDBStore{})
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
filer.Stores = append(filer.Stores, &LevelDBStore{})
|
filer.Stores = append(filer.Stores, &LevelDBStore{})
|
||||||
}
|
}
|
||||||
|
@ -242,3 +247,13 @@ func getNameFromKey(key []byte) string {
|
||||||
func (store *LevelDBStore) Shutdown() {
|
func (store *LevelDBStore) Shutdown() {
|
||||||
store.db.Close()
|
store.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (store *LevelDBStore) Debug(writer io.Writer) {
|
||||||
|
iter := store.db.NewIterator(&leveldb_util.Range{}, nil)
|
||||||
|
for iter.Next() {
|
||||||
|
key := iter.Key()
|
||||||
|
fullName := bytes.Replace(key, []byte{DIR_FILE_SEPARATOR}, []byte{' '}, 1)
|
||||||
|
fmt.Fprintf(writer, "%v\n", string(fullName))
|
||||||
|
}
|
||||||
|
iter.Release()
|
||||||
|
}
|
||||||
|
|
|
@ -144,3 +144,10 @@ func (mc *MetaCache) Shutdown() {
|
||||||
func (mc *MetaCache) mapIdFromFilerToLocal(entry *filer.Entry) {
|
func (mc *MetaCache) mapIdFromFilerToLocal(entry *filer.Entry) {
|
||||||
entry.Attr.Uid, entry.Attr.Gid = mc.uidGidMapper.FilerToLocal(entry.Attr.Uid, entry.Attr.Gid)
|
entry.Attr.Uid, entry.Attr.Gid = mc.uidGidMapper.FilerToLocal(entry.Attr.Uid, entry.Attr.Gid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) Debug() {
|
||||||
|
if debuggable, ok := mc.localStore.(filer.Debuggable); ok {
|
||||||
|
println("start debugging")
|
||||||
|
debuggable.Debug(os.Stderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue