-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-ganglia
83 lines (66 loc) · 2.46 KB
/
install-ganglia
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
#!/usr/bin/ruby
module Emr
#Fixme: make sure error reporting is surfaced to the caller of this class
class PackageInstaller
def PackageInstaller.install(package)
# elasticmapreduce is a token that will be replaced by the s3 artifact deployer by the actual bucket name where this file is uploaded
bucket = "elasticmapreduce"
puts `mkdir -p /home/hadoop/common_packages/`
puts `rm -f /home/hadoop/common_packages/#{package}`
puts `wget http://#{bucket}.s3.amazonaws.com/libs/common-packages/#{package} -P /home/hadoop/common_packages/`
puts `sudo dpkg -i /home/hadoop/common_packages/#{package}`
end
end
end
Emr::PackageInstaller.install("libemr-ruby_latest.deb")
require 'fileutils'
require 'open-uri'
require 'json'
require 'emr/common'
class Installer
# bucketName is a token that will be replaced by the s3 artifact deployer by the actual bucket name where this file is uploaded
BUCKET_NAME = "elasticmapreduce"
PERSONAL_BUCKET_NAME = "crossbow-lei"
GANGLIA_HADOOP_VERSION_MAP =
{
"default" => "1.0",
"0.18" => "1.0",
"0.20" => "1.0",
"0.20.205" => "2.0",
"1.0.3" => "2.0"
}
def install_ganglia
jobflow_info = Emr::JsonInfoFile.new("job-flow")
hadoop_version = jobflow_info['hadoopVersion']
logger = Emr::Logger.new
executor = Emr::Executor.new(logger)
if hadoop_version != nil && GANGLIA_HADOOP_VERSION_MAP.has_key?(hadoop_version) then
version_num = GANGLIA_HADOOP_VERSION_MAP[hadoop_version]
else
version_num = GANGLIA_HADOOP_VERSION_MAP["default"]
end
executor.run("rm -f ganglia-installer")
if `cat /etc/*-release 2>/dev/null | grep 'Amazon'` == ""
#executor.run("hadoop fs -copyToLocal s3://#{BUCKET_NAME}/bootstrap-actions/ganglia/#{version_num}/ganglia-installer .")
executor.run("hadoop fs -copyToLocal s3://#{PERSONAL_BUCKET_NAME}/ganglia-installer .")
else
executor.run("hadoop fs -copyToLocal s3://#{BUCKET_NAME}/bootstrap-actions/ganglia/amz/ganglia-installer .")
end
executor.run("chmod +x ganglia-installer")
executor.run("sudo ./ganglia-installer")
end
end
logger = Emr::Logger.new
retriesLeft = 1
begin
Installer.new.install_ganglia
rescue Exception => e
logger.log "Failed to install ganglia: #{e.to_s}"
retriesLeft = retriesLeft - 1
if retriesLeft > 0
logger.log "Retrying with #{retriesLeft} attemps remaining"
retry
end
logger.log "Failed to install ganglia"
raise
end