Browse Source

Added a few missing implementations in index.go.

Also, added closing of persistence and mem storage.

Change-Id: Iacf0d22c3520dd2584d9546984c1f8a5ed6cd54e
pull/413/head
Bjoern Rabenstein 10 years ago
parent
commit
af77d5ef0b
  1. 2
      main.go
  2. 17
      storage/local/index/index.go
  3. 2
      storage/local/index/index_test.go
  4. 3
      storage/local/storage.go

2
main.go

@ -145,6 +145,7 @@ func main() {
if err != nil { if err != nil {
glog.Fatal("Error opening disk persistence: ", err) glog.Fatal("Error opening disk persistence: ", err)
} }
defer persistence.Close()
o := &storage_ng.MemorySeriesStorageOptions{ o := &storage_ng.MemorySeriesStorageOptions{
Persistence: persistence, Persistence: persistence,
@ -157,6 +158,7 @@ func main() {
if err != nil { if err != nil {
glog.Fatal("Error opening memory series storage: ", err) glog.Fatal("Error opening memory series storage: ", err)
} }
defer memStorage.Close()
//registry.MustRegister(memStorage) //registry.MustRegister(memStorage)
var remoteTSDBQueue *remote.TSDBQueueManager var remoteTSDBQueue *remote.TSDBQueueManager

17
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. // 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{ fps, _, err := i.LabelPairToFingerprints.Lookup(&metric.LabelPair{
Name: l, Name: ln,
Value: v, Value: lv,
}) })
return fps, err return fps, err
} }
// GetLabelValuesForLabelName returns all label values associated with a given label name. // GetLabelValuesForLabelName returns all label values associated with a given label name.
func (i *TotalIndexer) GetLabelValuesForLabelName(clientmodel.LabelName) (clientmodel.LabelValues, error) { func (i *TotalIndexer) GetLabelValuesForLabelName(ln clientmodel.LabelName) (clientmodel.LabelValues, error) {
// TODO: implement. lvs, _, err := i.LabelNameToLabelValues.Lookup(ln)
return nil, nil return lvs, err
} }
// HasFingerprint returns true if a metric with the given fingerprint has been indexed. // HasFingerprint returns true if a metric with the given fingerprint has been indexed.
func (i *TotalIndexer) HasFingerprint(clientmodel.Fingerprint) (bool, error) { func (i *TotalIndexer) HasFingerprint(fp clientmodel.Fingerprint) (bool, error) {
// TODO: implement. return i.FingerprintMembership.Has(fp)
return false, nil
} }

2
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) t.Fatalf("%d. fingerprint %v not found", i, fp)
} }
if !mOut.Equal(m) { 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. // Check that indexed metrics are in membership index.

3
storage/local/storage.go

@ -243,9 +243,6 @@ func (s *memorySeriesStorage) Close() error {
} }
s.fingerprintToSeries = nil s.fingerprintToSeries = nil
// TODO: Close() persistence either here or in main (where it got created -
// probably better in main).
s.state = storageStopping s.state = storageStopping
return nil return nil

Loading…
Cancel
Save