mandy 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.9
1
+ 0.5.10
data/bin/mandy CHANGED
@@ -2,24 +2,8 @@
2
2
  require "rubygems"
3
3
  require "mandy"
4
4
 
5
- # Hadoop Home Detection
6
- hadoop_home = `echo $HADOOP_HOME`.chomp
7
-
8
- if hadoop_home== ''
9
- puts "You need to set the HADOOP_HOME environment variable to point to your hadoop install :("
10
- puts "Try setting 'export HADOOP_HOME=/my/hadoop/path' in your ~/.profile maybe?"
11
- exit(1)
12
- end
13
-
14
- # Hadoop Version Detection
15
- hadoop_version = `$HADOOP_HOME/bin/hadoop version 2>&1`
16
-
17
- if hadoop_version =~ /No such file or directory/
18
- puts("Mandy failed to find Hadoop in #{hadoop_home} :(")
19
- puts
20
- puts hadoop_version
21
- exit(1)
22
- end
5
+ hadoop_home = HadoopConfiguration.check_home
6
+ hadoop_version = HadoopConfiguration.check_version
23
7
 
24
8
  # Status & Help Message
25
9
  puts "\nYou are running Mandy!"
data/bin/mandy-cat CHANGED
@@ -2,6 +2,12 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
10
+
5
11
  exec('mandy-cat -h') unless ARGV.size >= 2
6
12
 
7
13
  options = OpenStruct.new
data/bin/mandy-cp CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-cp -h') unless ARGV.size >= 2
6
11
 
7
12
 
data/bin/mandy-exists CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-exists -h') unless ARGV.size >= 2
6
11
 
7
12
 
data/bin/mandy-get CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-get -h') unless ARGV.size >= 2
6
11
 
7
12
  options = OpenStruct.new
data/bin/mandy-hadoop CHANGED
@@ -5,6 +5,11 @@ require 'optparse'
5
5
  require 'ostruct'
6
6
  require 'cgi'
7
7
 
8
+ require "rubygems"
9
+ require "mandy"
10
+
11
+ HadoopConfiguration.check_home_and_version
12
+
8
13
  errors = false
9
14
  options = OpenStruct.new
10
15
 
data/bin/mandy-install CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require "rubygems"
4
+ require "mandy"
5
+
6
+ HadoopConfiguration.check_home_and_version
7
+
3
8
  if ARGV.size==0
4
9
  puts "USAGE: mandy-install user@server1.com [user@server2.com ...]"
5
10
  exit
data/bin/mandy-kill CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-kill -h') unless ARGV.size >= 1
6
11
 
7
12
 
data/bin/mandy-local CHANGED
@@ -3,6 +3,11 @@ require 'optparse'
3
3
  require 'ostruct'
4
4
  require 'cgi'
5
5
 
6
+ require "rubygems"
7
+ require "mandy"
8
+
9
+ HadoopConfiguration.check_home_and_version
10
+
6
11
  options = OpenStruct.new
7
12
 
8
13
  OptionParser.new do |opts|
data/bin/mandy-map CHANGED
@@ -2,6 +2,8 @@
2
2
  require "rubygems"
3
3
  require "mandy"
4
4
 
5
+ HadoopConfiguration.check_home_and_version
6
+
5
7
  if ARGV.size==0
6
8
  puts "USAGE: mandy-map my_script.rb 'Job Name'"
7
9
  exit
data/bin/mandy-mkdir CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-mkdir -h') unless ARGV.size >= 2
6
11
 
7
12
 
data/bin/mandy-mv CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-mv -h') unless ARGV.size >= 2
6
11
 
7
12
 
data/bin/mandy-put CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-put -h') unless ARGV.size >= 2
6
11
 
7
12
 
data/bin/mandy-reduce CHANGED
@@ -2,6 +2,8 @@
2
2
  require "rubygems"
3
3
  require "mandy"
4
4
 
5
+ HadoopConfiguration.check_home_and_version
6
+
5
7
  if ARGV.size==0
6
8
  puts "USAGE: mandy-reduce my_script.rb 'Job Name' [payload]"
7
9
  exit
data/bin/mandy-rm CHANGED
@@ -2,6 +2,11 @@
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
4
 
