Skip to content

Commit

Permalink
Add rocksdb config parameters to core.yaml [FAB-349]
Browse files Browse the repository at this point in the history
Change-Id: I93ac3badea5ff6a3abf4c32af26468f6006f70cc
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Sep 27, 2016
1 parent f28d3d6 commit 38ef435
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 26 additions & 0 deletions core/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import (
)

var dbLogger = logging.MustGetLogger("db")
var rocksDBLogLevelMap = map[string]gorocksdb.InfoLogLevel{
"debug": gorocksdb.DebugInfoLogLevel,
"info": gorocksdb.InfoInfoLogLevel,
"warn": gorocksdb.WarnInfoLogLevel,
"error": gorocksdb.ErrorInfoLogLevel,
"fatal": gorocksdb.FatalInfoLogLevel}

const blockchainCF = "blockchainCF"
const stateCF = "stateCF"
Expand Down Expand Up @@ -159,6 +165,26 @@ func (openchainDB *OpenchainDB) open() {
opts := gorocksdb.NewDefaultOptions()
defer opts.Destroy()

maxLogFileSize := viper.GetInt("peer.db.maxLogFileSize")
if maxLogFileSize > 0 {
dbLogger.Infof("Setting rocksdb maxLogFileSize to %d", maxLogFileSize)
opts.SetMaxLogFileSize(maxLogFileSize)
}

keepLogFileNum := viper.GetInt("peer.db.keepLogFileNum")
if keepLogFileNum > 0 {
dbLogger.Infof("Setting rocksdb keepLogFileNum to %d", keepLogFileNum)
opts.SetKeepLogFileNum(keepLogFileNum)
}

logLevelStr := viper.GetString("peer.db.loglevel")
logLevel, ok := rocksDBLogLevelMap[logLevelStr]

if ok {
dbLogger.Infof("Setting rocks db InfoLogLevel to %d", logLevel)
opts.SetInfoLogLevel(logLevel)
}

opts.SetCreateIfMissing(missing)
opts.SetCreateIfMissingColumnFamilies(true)

Expand Down
6 changes: 5 additions & 1 deletion peer/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ peer:

# Path on the file system where peer will store data
fileSystemPath: /var/hyperledger/production

# rocksdb configurations
db:
maxLogFileSize: 10485760
keepLogFileNum: 10
logLevel: "warn"

profile:
enabled: false
Expand Down

0 comments on commit 38ef435

Please sign in to comment.