Allow tsi to be enabled via config option

pull/7913/head
Jason Wilder 2016-11-21 10:11:59 -07:00 committed by Ben Johnson
parent 2b96c5d4d0
commit 4bf7b2bb19
No known key found for this signature in database
GPG Key ID: 81741CD251883081
4 changed files with 14 additions and 3 deletions

View File

@ -51,7 +51,7 @@ const (
type Config struct {
Dir string `toml:"dir"`
Engine string `toml:"-"`
Index string `toml:"-"`
Index string `toml:"index-version"`
// General WAL configuration options
WALDir string `toml:"wal-dir"`

View File

@ -76,12 +76,12 @@ func RegisteredIndexes() []string {
// If the path does not exist then the DefaultFormat is used.
func NewIndex(id uint64, path string, options EngineOptions) (Index, error) {
// Create a new index.
if _, err := os.Stat(path); os.IsNotExist(err) {
if _, err := os.Stat(path); os.IsNotExist(err) && options.Config.Index != "inmem" {
return newIndexFuncs[options.IndexVersion](id, path, options), nil
}
// Use default format.
format := DefaultIndex
format := options.Config.Index
// Lookup index by format.
fn := newIndexFuncs[format]

View File

@ -14,6 +14,12 @@ import (
"github.com/influxdata/influxdb/tsdb"
)
func init() {
tsdb.RegisterIndex("tsi1", func(id uint64, path string, opt tsdb.EngineOptions) tsdb.Index {
return &Index{Path: path}
})
}
// File extensions.
const (
LogFileExt = ".tsi.log"

View File

@ -245,6 +245,11 @@ func (s *Shard) Open() error {
// Initialize underlying index.
ipath := filepath.Join(s.path, "index")
// Create directory.
if err := os.MkdirAll(ipath, 0700); err != nil {
return err
}
idx, err := NewIndex(s.id, ipath, s.options)
if err != nil {
return err