trafficbroker-mandy 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/mandy-hadoop +14 -6
- data/lib/dsl.rb +8 -0
- data/lib/job.rb +3 -0
- metadata +1 -1
data/bin/mandy-hadoop
CHANGED
@@ -4,17 +4,25 @@ def absolute_path(path)
|
|
4
4
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
5
5
|
end
|
6
6
|
|
7
|
-
file =
|
7
|
+
file = ARGV[0]
|
8
|
+
filename = File.basename(file)
|
8
9
|
input = ARGV[1]
|
9
10
|
output = ARGV[2]
|
10
11
|
config = ARGV[3]
|
11
12
|
|
12
|
-
require file
|
13
|
+
require absolute_path(file)
|
13
14
|
|
14
|
-
|
15
|
+
jobconf = Mandy::Job.default.settings.map { |key, value| %(-jobconf #{key}="#{value}") }.join(' ')
|
16
|
+
|
17
|
+
command = %($HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/contrib/streaming/hadoop-*-streaming.jar \
|
15
18
|
-additionalconfspec "#{config}" \
|
16
19
|
-input "#{input}" \
|
17
|
-
-mapper "mandy-map #{
|
18
|
-
-reducer "mandy-reduce #{
|
20
|
+
-mapper "mandy-map #{filename}" \
|
21
|
+
-reducer "mandy-reduce #{filename}" \
|
19
22
|
-file "#{file}" \
|
20
|
-
-output "#{output}"
|
23
|
+
-output "#{output}" \
|
24
|
+
#{jobconf})
|
25
|
+
|
26
|
+
`#{command}`
|
27
|
+
|
28
|
+
# puts "#{command}"
|
data/lib/dsl.rb
CHANGED
@@ -5,6 +5,14 @@ module Mandy
|
|
5
5
|
Mandy::Job.default = Mandy::Job.new('Untitled Job')
|
6
6
|
end
|
7
7
|
|
8
|
+
def set(key, value)
|
9
|
+
Mandy::Job.default.settings[key.to_s] = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def job_name(name)
|
13
|
+
set "mapred.job.name", name.to_s
|
14
|
+
end
|
15
|
+
|
8
16
|
def map(&blk)
|
9
17
|
Mandy::Job.default.map(&blk)
|
10
18
|
end
|
data/lib/job.rb
CHANGED