Permalink
Browse files

Convert Cassandra schema to snake_case from CamelCase.

This makes the data acecssible (even if unreadable) via CQL. I wanted this done
before we fire up the new cluster since we're migrating all the data anyways.

Tests pass on my box and I fired up the whole infrastructure and it works.

Also cleaned up the whole "stat_*" thing so now it's "*_value" which matches all
the other CF's.
  • Loading branch information...
1 parent a1c849e commit 88043d295235a415e1a3040b20f2c7fcca9ea17a Al Tobey committed Oct 18, 2012
View
@@ -45,7 +45,7 @@ Not really. A system with sufficient metric coverage can leave behind most Nagio
Hostnames are often wildly inaccurate even in meticulously managed networks. They get reused, mispelled, changed by accident,
and sometimes are totally meaningless (as in EC2). Hastur agent, by default, creates /etc/uuid if it doesn't exist and writes
a UUID in there that it uses from then on to identify the system. As many of the network names as are available are read
-from the system and stored in Hastur's LookupByKey column family for later translation back to hostnames. Ohai data is
+from the system and stored in Hastur's lookup_by_key column family for later translation back to hostnames. Ohai data is
also used in this stage where available.
## What about security?
View
@@ -14,7 +14,7 @@
:multi => true
opt :acks_to, "Router ack URI(s)", :default => ["tcp://127.0.0.1:8134"], :type => :strings,
:multi => true
- opt :keyspace, "Keyspace", :default => "Hastur", :type => String
+ opt :keyspace, "Keyspace", :default => "hastur", :type => String
opt :hwm, "ZMQ message queue size", :default => 1, :type => :int
end
View
@@ -53,7 +53,7 @@
sink = Hastur::Service::CassandraSink.new(
:ack_uri => opts[:return],
:data_uri => opts[:firehose],
- :keyspace => 'Hastur',
+ :keyspace => 'hastur',
:cassandra => opts[:cassandra],
:socktype => ZMQ::SUB,
:logger => logger,
@@ -490,7 +490,7 @@ def filter_out_unwanted_names(output, names)
end
#
- # Look up message names in the "name-" LookupByKey row. Handles comma-separated lists.
+ # Look up message names in the "name-" lookup_by_key row. Handles comma-separated lists.
# @see parse_name_lookup
#
# @param [String] match_name the name to look up
@@ -541,7 +541,7 @@ def cass_client
uri_json = ENV['CASSANDRA_URIS'] || '["127.0.0.1:9160"]'
@cassandra_uris = MultiJson.load uri_json
- @cass_client = ::Cassandra.new("Hastur", @cassandra_uris, THRIFT_OPTIONS)
+ @cass_client = ::Cassandra.new("hastur", @cassandra_uris, THRIFT_OPTIONS)
# for non-production and port-forwarded ssh, there will only be one URI and it
# should not auto-discover nodes
@@ -498,7 +498,7 @@ class V1 < Grape::API
get "/statusz" do
begin
# cass_client.ring will fail if no successful queries have run
- cass_client.get "GaugeArchive", " "
+ cass_client.get "gauge_archive", " "
ring = cass_client.ring
out = ring.map do |r|
{ :start_token => r.start_token, :end_token => r.end_token, :endpoints => r.endpoints }
@@ -24,7 +24,7 @@ module Rollup
# existing entries with the same column key.
# Writes out row keys in the form of uuid-rollup_interval-weekly_bucket.
#
- # @param [String] archive which Archive CF to roll up, e.g. 'gauge', 'counter'
+ # @param [String] archive which archive CF to roll up, e.g. 'gauge', 'counter'
# @param [Fixnum] start_ts beginning of the period to roll up
# @param [Fixnum] end_ts end of the period to roll up
# @example
@@ -71,7 +71,7 @@ def schema_by_type(type)
#
# Insert a Hastur message. This inserts the JSON into the archive
# column family, the value into the value column family (if
- # relevant), and updates the metadata and LookupByKey column
+ # relevant), and updates the metadata and lookup_by_key column
# family.
#
# @param [Cassandra] cass_client client object, should be connected and in the right keyspace
@@ -116,17 +116,17 @@ def insert(cass_client, json_string, schema, options = {})
client.insert(cf, key, { colname => value.to_msgpack }, insert_options) if cf
# Insert into "saw UUID in this time period" row
- client.insert(:LookupByKey, "uuid-#{one_day_ts}", { uuid => "" }, insert_options)
+ client.insert(:lookup_by_key, "uuid-#{one_day_ts}", { uuid => "" }, insert_options)
# Insert into "saw message name in this time period" row
if schema[:name]
type_id = Hastur::Message.symbol_to_type_id(schema[:type])
colkey = [name, type_id, uuid].join('-')
- client.insert(:LookupByKey, "name-#{one_day_ts}", { colkey => "" }, insert_options)
+ client.insert(:lookup_by_key, "name-#{one_day_ts}", { colkey => "" }, insert_options)
end
# Insert into "saw this UUID for this app name" row
- client.insert(:LookupByKey, "app_name-#{one_day_ts}", { "#{app_name}-#{uuid}" => "" }, insert_options)
+ client.insert(:lookup_by_key, "app_name-#{one_day_ts}", { "#{app_name}-#{uuid}" => "" }, insert_options)
end
end
@@ -177,7 +177,7 @@ def get(cass_client, agent_uuid, type, start_timestamp, end_timestamp, options =
end
#
- # Get one or more rows from the LookupByKey CF and return a flattened hash.
+ # Get one or more rows from the lookup_by_key CF and return a flattened hash.
#
# @param cass_client The cassandra client object
# @param [String,Symbol] prefix the row key prefix to fetch, e.g. "name", "cnames"
@@ -192,7 +192,7 @@ def lookup_by_key(cass_client, kind, start_timestamp, end_timestamp, options={})
options = { :count => 10_000 }.merge(options)
# this isn't defined in the schema (yet?) so the bucket is hard-coded to one day everywhere
usec_aligned_chunks(start_timestamp, end_timestamp, :day).each do |ts|
- cass_client.get('LookupByKey', "#{kind}-#{ts}", options).each do |key,value|
+ cass_client.get('lookup_by_key', "#{kind}-#{ts}", options).each do |key,value|
data[key] = value
end
end
@@ -525,7 +525,7 @@ class Retrieval < Sinatra::Base
get "/api/statusz" do
begin
# cass_client.ring will fail if no successful queries have run
- cass_client.get "GaugeArchive", " "
+ cass_client.get "gauge_archive", " "
ring = cass_client.ring
out = ring.map do |r|
{ :start_token => r.start_token, :end_token => r.end_token, :endpoints => r.endpoints }
@@ -48,7 +48,7 @@ def setup
@heartbeat_agent2 = "heartbeat-agent2"
@start_ts = Hastur::Util.timestamp
@end_ts = @start_ts + 150_000_000
- @cf = "HBProcessArchive"
+ @cf = "hb_process_archive"
@topology = Nodule::Topology.new(
:alarm => Nodule::Alarm.new(:timeout => test_timeout(100)),
@@ -58,7 +58,7 @@ def setup
:router => Nodule::ZeroMQ.new(:uri => :gen),
:firehose => Nodule::ZeroMQ.new(:uri => :gen),
:return => Nodule::ZeroMQ.new(:uri => :gen, :connect => ZMQ::PUSH),
- :cassandra => Nodule::Cassandra.new(:keyspace => "Hastur", :verbose => :greenio),
+ :cassandra => Nodule::Cassandra.new(:keyspace => "hastur", :verbose => :greenio),
:coresvc => Nodule::Process.new(
HASTUR_CORE_BIN,
'--uuid', R1UUID,
@@ -97,7 +97,7 @@ def setup
@topology.start_all
# wait for the row to show up in Cassandra
@cass = @topology[:cassandra].client
- wait_for_cassandra_rows @cass, "RegAgentArchive", 1, 30, true
+ wait_for_cassandra_rows @cass, "reg_agent_archive", 1, 30, true
end
def teardown
@@ -52,7 +52,7 @@ def setup
:rawdata => Nodule::ZeroMQ.new(:connect => ZMQ::PULL, :uri => :gen, :reader => :drain),
:control => Nodule::ZeroMQ.new(:connect => ZMQ::PULL, :uri => :gen, :reader => :drain),
:direct => Nodule::ZeroMQ.new(:connect => ZMQ::PUSH, :uri => :gen, :reader => :drain),
- :cassandra => Nodule::Cassandra.new( :keyspace => "Hastur", :verbose => :greenio ),
+ :cassandra => Nodule::Cassandra.new( :keyspace => "hastur", :verbose => :greenio ),
:router1svc => Nodule::Process.new(
HASTUR_ROUTER_BIN,
'--uuid', R1UUID,
@@ -126,7 +126,7 @@ def setup
@topology.start_all
# wait for the row to show up in Cassandra
client = @topology[:cassandra].client
- wait_for_cassandra_rows(client, "RegAgentArchive", 1, 60) do
+ wait_for_cassandra_rows(client, "reg_agent_archive", 1, 60) do
flunk "Gave up waiting for registrations in cassandra."
end
@@ -47,7 +47,7 @@ def setup
:log => Nodule::ZeroMQ.new(:connect => ZMQ::PULL, :uri => :gen, :reader => :drain),
:error => Nodule::ZeroMQ.new(:connect => ZMQ::PULL, :uri => :gen, :reader => :redio),
:direct => Nodule::ZeroMQ.new(:connect => ZMQ::PUSH, :uri => :gen, :reader => :drain),
- :cassandra => Nodule::Cassandra.new( :keyspace => "Hastur", :verbose => :greenio ),
+ :cassandra => Nodule::Cassandra.new( :keyspace => "hastur", :verbose => :greenio ),
:routersvc => Nodule::Process.new(
HASTUR_ROUTER_BIN,
'--uuid', R1UUID,
@@ -107,7 +107,7 @@ def setup
@topology.start_all
# wait for the row to show up in Cassandra
client = @topology[:cassandra].client
- wait_for_cassandra_rows(client, "RegAgentArchive", 1, 30) do
+ wait_for_cassandra_rows(client, "reg_agent_archive", 1, 30) do
flunk "Gave up waiting for registrations in cassandra."
end
@@ -34,7 +34,7 @@ def setup
:error => Nodule::ZeroMQ.new(:connect => ZMQ::PULL, :uri => :gen, :reader => :drain),
:control => Nodule::ZeroMQ.new(:connect => ZMQ::REP, :uri => :gen),
:direct => Nodule::ZeroMQ.new(:connect => ZMQ::PUSH, :uri => :gen),
- :cassandra => Nodule::Cassandra.new(:keyspace => "Hastur",
+ :cassandra => Nodule::Cassandra.new(:keyspace => "hastur",
:stderr => :redio, :verbose => :cyanio, #:stdout => :greenio,
),
:query_server => Nodule::Process.new(HASTUR_QUERY_SERVER_BIN,
@@ -102,7 +102,7 @@ def setup
sleep 0.01 until sinatra_ready
# wait for the row to show up in Cassandra
- wait_for_cassandra_rows(@topology[:cassandra].client, "RegAgentArchive", 1, 5) do
+ wait_for_cassandra_rows(@topology[:cassandra].client, "reg_agent_archive", 1, 5) do
flunk "Gave up waiting for registration in cassandra."
end
end
@@ -21,7 +21,7 @@ def setup
:mock_agent => Hastur::Mock::NoduleAgent.new(:reader => :capture),
:firehose => Nodule::ZeroMQ.new(:connect => ZMQ::SUB, :uri => :gen, :reader => :capture),
:return => Nodule::ZeroMQ.new(:uri => :gen),
- :cassandra => Nodule::Cassandra.new(:keyspace => "Hastur"),
+ :cassandra => Nodule::Cassandra.new(:keyspace => "hastur"),
:coresvc => Nodule::Process.new(
HASTUR_CORE_BIN,
'--uuid', R1UUID,
@@ -59,7 +59,7 @@ def test_core_router_ack
# why does this take so long, even on my fast box?
# TODO: figure out why this is timing out even on nice machines (al, 2012-04-12)
#start = Time.now
- #assert wait_for_cassandra_rows(@topology[:cassandra].client, "HBProcessArchive", 2, 60)
+ #assert wait_for_cassandra_rows(@topology[:cassandra].client, "hb_process_archive", 2, 60)
#STDERR.puts "Took #{Time.now - start} seconds for the rows to show up in Cassandra."
# check ack flow
Oops, something went wrong.

0 comments on commit 88043d2

Please sign in to comment.