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



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

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



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

def check_windows
  true
end

#run_linuxObject Also known as: run_darwin

Install Linux Mercurial package

Return

true

Always return true



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

def run_linux
  post_note ""
  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(post_note + "Had to move #{install_path} to #{install_path}_old\n")
  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(post_note + "Cassandra was installed, please reload your shell to activate it and re-run rconf\n")
    aborting(true)
  end
  report_success
  cassandra_configure({:endpoint_snitch => endpoint_snitch, :partitioner => partitioner})
end

#run_windowsObject

Install Windows software

Return

true

Always return true



87
88
89
# File 'lib/rconf/configurators/cassandra_configurator.rb', line 87

def run_windows
  # TBD
end