Class: Gizzard::SetupReplicaCommand
- Defined in:
- lib/gizzard/commands.rb
Instance Attribute Summary
Attributes inherited from Command
#argv, #buffer, #command_options, #global_options, #job_injector, #manager
Instance Method Summary collapse
Methods inherited from Command
classify, #confirm!, #get_base_name, #help!, #initialize, make_job_injector, make_manager, #output, #require_tables, #require_template_options, run
Constructor Details
This class inherits a constructor from Gizzard::Command
Instance Method Details
#run ⇒ Object
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/gizzard/commands.rb', line 598 def run from_shard_id_string, to_shard_id_string = @argv help!("Requires source & destination shard id") unless from_shard_id_string && to_shard_id_string from_shard_id = ShardId.parse(from_shard_id_string) to_shard_id = ShardId.parse(to_shard_id_string) if manager.list_upward_links(to_shard_id).size > 0 STDERR.puts "Destination shard #{to_shard_id} has links to it." exit 1 end link = manager.list_upward_links(from_shard_id)[0] replica_shard_id = link.up_id weight = link.weight write_only_shard_id = ShardId.new("localhost", "#{to_shard_id.table_prefix}_copy_write_only") manager.create_shard(ShardInfo.new(write_only_shard_id, "WriteOnlyShard", "", "", 0)) manager.add_link(replica_shard_id, write_only_shard_id, weight) manager.add_link(write_only_shard_id, to_shard_id, 1) output to_shard_id.to_unix end |