5
+ require "rubygems"
6
+ require "mandy"
7
+
8
+ HadoopConfiguration.check_home_and_version
9
+
5
10
  exec('mandy-rm -h') unless ARGV.size >= 1
6
11
 
7
12
 
@@ -13,7 +18,11 @@ OptionParser.new do |opts|
13
18
  opts.on("-c", "--conf HADOOP_CONF", "Use this cluster xml config file.") do |config|
14
19
  options.config = config
15
20
  end
16
-
21
+
22
+ opts.on("-f", "--force", "Use this paramter to force deletion of a relative folder, root folder or 1st level folder (like /home or /tmp)") do
23
+ options.force = true
24
+ end
25
+
17
26
  opts.on_tail("-h", "--help", "Show this message") do
18
27
  puts opts
19
28
  exit
@@ -23,4 +32,14 @@ end.parse!
23
32
  file = ARGV[0]
24
33
  config = options.config || 'cluster.xml'
25
34
 
35
+ if !options.force and file =~ /^[^\/]/
36
+ puts "mandy-rm: Cowardly refusing to delete a relative folder. Use -f parameter to force command."
37
+ exit
38
+ end
39
+
40
+ if !options.force and File.expand_path(file).split("/").size <= 2
41
+ puts "mandy-rm: Cowardly refusing to delete a root or 1st level folder. Use -f parameter to force command."
42
+ exit
43
+ end
44
+
26
45
  `$HADOOP_HOME/bin/hadoop fs -conf #{config} -rmr #{file}`
data/lib/mandy.rb CHANGED
@@ -10,6 +10,7 @@ require "fileutils"
10
10
  dsl
11
11
  job
12
12
  packer
13
+ configuration/hadoop_configuration
13
14
  support/tuple
14
15
  support/array_serializer
15
16
  support/hdfs_location
@@ -30,6 +31,8 @@ require "fileutils"
30
31
  errors
31
32
  ).each {|file| require File.join(File.dirname(__FILE__), 'mandy', file) }
32
33
 
34
+ include HadoopConfiguration
35
+
33
36
  module Mandy
34
37
  class << self
35
38
  attr_accessor :local_input
@@ -0,0 +1,28 @@
1
+ module HadoopConfiguration
2
+ def check_home
3
+ hadoop_home = `echo $HADOOP_HOME`.chomp
4
+ if hadoop_home== ''
5
+ puts "You need to set the HADOOP_HOME environment variable to point to your hadoop install :("
6
+ puts "Try setting 'export HADOOP_HOME=/my/hadoop/path' in your ~/.profile maybe?"
7
+ exit(1)
8
+ end
9
+ hadoop_home
10
+ end
11
+
12
+ def check_version
13
+ hadoop_version = `$HADOOP_HOME/bin/hadoop version 2>&1`
14
+
15
+ if hadoop_version =~ /No such file or directory/
16
+ puts("Mandy failed to find Hadoop in #{check_home} :(")
17
+ puts
18
+ puts hadoop_version
19
+ exit(1)
20
+ end
21
+ hadoop_version
22
+ end
23
+
24
+ def check_home_and_version
25
+ check_home
26
+ check_version
27
+ end
28
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 5
9
- - 9
10
- version: 0.5.9
8
+ - 10
9
+ version: 0.5.10
11
10
  platform: ruby
12
11
  authors:
13
12
  - Andy Kent
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- hash: 3
31
29
  segments:
32
30
  - 0
33
31
  version: "0"
@@ -78,6 +76,7 @@ files:
78
76
  - geminstaller.yml
79
77
  - lib/mandy.rb
80
78
  - lib/mandy/errors.rb
79
+ - lib/mandy/configuration/hadoop_configuration.rb
81
80
  - lib/mandy/support/tuple.rb
82
81
  - lib/mandy/support/formatting.rb
83
82
  - lib/mandy/support/array_serializer.rb
@@ -118,7 +117,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
117
  requirements:
119
118
  - - ">="
120
119
  - !ruby/object:Gem::Version
121
- hash: 3
122
120
  segments:
123
121
  - 0
124
122
  version: "0"
@@ -127,7 +125,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
125
  requirements:
128
126
  - - ">="
129
127
  - !ruby/object:Gem::Version
130
- hash: 3
131
128
  segments:
132
129
  - 0
133
130
  version: "0"