mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
libs/db: Add cleveldb.Stats() (#3379)
Fixes: #3378 * Add stats to cleveldb implementation * update changelog * remote TODO also - sort keys - preallocate memory * fix const initializer []string literal is not a constant * add test
This commit is contained in:
committed by
Anton Kaliaev
parent
52771e1287
commit
8c9df30e28
@@ -128,10 +128,18 @@ func (db *CLevelDB) Print() {
|
||||
|
||||
// Implements DB.
|
||||
func (db *CLevelDB) Stats() map[string]string {
|
||||
// TODO: Find the available properties for the C LevelDB implementation
|
||||
keys := []string{}
|
||||
keys := []string{
|
||||
"leveldb.aliveiters",
|
||||
"leveldb.alivesnaps",
|
||||
"leveldb.blockpool",
|
||||
"leveldb.cachedblock",
|
||||
"leveldb.num-files-at-level{n}",
|
||||
"leveldb.openedtables",
|
||||
"leveldb.sstables",
|
||||
"leveldb.stats",
|
||||
}
|
||||
|
||||
stats := make(map[string]string)
|
||||
stats := make(map[string]string, len(keys))
|
||||
for _, key := range keys {
|
||||
str := db.db.PropertyValue(key)
|
||||
stats[key] = str
|
||||
|
||||
@@ -99,3 +99,12 @@ func TestCLevelDBBackend(t *testing.T) {
|
||||
_, ok := db.(*CLevelDB)
|
||||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
func TestCLevelDBStats(t *testing.T) {
|
||||
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
|
||||
dir := os.TempDir()
|
||||
db := NewDB(name, LevelDBBackend, dir)
|
||||
defer cleanupDBDir(dir, name)
|
||||
|
||||
assert.NotEmpty(t, db.Stats())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user