Class: RightConf::CassandraConfigurator

Inherits:
Object
  • Object
show all
Includes:
Configurator
Defined in:
lib/rconf/configurators/cassandra_configurator.rb

Constant Summary collapse

SOURCE_BASE_URL =
'http://archive.apache.org/dist/cassandra/VERSION/apache-cassandra-VERSION-bin.tar.gz'
DEFAULT_CASSANDRA_INSTALL =
['/opt/cassandra', File.join(ENV['HOME'], 'cassandra')]

Instance Method Summary collapse

Methods included from Configurator

#[], #check, included, #post_process, #run, #signature, #validate

Methods included from ProgressReporter

included, report_to_file, report_to_stdout

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightConf::Configurator

Instance Method Details

#check_linuxObject Also known as: check_darwin

Check whether Cassandra is installed

Return

true

If Cassandra is installed

false

Otherwise



36
37
38
39
40
41
# File 'lib/rconf/configurators/cassandra_configurator.rb', line 36

def check_linux
  report_check('Checking for Cassandra')
  installed = Command.execute('cassandra', '-h').success?
  report_result(installed)
  installed
end

#check_windowsObject

Check on windows

Return

true

Always return true



48
49
50
# File 'lib/rconf/configurators/cassandra_configurator.rb', line 48

def check_windows
  true
end

#run_linuxObject Also known as: run_darwin

Install Linux Mercurial package

Return

true

Always return true



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rconf/configurators/cassandra_configurator.rb', line 56

def run_linux
  install_path(default_install_path) if install_path.nil?
  abort_on_failure(true) if abort_on_failure.nil?
  report_check('Installing Cassandra')
  url = SOURCE_BASE_URL.gsub('VERSION', version)
  if File.exist?(install_path)
    FileUtils.rm_rf("#{install_path}_old")
    FileUtils.mv(install_path, "#{install_path}_old")
    post_note "Had to move #{install_path} to #{install_path}_old"
  end
  FileUtils.mkdir_p(install_path)
  Dir.chdir(install_path) do
    Command.execute('curl', '-O', '-f', url, abort_option('Failed to download Cassandra')) unless File.exist?(File.join(install_path, File.basename(url)))
    Command.execute('tar', 'xvzf', File.basename(url), abort_option('Failed to untar Cassandra'))
  end
  bin_path = File.join(install_path, "apache-cassandra-#{version}", 'bin')
  if EnvironmentUpdater.update("PATH=$PATH:#{bin_path}", ['PATH'])
    post_note 'Cassandra was installed, please reload your shell to activate it and re-run rconf'
    aborting(true)
  end
  report_success
  if (endpoint_snitch)
    report_check 'Change cassandra configuration.'
    config_path = File.join(install_path, "apache-cassandra-#{version}", 'conf', 'cassandra.yaml')
    backup_ext = '.orig'
    Command.execute('sed', '-i', backup_ext, '-e', "s%^endpoint_snitch: .*$%endpoint_snitch: #{endpoint_snitch}%", config_path)
    report_success
    post_note "Origin config file in #{config_path}#{backup_ext}"
  end
end

#run_windowsObject

Install Windows software

Return

true

Always return true



92
93
94
# File 'lib/rconf/configurators/cassandra_configurator.rb', line 92

def run_windows
  # TBD
end