Merge branch 'develop' into rpl-feature

This commit is contained in:
siddontang 2014-10-31 20:34:51 +08:00
commit 0f2dcfe783
5 changed files with 32 additions and 18 deletions

View File

@ -113,7 +113,7 @@ type Config struct {
ConnReadBufferSize int `toml:"conn_read_buffer_size"` ConnReadBufferSize int `toml:"conn_read_buffer_size"`
ConnWriteBufferSize int `toml:"conn_write_buffer_size"` ConnWriteBufferSize int `toml:"conn_write_buffer_size"`
ConnKeepaliveInterval int `toml:"conn_keepavlie_interval"` ConnKeepaliveInterval int `toml:"conn_keepalive_interval"`
TTLCheckInterval int `toml:"ttl_check_interval"` TTLCheckInterval int `toml:"ttl_check_interval"`
} }

View File

@ -50,7 +50,7 @@ conn_write_buffer_size = 10240
# if connection receives no data after n seconds, it may be dead, close # if connection receives no data after n seconds, it may be dead, close
# 0 to disable and not check # 0 to disable and not check
conn_keepavlie_interval = 0 conn_keepalive_interval = 0
# checking TTL (time to live) data every n seconds # checking TTL (time to live) data every n seconds
# if you set big, the expired data may not be deleted immediately # if you set big, the expired data may not be deleted immediately

View File

@ -50,7 +50,7 @@ conn_write_buffer_size = 10240
# if connection receives no data after n seconds, it may be dead, close # if connection receives no data after n seconds, it may be dead, close
# 0 to disable and not check # 0 to disable and not check
conn_keepavlie_interval = 0 conn_keepalive_interval = 0
# checking TTL (time to live) data every n seconds # checking TTL (time to live) data every n seconds
# if you set big, the expired data may not be deleted immediately # if you set big, the expired data may not be deleted immediately

View File

@ -173,31 +173,33 @@ func (i *info) dumpStore(buf *bytes.Buffer) {
s := i.app.ldb.StoreStat() s := i.app.ldb.StoreStat()
getNum := s.GetNum.Get() // getNum := s.GetNum.Get()
getTotalTime := s.GetTotalTime.Get() // getTotalTime := s.GetTotalTime.Get()
gt := int64(0) // gt := int64(0)
if getNum > 0 { // if getNum > 0 {
gt = getTotalTime.Nanoseconds() / (getNum * 1e3) // gt = getTotalTime.Nanoseconds() / (getNum * 1e3)
} // }
commitNum := s.BatchCommitNum.Get() // commitNum := s.BatchCommitNum.Get()
commitTotalTime := s.BatchCommitTotalTime.Get() // commitTotalTime := s.BatchCommitTotalTime.Get()
ct := int64(0) // ct := int64(0)
if commitNum > 0 { // if commitNum > 0 {
ct = commitTotalTime.Nanoseconds() / (commitNum * 1e3) // ct = commitTotalTime.Nanoseconds() / (commitNum * 1e3)
} // }
i.dumpPairs(buf, infoPair{"name", i.app.cfg.DBName}, i.dumpPairs(buf, infoPair{"name", i.app.cfg.DBName},
infoPair{"get", s.GetNum}, infoPair{"get", s.GetNum},
infoPair{"get_missing", s.GetMissingNum}, infoPair{"get_missing", s.GetMissingNum},
infoPair{"get_per_time", fmt.Sprintf("%0.002fms", float64(gt)/1000.0)}, infoPair{"put", s.PutNum},
infoPair{"delete", s.DeleteNum},
infoPair{"get_total_time", s.GetTotalTime.Get().String()},
infoPair{"iter", s.IterNum}, infoPair{"iter", s.IterNum},
infoPair{"iter_seek", s.IterSeekNum}, infoPair{"iter_seek", s.IterSeekNum},
infoPair{"iter_close", s.IterCloseNum}, infoPair{"iter_close", s.IterCloseNum},
infoPair{"batch_commit", s.BatchCommitNum}, infoPair{"batch_commit", s.BatchCommitNum},
infoPair{"batch_commit_per_time", fmt.Sprintf("%0.002fms", float64(ct)/1000.0)}, infoPair{"batch_commit_total_time", s.BatchCommitTotalTime.Get().String()},
) )
} }

View File

@ -9,19 +9,28 @@ type WriteBatch struct {
wb driver.IWriteBatch wb driver.IWriteBatch
st *Stat st *Stat
putNum int64
deleteNum int64
db *DB db *DB
} }
func (wb *WriteBatch) Put(key []byte, value []byte) { func (wb *WriteBatch) Put(key []byte, value []byte) {
wb.putNum++
wb.wb.Put(key, value) wb.wb.Put(key, value)
} }
func (wb *WriteBatch) Delete(key []byte) { func (wb *WriteBatch) Delete(key []byte) {
wb.deleteNum++
wb.wb.Delete(key) wb.wb.Delete(key)
} }
func (wb *WriteBatch) Commit() error { func (wb *WriteBatch) Commit() error {
wb.st.BatchCommitNum.Add(1) wb.st.BatchCommitNum.Add(1)
wb.st.PutNum.Add(wb.putNum)
wb.st.DeleteNum.Add(wb.deleteNum)
wb.putNum = 0
wb.deleteNum = 0
var err error var err error
t := time.Now() t := time.Now()
if wb.db == nil || !wb.db.needSyncCommit() { if wb.db == nil || !wb.db.needSyncCommit() {
@ -36,5 +45,8 @@ func (wb *WriteBatch) Commit() error {
} }
func (wb *WriteBatch) Rollback() error { func (wb *WriteBatch) Rollback() error {
wb.putNum = 0
wb.deleteNum = 0
return wb.wb.Rollback() return wb.wb.Rollback()
} }