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 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(ARGV[2])
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 = ARGV[3]
19
- payload = ARGV[4] ? Mandy::Packer.pack(ARGV[4]) : ARGV[0]
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
- if ARGV.size==0
4
- puts "USAGE: mandy-put local_file_or_folder hdfs_destination_location cluster-config.xml"
5
- exit
6
- end
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 = absolute_path(ARGV[2])
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
- if ARGV.size==0
4
- puts "USAGE: mandy-rm file_or_folder_on_hdfs cluster-config.xml"
5
- exit
6
- end
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 = ARGV[1]
21
+ config = options.config || 'cluster.xml'
10
22
 
11
23
  `$HADOOP_HOME/bin/hadoop fs -conf #{config} -rmr #{file}`
data/lib/packer.rb CHANGED
@@ -16,5 +16,10 @@ module Mandy
16
16
  return false unless File.extname(file) == '.tar'
17
17
  `tar -xf #{file}`
18
18
  end
19
+
20
+ def self.cleanup!(file)
21
+ return false unless File.extname(file) == '.tar'
22
+ `rm #{file}`
23
+ end
19
24
  end
20
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trafficbroker-mandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4.6
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Kent