Merge pull request #420 from steveyen/MB-20590
index/store/moss KV backend propagates mossStore's Stats()
This commit is contained in:
commit
f531835d5c
|
@ -32,7 +32,7 @@ func initLowerLevelStore(
|
||||||
lowerLevelStoreConfig map[string]interface{},
|
lowerLevelStoreConfig map[string]interface{},
|
||||||
lowerLevelMaxBatchSize uint64,
|
lowerLevelMaxBatchSize uint64,
|
||||||
options moss.CollectionOptions,
|
options moss.CollectionOptions,
|
||||||
) (moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, error) {
|
) (moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, statsFunc, error) {
|
||||||
if lowerLevelStoreConfig == nil {
|
if lowerLevelStoreConfig == nil {
|
||||||
lowerLevelStoreConfig = map[string]interface{}{}
|
lowerLevelStoreConfig = map[string]interface{}{}
|
||||||
}
|
}
|
||||||
|
@ -50,13 +50,13 @@ func initLowerLevelStore(
|
||||||
|
|
||||||
constructor := registry.KVStoreConstructorByName(lowerLevelStoreName)
|
constructor := registry.KVStoreConstructorByName(lowerLevelStoreName)
|
||||||
if constructor == nil {
|
if constructor == nil {
|
||||||
return nil, nil, nil, fmt.Errorf("moss store, initLowerLevelStore,"+
|
return nil, nil, nil, nil, fmt.Errorf("moss store, initLowerLevelStore,"+
|
||||||
" could not find lower level store: %s", lowerLevelStoreName)
|
" could not find lower level store: %s", lowerLevelStoreName)
|
||||||
}
|
}
|
||||||
|
|
||||||
kvStore, err := constructor(options.MergeOperator, lowerLevelStoreConfig)
|
kvStore, err := constructor(options.MergeOperator, lowerLevelStoreConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
llStore := &llStore{
|
llStore := &llStore{
|
||||||
|
@ -74,10 +74,10 @@ func initLowerLevelStore(
|
||||||
llSnapshot, err := llUpdate(nil)
|
llSnapshot, err := llUpdate(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = kvStore.Close()
|
_ = kvStore.Close()
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return llSnapshot, llUpdate, kvStore, nil // llStore.refs is now 1.
|
return llSnapshot, llUpdate, kvStore, nil, nil // llStore.refs is now 1.
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
|
@ -410,16 +410,16 @@ func (lli *llIterator) CurrentEx() (
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
|
|
||||||
func InitMossStore(config map[string]interface{}, options moss.CollectionOptions) (
|
func InitMossStore(config map[string]interface{}, options moss.CollectionOptions) (
|
||||||
moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, error) {
|
moss.Snapshot, moss.LowerLevelUpdate, store.KVStore, statsFunc, error) {
|
||||||
path, ok := config["path"].(string)
|
path, ok := config["path"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, nil, fmt.Errorf("lower: missing path for InitMossStore config")
|
return nil, nil, nil, nil, fmt.Errorf("lower: missing path for InitMossStore config")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := os.MkdirAll(path, 0700)
|
err := os.MkdirAll(path, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, fmt.Errorf("lower: InitMossStore mkdir, path: %s, err: %v",
|
return nil, nil, nil, nil, fmt.Errorf("lower: InitMossStore mkdir,"+
|
||||||
path, err)
|
" path: %s, err: %v", path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
storeOptions := moss.StoreOptions{
|
storeOptions := moss.StoreOptions{
|
||||||
|
@ -429,19 +429,19 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
|
||||||
if ok {
|
if ok {
|
||||||
b, err := json.Marshal(v) // Convert from map[string]interface{}.
|
b, err := json.Marshal(v) // Convert from map[string]interface{}.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(b, &storeOptions)
|
err = json.Unmarshal(b, &storeOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := moss.OpenStore(path, storeOptions)
|
s, err := moss.OpenStore(path, storeOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, fmt.Errorf("lower: moss.OpenStore, path: %s, err: %v",
|
return nil, nil, nil, nil, fmt.Errorf("lower: moss.OpenStore,"+
|
||||||
path, err)
|
" path: %s, err: %v", path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sw := &mossStoreWrapper{s: s}
|
sw := &mossStoreWrapper{s: s}
|
||||||
|
@ -461,10 +461,18 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
|
||||||
|
|
||||||
llSnapshot, err := llUpdate(nil)
|
llSnapshot, err := llUpdate(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return llSnapshot, llUpdate, nil, nil
|
llStats := func() map[string]interface{} {
|
||||||
|
stats, err := s.Stats()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return stats
|
||||||
|
}
|
||||||
|
|
||||||
|
return llSnapshot, llUpdate, nil, llStats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type mossStoreWrapper struct {
|
type mossStoreWrapper struct {
|
||||||
|
|
|
@ -34,6 +34,11 @@ func (s *stats) statsMap() map[string]interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, exists := ms["kv"]
|
||||||
|
if !exists && s.s.llstats != nil {
|
||||||
|
ms["kv"] = s.s.llstats()
|
||||||
|
}
|
||||||
|
|
||||||
return ms
|
return ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,14 @@ type Store struct {
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
ms moss.Collection
|
ms moss.Collection
|
||||||
mo store.MergeOperator
|
mo store.MergeOperator
|
||||||
llstore store.KVStore
|
llstore store.KVStore // May be nil (ex: when using mossStore).
|
||||||
|
llstats statsFunc // May be nil.
|
||||||
|
|
||||||
s *stats
|
s *stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type statsFunc func() map[string]interface{}
|
||||||
|
|
||||||
// New initializes a moss storage with values from the optional
|
// New initializes a moss storage with values from the optional
|
||||||
// config["mossCollectionOptions"] (a JSON moss.CollectionOptions).
|
// config["mossCollectionOptions"] (a JSON moss.CollectionOptions).
|
||||||
// Next, values from the RegistryCollectionOptions, named by the
|
// Next, values from the RegistryCollectionOptions, named by the
|
||||||
|
@ -102,6 +105,8 @@ func New(mo store.MergeOperator, config map[string]interface{}) (
|
||||||
}
|
}
|
||||||
|
|
||||||
var llStore store.KVStore
|
var llStore store.KVStore
|
||||||
|
var llStats statsFunc
|
||||||
|
|
||||||
if options.LowerLevelInit == nil &&
|
if options.LowerLevelInit == nil &&
|
||||||
options.LowerLevelUpdate == nil &&
|
options.LowerLevelUpdate == nil &&
|
||||||
mossLowerLevelStoreName != "" {
|
mossLowerLevelStoreName != "" {
|
||||||
|
@ -127,7 +132,7 @@ func New(mo store.MergeOperator, config map[string]interface{}) (
|
||||||
mossLowerLevelMaxBatchSize = uint64(mossLowerLevelMaxBatchSizeF)
|
mossLowerLevelMaxBatchSize = uint64(mossLowerLevelMaxBatchSizeF)
|
||||||
}
|
}
|
||||||
|
|
||||||
lowerLevelInit, lowerLevelUpdate, lowerLevelStore, err :=
|
lowerLevelInit, lowerLevelUpdate, lowerLevelStore, lowerLevelStats, err :=
|
||||||
initLowerLevelStore(config,
|
initLowerLevelStore(config,
|
||||||
mossLowerLevelStoreName,
|
mossLowerLevelStoreName,
|
||||||
mossLowerLevelStoreConfig,
|
mossLowerLevelStoreConfig,
|
||||||
|
@ -139,7 +144,9 @@ func New(mo store.MergeOperator, config map[string]interface{}) (
|
||||||
|
|
||||||
options.LowerLevelInit = lowerLevelInit
|
options.LowerLevelInit = lowerLevelInit
|
||||||
options.LowerLevelUpdate = lowerLevelUpdate
|
options.LowerLevelUpdate = lowerLevelUpdate
|
||||||
|
|
||||||
llStore = lowerLevelStore
|
llStore = lowerLevelStore
|
||||||
|
llStats = lowerLevelStats
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
@ -156,6 +163,7 @@ func New(mo store.MergeOperator, config map[string]interface{}) (
|
||||||
ms: ms,
|
ms: ms,
|
||||||
mo: mo,
|
mo: mo,
|
||||||
llstore: llStore,
|
llstore: llStore,
|
||||||
|
llstats: llStats,
|
||||||
}
|
}
|
||||||
rv.s = &stats{s: &rv}
|
rv.s = &stats{s: &rv}
|
||||||
return &rv, nil
|
return &rv, nil
|
||||||
|
|
15
vendor/manifest
vendored
15
vendor/manifest
vendored
|
@ -4,6 +4,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/blevesearch/go-porterstemmer",
|
"importpath": "github.com/blevesearch/go-porterstemmer",
|
||||||
"repository": "https://github.com/blevesearch/go-porterstemmer",
|
"repository": "https://github.com/blevesearch/go-porterstemmer",
|
||||||
|
"vcs": "",
|
||||||
"revision": "23a2c8e5cf1f380f27722c6d2ae8896431dc7d0e",
|
"revision": "23a2c8e5cf1f380f27722c6d2ae8896431dc7d0e",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/blevesearch/segment",
|
"importpath": "github.com/blevesearch/segment",
|
||||||
"repository": "https://github.com/blevesearch/segment",
|
"repository": "https://github.com/blevesearch/segment",
|
||||||
|
"vcs": "",
|
||||||
"revision": "db70c57796cc8c310613541dfade3dce627d09c7",
|
"revision": "db70c57796cc8c310613541dfade3dce627d09c7",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/boltdb/bolt",
|
"importpath": "github.com/boltdb/bolt",
|
||||||
"repository": "https://github.com/boltdb/bolt",
|
"repository": "https://github.com/boltdb/bolt",
|
||||||
|
"vcs": "",
|
||||||
"revision": "144418e1475d8bf7abbdc48583500f1a20c62ea7",
|
"revision": "144418e1475d8bf7abbdc48583500f1a20c62ea7",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -25,13 +28,15 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/couchbase/moss",
|
"importpath": "github.com/couchbase/moss",
|
||||||
"repository": "https://github.com/couchbase/moss",
|
"repository": "https://github.com/couchbase/moss",
|
||||||
"revision": "e013f5f973e5b094ecf61e08ae9aa3754bd22d15",
|
"vcs": "git",
|
||||||
|
"revision": "564bdbc09ecc32cb398b56b855a5a6dc9fd7cce5",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"importpath": "github.com/golang/protobuf/proto",
|
"importpath": "github.com/golang/protobuf/proto",
|
||||||
"repository": "https://github.com/golang/protobuf",
|
"repository": "https://github.com/golang/protobuf",
|
||||||
|
"vcs": "",
|
||||||
"revision": "655cdfa588ea190e901bc5590e65d5621688847c",
|
"revision": "655cdfa588ea190e901bc5590e65d5621688847c",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/proto",
|
"path": "/proto",
|
||||||
|
@ -40,6 +45,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/golang/snappy",
|
"importpath": "github.com/golang/snappy",
|
||||||
"repository": "https://github.com/golang/snappy",
|
"repository": "https://github.com/golang/snappy",
|
||||||
|
"vcs": "",
|
||||||
"revision": "cef980a12b316c5b7e5bb3a8e168eb43ae999a88",
|
"revision": "cef980a12b316c5b7e5bb3a8e168eb43ae999a88",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -47,6 +53,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/rcrowley/go-metrics",
|
"importpath": "github.com/rcrowley/go-metrics",
|
||||||
"repository": "https://github.com/rcrowley/go-metrics",
|
"repository": "https://github.com/rcrowley/go-metrics",
|
||||||
|
"vcs": "",
|
||||||
"revision": "dee209f2455f101a5e4e593dea94872d2c62d85d",
|
"revision": "dee209f2455f101a5e4e593dea94872d2c62d85d",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -54,6 +61,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/steveyen/gtreap",
|
"importpath": "github.com/steveyen/gtreap",
|
||||||
"repository": "https://github.com/steveyen/gtreap",
|
"repository": "https://github.com/steveyen/gtreap",
|
||||||
|
"vcs": "",
|
||||||
"revision": "0abe01ef9be25c4aedc174758ec2d917314d6d70",
|
"revision": "0abe01ef9be25c4aedc174758ec2d917314d6d70",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -61,6 +69,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/syndtr/goleveldb/leveldb",
|
"importpath": "github.com/syndtr/goleveldb/leveldb",
|
||||||
"repository": "https://github.com/syndtr/goleveldb",
|
"repository": "https://github.com/syndtr/goleveldb",
|
||||||
|
"vcs": "",
|
||||||
"revision": "93fc893f2dadb96ffde441c7546cc67ea290a3a8",
|
"revision": "93fc893f2dadb96ffde441c7546cc67ea290a3a8",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/leveldb",
|
"path": "/leveldb",
|
||||||
|
@ -69,6 +78,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "github.com/willf/bitset",
|
"importpath": "github.com/willf/bitset",
|
||||||
"repository": "https://github.com/willf/bitset",
|
"repository": "https://github.com/willf/bitset",
|
||||||
|
"vcs": "",
|
||||||
"revision": "2e6e8094ef4745224150c88c16191c7dceaad16f",
|
"revision": "2e6e8094ef4745224150c88c16191c7dceaad16f",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"notests": true
|
"notests": true
|
||||||
|
@ -76,6 +86,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "golang.org/x/net/context",
|
"importpath": "golang.org/x/net/context",
|
||||||
"repository": "https://go.googlesource.com/net",
|
"repository": "https://go.googlesource.com/net",
|
||||||
|
"vcs": "",
|
||||||
"revision": "e45385e9b226f570b1f086bf287b25d3d4117776",
|
"revision": "e45385e9b226f570b1f086bf287b25d3d4117776",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/context",
|
"path": "/context",
|
||||||
|
@ -84,6 +95,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "golang.org/x/text/transform",
|
"importpath": "golang.org/x/text/transform",
|
||||||
"repository": "https://go.googlesource.com/text",
|
"repository": "https://go.googlesource.com/text",
|
||||||
|
"vcs": "",
|
||||||
"revision": "5ee49cfe751141f8017047bab800d1f528ee3be1",
|
"revision": "5ee49cfe751141f8017047bab800d1f528ee3be1",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/transform",
|
"path": "/transform",
|
||||||
|
@ -92,6 +104,7 @@
|
||||||
{
|
{
|
||||||
"importpath": "golang.org/x/text/unicode/norm",
|
"importpath": "golang.org/x/text/unicode/norm",
|
||||||
"repository": "https://go.googlesource.com/text",
|
"repository": "https://go.googlesource.com/text",
|
||||||
|
"vcs": "",
|
||||||
"revision": "5ee49cfe751141f8017047bab800d1f528ee3be1",
|
"revision": "5ee49cfe751141f8017047bab800d1f528ee3be1",
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"path": "/unicode/norm",
|
"path": "/unicode/norm",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user