diff --git a/main.go b/main.go index 576fda825..71adcd661 100644 --- a/main.go +++ b/main.go @@ -145,6 +145,7 @@ func main() { if err != nil { glog.Fatal("Error opening disk persistence: ", err) } + defer persistence.Close() o := &storage_ng.MemorySeriesStorageOptions{ Persistence: persistence, @@ -157,6 +158,7 @@ func main() { if err != nil { glog.Fatal("Error opening memory series storage: ", err) } + defer memStorage.Close() //registry.MustRegister(memStorage) var remoteTSDBQueue *remote.TSDBQueueManager diff --git a/storage/local/index/index.go b/storage/local/index/index.go index 4455cf293..97ba457f7 100644 --- a/storage/local/index/index.go +++ b/storage/local/index/index.go @@ -448,22 +448,21 @@ func (i *TotalIndexer) GetMetricForFingerprint(fp clientmodel.Fingerprint) (clie } // GetFingerprintsForLabelPair returns all fingerprints for the provided label pair. -func (i *TotalIndexer) GetFingerprintsForLabelPair(l clientmodel.LabelName, v clientmodel.LabelValue) (clientmodel.Fingerprints, error) { +func (i *TotalIndexer) GetFingerprintsForLabelPair(ln clientmodel.LabelName, lv clientmodel.LabelValue) (clientmodel.Fingerprints, error) { fps, _, err := i.LabelPairToFingerprints.Lookup(&metric.LabelPair{ - Name: l, - Value: v, + Name: ln, + Value: lv, }) return fps, err } // GetLabelValuesForLabelName returns all label values associated with a given label name. -func (i *TotalIndexer) GetLabelValuesForLabelName(clientmodel.LabelName) (clientmodel.LabelValues, error) { - // TODO: implement. - return nil, nil +func (i *TotalIndexer) GetLabelValuesForLabelName(ln clientmodel.LabelName) (clientmodel.LabelValues, error) { + lvs, _, err := i.LabelNameToLabelValues.Lookup(ln) + return lvs, err } // HasFingerprint returns true if a metric with the given fingerprint has been indexed. -func (i *TotalIndexer) HasFingerprint(clientmodel.Fingerprint) (bool, error) { - // TODO: implement. - return false, nil +func (i *TotalIndexer) HasFingerprint(fp clientmodel.Fingerprint) (bool, error) { + return i.FingerprintMembership.Has(fp) } diff --git a/storage/local/index/index_test.go b/storage/local/index/index_test.go index 67f26af24..f70dbc23c 100644 --- a/storage/local/index/index_test.go +++ b/storage/local/index/index_test.go @@ -42,7 +42,7 @@ func verifyIndexedState(i int, t *testing.T, b incrementalBatch, indexedFpsToMet t.Fatalf("%d. fingerprint %v not found", i, fp) } if !mOut.Equal(m) { - t.Fatalf("%i. %v: Got: %s; want %s", i, fp, mOut, m) + t.Fatalf("%d. %v: Got: %s; want %s", i, fp, mOut, m) } // Check that indexed metrics are in membership index. diff --git a/storage/local/storage.go b/storage/local/storage.go index db9518570..6fe69d8ad 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -243,9 +243,6 @@ func (s *memorySeriesStorage) Close() error { } s.fingerprintToSeries = nil - // TODO: Close() persistence either here or in main (where it got created - - // probably better in main). - s.state = storageStopping return nil