Ejemplo n.º 1
0
func (db *cassandraDatabase) RemoveMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
	return db.session.Query(
		"DELETE FROM metric_names WHERE metric_key = ? AND tag_set = ?",
		metricKey,
		tagSet.Serialize(),
	).Exec()
}
Ejemplo n.º 2
0
func (db *defaultDatabase) RemoveMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {
	db.allMetricsMutex.Lock()
	// Forget the metric in the cache.
	// (If this delete fails, there will be an extraneous write the next time the metric is consumed).
	db.allMetricsCache[metricKey] = false
	db.allMetricsMutex.Unlock()
	return db.session.Query(
		"DELETE FROM metric_names WHERE metric_key = ? AND tag_set = ?",
		metricKey,
		tagSet.Serialize(),
	).Exec()
}
Ejemplo n.º 3
0
// AddMetricName inserts to metric to Cassandra.
func (db *defaultDatabase) AddMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {

	if err := db.session.Query("INSERT INTO metric_names (metric_key, tag_set) VALUES (?, ?)", metricKey, tagSet.Serialize()).Exec(); err != nil {
		return err
	}
	db.allMetricsMutex.Lock()
	if db.allMetricsCache[metricKey] {
		db.allMetricsMutex.Unlock()
		// If the key is found in the cache, exit early.
		return nil
	}
	db.allMetricsMutex.Unlock()
	if err := db.session.Query("UPDATE metric_name_set SET metric_names = metric_names + ? WHERE shard = ?", []string{string(metricKey)}, 0).Exec(); err != nil {
		return err
	}
	db.allMetricsMutex.Lock()
	// Remember the cached value so that it won't be written again in the absence of reads.
	db.allMetricsCache[metricKey] = true
	db.allMetricsMutex.Unlock()
	return nil

}
Ejemplo n.º 4
0
// AddMetricName inserts to metric to Cassandra.
func (db *cassandraDatabase) AddMetricName(metricKey api.MetricKey, tagSet api.TagSet) error {

	if err := db.session.Query("INSERT INTO metric_names (metric_key, tag_set) VALUES (?, ?)", metricKey, tagSet.Serialize()).Exec(); err != nil {
		return err
	}
	if err := db.session.Query("UPDATE metric_name_set SET metric_names = metric_names + ? WHERE shard = ?", []string{string(metricKey)}, 0).Exec(); err != nil {
		return err
	}
	return nil

}
Ejemplo n.º 5
0
func matchPrecondition(matcherTag string, tagSet api.TagSet) bool {
	return tagSet.HasKey(matcherTag)
}