Ejemplo n.º 1
0
func NewFileStore(dir string) *FileStore {
	db, rp := tsdb.DecodeStorePath(dir)
	return &FileStore{
		dir:          dir,
		lastModified: time.Now(),
		Logger:       log.New(os.Stderr, "[filestore] ", log.LstdFlags),
		statMap: influxdb.NewStatistics(
			"tsm1_filestore:"+dir,
			"tsm1_filestore",
			map[string]string{"path": dir, "database": db, "retentionPolicy": rp},
		),
	}
}
Ejemplo n.º 2
0
func NewWAL(path string) *WAL {
	db, rp := tsdb.DecodeStorePath(path)
	return &WAL{
		path: path,

		// these options should be overriden by any options in the config
		LogOutput:   os.Stderr,
		SegmentSize: DefaultSegmentSize,
		logger:      log.New(os.Stderr, "[tsm1wal] ", log.LstdFlags),
		closing:     make(chan struct{}),

		statMap: influxdb.NewStatistics(
			"tsm1_wal:"+path,
			"tsm1_wal",
			map[string]string{"path": path, "database": db, "retentionPolicy": rp},
		),
	}
}
Ejemplo n.º 3
0
// NewCache returns an instance of a cache which will use a maximum of maxSize bytes of memory.
// Only used for engine caches, never for snapshots
func NewCache(maxSize uint64, path string) *Cache {
	db, rp := tsdb.DecodeStorePath(path)
	c := &Cache{
		maxSize: maxSize,
		store:   make(map[string]*entry),
		statMap: influxdb.NewStatistics(
			"tsm1_cache:"+path,
			"tsm1_cache",
			map[string]string{"path": path, "database": db, "retentionPolicy": rp},
		),
		lastSnapshot: time.Now(),
	}
	c.UpdateAge()
	c.UpdateCompactTime(0)
	c.updateCachedBytes(0)
	c.updateMemSize(0)
	c.updateSnapshots()
	return c
}