trafficbroker-mandy 0.2.4.6 → 0.2.5
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-get +18 -5
- data/bin/mandy-hadoop +25 -7
- data/bin/mandy-put +17 -5
- data/bin/mandy-rm +17 -5
- data/lib/packer.rb +5 -0
- metadata +1 -1
data/bin/mandy-get
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
options = OpenStruct.new
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "USAGE: mandy-get hdfs_file_location local_file_destination [options]"
|
9
|
+
|
10
|
+
opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
|
11
|
+
options.config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
15
|
+
puts opts
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end.parse!
|
2
19
|
|
3
|
-
if ARGV.size==0
|
4
|
-
puts "USAGE: mandy-get hdfs_file_location local_file_destination cluster-config.xml"
|
5
|
-
exit
|
6
|
-
end
|
7
20
|
|
8
21
|
def absolute_path(path)
|
9
22
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
@@ -11,6 +24,6 @@ end
|
|
11
24
|
|
12
25
|
remote_file = ARGV[0]
|
13
26
|
local_file = ARGV[1]
|
14
|
-
config = absolute_path(
|
27
|
+
config = absolute_path(options.config || 'cluster.xml')
|
15
28
|
|
16
29
|
`$HADOOP_HOME/bin/hadoop fs -conf #{config} -getmerge #{remote_file} #{local_file}`
|
data/bin/mandy-hadoop
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "rubygems"
|
3
3
|
require "mandy"
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
options = OpenStruct.new
|
8
|
+
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "USAGE: mandy-hadoop script input output [options]"
|
11
|
+
|
12
|
+
opts.on("-p", "--payload PAYLOAD", "Add a working directory to be sent to the cluster.") do |payload|
|
13
|
+
options.payload = payload
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
|
17
|
+
options.config = config
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end.parse!
|
4
25
|
|
5
26
|
def absolute_path(path)
|
6
27
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
7
28
|
end
|
8
29
|
|
9
|
-
if ARGV.size==0
|
10
|
-
puts "USAGE: mandy-hadoop my_script.rb input_file_or_folder_on_hdfs output_folder_on_hdfs cluster-config.xml [payload]"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
|
14
30
|
file = ARGV[0]
|
15
31
|
filename = File.basename(file)
|
16
32
|
input = ARGV[1]
|
17
33
|
output_folder = ARGV[2]
|
18
|
-
config =
|
19
|
-
payload =
|
34
|
+
config = options.config || 'cluster.xml'
|
35
|
+
payload = options.payload ? Mandy::Packer.pack(options.payload) : ARGV[0]
|
36
|
+
|
37
|
+
at_exit { Mandy::Packer.cleanup!(payload) }
|
20
38
|
|
21
39
|
require absolute_path(file)
|
22
40
|
|
data/bin/mandy-put
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
options = OpenStruct.new
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "USAGE: mandy-put local_file_or_folder hdfs_destination_location [options]"
|
9
|
+
|
10
|
+
opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
|
11
|
+
options.config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
15
|
+
puts opts
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end.parse!
|
7
19
|
|
8
20
|
def absolute_path(path)
|
9
21
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
@@ -11,6 +23,6 @@ end
|
|
11
23
|
|
12
24
|
source = absolute_path(ARGV[0])
|
13
25
|
dest = ARGV[1]
|
14
|
-
config =
|
26
|
+
config = options.config || 'cluster.xml'
|
15
27
|
|
16
28
|
`$HADOOP_HOME/bin/hadoop fs -conf #{config} -copyFromLocal #{source} #{dest}`
|
data/bin/mandy-rm
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
options = OpenStruct.new
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "USAGE: mandy-rm file_or_folder_on_hdfs [options]"
|
9
|
+
|
10
|
+
opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
|
11
|
+
options.config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
15
|
+
puts opts
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end.parse!
|
7
19
|
|
8
20
|
file = ARGV[0]
|
9
|
-
config =
|
21
|
+
config = options.config || 'cluster.xml'
|
10
22
|
|
11
23
|
`$HADOOP_HOME/bin/hadoop fs -conf #{config} -rmr #{file}`
|
data/lib/packer.rb
CHANGED