Browse Source

Merge pull request #102 from prometheus/julius-tiered-error-handling

More userfriendly output when we fail to create the tiered storage.
pull/104/head
Matt T. Proud 12 years ago
parent
commit
a4f0578a7e
  1. 5
      main.go
  2. 5
      rules/rules_test.go
  3. 7
      storage/metric/tiered.go
  4. 8
      storage/metric/tiered_test.go

5
main.go

@ -48,7 +48,10 @@ func main() {
log.Fatalf("Error loading configuration from %s: %v", *configFile, err)
}
ts := metric.NewTieredStorage(5000, 5000, 100, time.Second*30, time.Second*1, time.Second*20, *metricsStoragePath)
ts, err := metric.NewTieredStorage(5000, 5000, 100, time.Second*30, time.Second*1, time.Second*20, *metricsStoragePath)
if err != nil {
log.Fatalf("Error opening storage: %s", err)
}
go ts.Serve()
go func() {
notifier := make(chan os.Signal)

5
rules/rules_test.go

@ -214,7 +214,10 @@ func vectorComparisonString(expected []string, actual []string) string {
func TestExpressions(t *testing.T) {
temporaryDirectory := test.NewTemporaryDirectory("rule_expression_tests", t)
defer temporaryDirectory.Close()
tieredStorage := metric.NewTieredStorage(5000, 5000, 100, time.Second*30, time.Second*1, time.Second*20, temporaryDirectory.Path())
tieredStorage, err := metric.NewTieredStorage(5000, 5000, 100, time.Second*30, time.Second*1, time.Second*20, temporaryDirectory.Path())
if err != nil {
t.Fatalf("Error opening storage: %s", err)
}
go tieredStorage.Serve()
ast.SetStorage(tieredStorage)

7
storage/metric/tiered.go

@ -73,13 +73,13 @@ type Storage interface {
GetMetricForFingerprint(model.Fingerprint) (m *model.Metric, err error)
}
func NewTieredStorage(appendToMemoryQueueDepth, appendToDiskQueueDepth, viewQueueDepth uint, flushMemoryInterval, writeMemoryInterval, memoryTTL time.Duration, root string) Storage {
func NewTieredStorage(appendToMemoryQueueDepth, appendToDiskQueueDepth, viewQueueDepth uint, flushMemoryInterval, writeMemoryInterval, memoryTTL time.Duration, root string) (storage Storage, err error) {
diskStorage, err := NewLevelDBMetricPersistence(root)
if err != nil {
panic(err)
return
}
return &tieredStorage{
storage = &tieredStorage{
appendToDiskQueue: make(chan model.Sample, appendToDiskQueueDepth),
appendToMemoryQueue: make(chan model.Sample, appendToMemoryQueueDepth),
diskStorage: diskStorage,
@ -90,6 +90,7 @@ func NewTieredStorage(appendToMemoryQueueDepth, appendToDiskQueueDepth, viewQueu
viewQueue: make(chan viewJob, viewQueueDepth),
writeMemoryInterval: writeMemoryInterval,
}
return
}
func (t *tieredStorage) AppendSample(s model.Sample) (err error) {

8
storage/metric/tiered_test.go

@ -35,10 +35,14 @@ func (t testTieredStorageCloser) Close() {
func newTestTieredStorage(t test.Tester) (storage Storage, closer test.Closer) {
var directory test.TemporaryDirectory
directory = test.NewTemporaryDirectory("test_tiered_storage", t)
storage = NewTieredStorage(5000000, 2500, 1000, 5*time.Second, 15*time.Second, 0*time.Second, directory.Path())
storage, err := NewTieredStorage(5000000, 2500, 1000, 5*time.Second, 15*time.Second, 0*time.Second, directory.Path())
if err != nil {
t.Fatalf("Error creating storage: %s", err)
}
if storage == nil {
t.Fatalf("%d. storage == nil")
t.Fatalf("storage == nil")
}
go storage.Serve()

Loading…
Cancel
Save