Allow tsi to be enabled via config option
parent
2b96c5d4d0
commit
4bf7b2bb19
|
@ -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"`
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue