masamune 0.15.6 → 0.16.0

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.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/Rakefile +1 -1
  4. data/bin/{masamune-elastic-mapreduce → masamune-aws-emr} +3 -3
  5. data/bin/masamune-dump +1 -1
  6. data/bin/masamune-hive +1 -1
  7. data/bin/masamune-psql +1 -1
  8. data/bin/masamune-shell +1 -1
  9. data/lib/masamune.rb +1 -1
  10. data/lib/masamune/actions.rb +1 -1
  11. data/lib/masamune/actions/{elastic_mapreduce.rb → aws_emr.rb} +14 -30
  12. data/lib/masamune/actions/data_flow.rb +1 -1
  13. data/lib/masamune/actions/date_parse.rb +1 -1
  14. data/lib/masamune/actions/execute.rb +1 -1
  15. data/lib/masamune/actions/filesystem.rb +1 -1
  16. data/lib/masamune/actions/hadoop_filesystem.rb +1 -1
  17. data/lib/masamune/actions/hadoop_streaming.rb +10 -8
  18. data/lib/masamune/actions/hive.rb +2 -2
  19. data/lib/masamune/actions/invoke_parallel.rb +1 -1
  20. data/lib/masamune/actions/postgres.rb +1 -1
  21. data/lib/masamune/actions/postgres_admin.rb +1 -1
  22. data/lib/masamune/actions/s3cmd.rb +1 -1
  23. data/lib/masamune/actions/transform.rb +1 -1
  24. data/lib/masamune/after_initialize_callbacks.rb +1 -1
  25. data/lib/masamune/cached_filesystem.rb +2 -2
  26. data/lib/masamune/commands.rb +1 -1
  27. data/lib/masamune/commands/{elastic_mapreduce.rb → aws_emr.rb} +38 -29
  28. data/lib/masamune/commands/hadoop_filesystem.rb +1 -1
  29. data/lib/masamune/commands/hadoop_streaming.rb +1 -1
  30. data/lib/masamune/commands/hive.rb +1 -1
  31. data/lib/masamune/commands/postgres.rb +1 -1
  32. data/lib/masamune/commands/postgres_admin.rb +1 -1
  33. data/lib/masamune/commands/postgres_common.rb +1 -1
  34. data/lib/masamune/commands/retry_with_backoff.rb +1 -1
  35. data/lib/masamune/commands/s3cmd.rb +1 -1
  36. data/lib/masamune/commands/shell.rb +11 -7
  37. data/lib/masamune/configuration.rb +2 -38
  38. data/lib/masamune/data_plan.rb +1 -1
  39. data/lib/masamune/data_plan/builder.rb +1 -1
  40. data/lib/masamune/data_plan/elem.rb +1 -1
  41. data/lib/masamune/data_plan/engine.rb +1 -1
  42. data/lib/masamune/data_plan/rule.rb +1 -1
  43. data/lib/masamune/data_plan/set.rb +1 -1
  44. data/lib/masamune/environment.rb +1 -1
  45. data/lib/masamune/filesystem.rb +1 -1
  46. data/lib/masamune/has_environment.rb +1 -1
  47. data/lib/masamune/helpers.rb +1 -1
  48. data/lib/masamune/helpers/postgres.rb +1 -1
  49. data/lib/masamune/io.rb +1 -1
  50. data/lib/masamune/last_element.rb +1 -1
  51. data/lib/masamune/method_logger.rb +1 -1
  52. data/lib/masamune/multi_io.rb +1 -1
  53. data/lib/masamune/schema.rb +1 -1
  54. data/lib/masamune/schema/catalog.rb +1 -1
  55. data/lib/masamune/schema/column.rb +1 -1
  56. data/lib/masamune/schema/dimension.rb +1 -1
  57. data/lib/masamune/schema/fact.rb +1 -1
  58. data/lib/masamune/schema/map.rb +1 -1
  59. data/lib/masamune/schema/row.rb +1 -1
  60. data/lib/masamune/schema/store.rb +1 -1
  61. data/lib/masamune/schema/table.rb +1 -1
  62. data/lib/masamune/schema/table_reference.rb +1 -1
  63. data/lib/masamune/spec_helper.rb +1 -1
  64. data/lib/masamune/string_format.rb +1 -1
  65. data/lib/masamune/tasks/aws_emr_thor.rb +79 -0
  66. data/lib/masamune/tasks/dump_thor.rb +1 -1
  67. data/lib/masamune/tasks/hive_thor.rb +2 -2
  68. data/lib/masamune/tasks/postgres_thor.rb +1 -1
  69. data/lib/masamune/tasks/shell_thor.rb +1 -1
  70. data/lib/masamune/template.rb +1 -1
  71. data/lib/masamune/thor.rb +1 -1
  72. data/lib/masamune/topological_hash.rb +1 -1
  73. data/lib/masamune/transform.rb +1 -1
  74. data/lib/masamune/transform/bulk_upsert.rb +1 -1
  75. data/lib/masamune/transform/common.rb +1 -1
  76. data/lib/masamune/transform/common/denormalize_table.rb +1 -1
  77. data/lib/masamune/transform/consolidate_dimension.rb +1 -1
  78. data/lib/masamune/transform/deduplicate_dimension.rb +1 -1
  79. data/lib/masamune/transform/define_schema.rb +1 -1
  80. data/lib/masamune/transform/define_table.rb +1 -1
  81. data/lib/masamune/transform/denormalize_table.rb +1 -1
  82. data/lib/masamune/transform/hive.rb +1 -1
  83. data/lib/masamune/transform/hive/define_schema.hql.erb +1 -1
  84. data/lib/masamune/transform/hive/define_table.hql.erb +1 -1
  85. data/lib/masamune/transform/hive/define_table.rb +1 -1
  86. data/lib/masamune/transform/hive/denormalize_table.hql.erb +1 -1
  87. data/lib/masamune/transform/hive/denormalize_table.rb +1 -1
  88. data/lib/masamune/transform/insert_reference_values.rb +1 -1
  89. data/lib/masamune/transform/load_dimension.rb +1 -1
  90. data/lib/masamune/transform/load_fact.rb +1 -1
  91. data/lib/masamune/transform/operator.rb +1 -1
  92. data/lib/masamune/transform/postgres.rb +1 -1
  93. data/lib/masamune/transform/postgres/bulk_upsert.psql.erb +1 -1
  94. data/lib/masamune/transform/postgres/bulk_upsert.rb +1 -1
  95. data/lib/masamune/transform/postgres/deduplicate_dimension.psql.erb +1 -1
  96. data/lib/masamune/transform/postgres/deduplicate_dimension.rb +1 -1
  97. data/lib/masamune/transform/postgres/define_foreign_key.psql.erb +1 -1
  98. data/lib/masamune/transform/postgres/define_index.psql.erb +1 -1
  99. data/lib/masamune/transform/postgres/define_inheritance.psql.erb +1 -1
  100. data/lib/masamune/transform/postgres/define_schema.psql.erb +1 -1
  101. data/lib/masamune/transform/postgres/define_table.psql.erb +1 -1
  102. data/lib/masamune/transform/postgres/define_table.rb +1 -1
  103. data/lib/masamune/transform/postgres/define_unique.psql.erb +1 -1
  104. data/lib/masamune/transform/postgres/denormalize_table.psql.erb +1 -1
  105. data/lib/masamune/transform/postgres/denormalize_table.rb +1 -1
  106. data/lib/masamune/transform/postgres/insert_reference_values.psql.erb +1 -1
  107. data/lib/masamune/transform/postgres/insert_reference_values.rb +1 -1
  108. data/lib/masamune/transform/postgres/relabel_dimension.psql.erb +1 -1
  109. data/lib/masamune/transform/postgres/relabel_dimension.rb +1 -1
  110. data/lib/masamune/transform/postgres/replace_table.psql.erb +1 -1
  111. data/lib/masamune/transform/postgres/rollup_fact.psql.erb +1 -1
  112. data/lib/masamune/transform/postgres/rollup_fact.rb +1 -1
  113. data/lib/masamune/transform/postgres/snapshot_dimension.psql.erb +1 -1
  114. data/lib/masamune/transform/postgres/snapshot_dimension.rb +1 -1
  115. data/lib/masamune/transform/postgres/stage_dimension.psql.erb +1 -1
  116. data/lib/masamune/transform/postgres/stage_dimension.rb +1 -1
  117. data/lib/masamune/transform/postgres/stage_fact.psql.erb +1 -1
  118. data/lib/masamune/transform/postgres/stage_fact.rb +1 -1
  119. data/lib/masamune/transform/relabel_dimension.rb +1 -1
  120. data/lib/masamune/transform/rollup_fact.rb +1 -1
  121. data/lib/masamune/transform/snapshot_dimension.rb +1 -1
  122. data/lib/masamune/transform/stage_dimension.rb +1 -1
  123. data/lib/masamune/transform/stage_fact.rb +1 -1
  124. data/lib/masamune/version.rb +2 -2
  125. data/spec/fixtures/aggregate.sql.erb +1 -1
  126. data/spec/fixtures/comment.sql.erb +1 -1
  127. data/spec/fixtures/invalid.sql.erb +1 -1
  128. data/spec/fixtures/relative.sql.erb +1 -1
  129. data/spec/fixtures/simple.sql.erb +1 -1
  130. data/spec/fixtures/whitespace.sql.erb +1 -1
  131. data/spec/masamune/actions/{elastic_mapreduce_spec.rb → aws_emr_spec.rb} +22 -42
  132. data/spec/masamune/actions/execute_spec.rb +1 -1
  133. data/spec/masamune/actions/hadoop_filesystem_spec.rb +1 -1
  134. data/spec/masamune/actions/hadoop_streaming_spec.rb +8 -8
  135. data/spec/masamune/actions/hive_spec.rb +5 -5
  136. data/spec/masamune/actions/invoke_parallel_spec.rb +1 -1
  137. data/spec/masamune/actions/postgres_admin_spec.rb +1 -1
  138. data/spec/masamune/actions/postgres_spec.rb +1 -1
  139. data/spec/masamune/actions/s3cmd_spec.rb +1 -1
  140. data/spec/masamune/actions/transform_spec.rb +1 -1
  141. data/spec/masamune/after_initialization_callbacks_spec.rb +1 -1
  142. data/spec/masamune/cached_filesystem_spec.rb +1 -1
  143. data/spec/masamune/commands/aws_emr_spec.rb +115 -0
  144. data/spec/masamune/commands/hadoop_filesystem_spec.rb +1 -1
  145. data/spec/masamune/commands/hadoop_streaming_spec.rb +1 -1
  146. data/spec/masamune/commands/hive_spec.rb +1 -1
  147. data/spec/masamune/commands/postgres_admin_spec.rb +1 -1
  148. data/spec/masamune/commands/postgres_spec.rb +1 -1
  149. data/spec/masamune/commands/retry_with_backoff_spec.rb +1 -1
  150. data/spec/masamune/commands/s3cmd_spec.rb +1 -1
  151. data/spec/masamune/commands/shell_spec.rb +79 -2
  152. data/spec/masamune/configuration_spec.rb +1 -65
  153. data/spec/masamune/data_plan/builder_spec.rb +1 -1
  154. data/spec/masamune/data_plan/elem_spec.rb +1 -1
  155. data/spec/masamune/data_plan/engine_spec.rb +1 -1
  156. data/spec/masamune/data_plan/rule_spec.rb +1 -1
  157. data/spec/masamune/data_plan/set_spec.rb +1 -1
  158. data/spec/masamune/environment_spec.rb +1 -1
  159. data/spec/masamune/filesystem_spec.rb +1 -1
  160. data/spec/masamune/helpers/postgres_spec.rb +1 -1
  161. data/spec/masamune/rspec/job_fixture_spec.rb +1 -1
  162. data/spec/masamune/rspec/mock_filesystem_spec.rb +1 -1
  163. data/spec/masamune/rspec/shared_example_group_spec.rb +1 -1
  164. data/spec/masamune/schema/catalog_spec.rb +1 -1
  165. data/spec/masamune/schema/column_spec.rb +1 -1
  166. data/spec/masamune/schema/dimension_spec.rb +1 -1
  167. data/spec/masamune/schema/fact_spec.rb +1 -1
  168. data/spec/masamune/schema/map_spec.rb +1 -1
  169. data/spec/masamune/schema/row_spec.rb +1 -1
  170. data/spec/masamune/schema/store_spec.rb +1 -1
  171. data/spec/masamune/schema/table_spec.rb +1 -1
  172. data/spec/masamune/string_format_spec.rb +1 -1
  173. data/spec/masamune/tasks/aws_emr_thor_spec.rb +69 -0
  174. data/spec/masamune/tasks/dump_thor_spec.rb +1 -1
  175. data/spec/masamune/tasks/hive_thor_spec.rb +1 -1
  176. data/spec/masamune/tasks/postgres_thor_spec.rb +1 -1
  177. data/spec/masamune/tasks/shell_thor_spec.rb +1 -1
  178. data/spec/masamune/template_spec.rb +1 -1
  179. data/spec/masamune/thor_spec.rb +1 -1
  180. data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +1 -1
  181. data/spec/masamune/transform/consolidate_dimension_spec.rb +1 -1
  182. data/spec/masamune/transform/deduplicate_dimension_spec.rb +1 -1
  183. data/spec/masamune/transform/define_schema_spec.rb +1 -1
  184. data/spec/masamune/transform/define_table.dimension_spec.rb +1 -1
  185. data/spec/masamune/transform/define_table.fact_spec.rb +1 -1
  186. data/spec/masamune/transform/define_table.table_spec.rb +1 -1
  187. data/spec/masamune/transform/denormalize_table_spec.rb +1 -1
  188. data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +1 -1
  189. data/spec/masamune/transform/insert_reference_values.fact_spec.rb +1 -1
  190. data/spec/masamune/transform/load_dimension_spec.rb +1 -1
  191. data/spec/masamune/transform/load_fact_spec.rb +1 -1
  192. data/spec/masamune/transform/relabel_dimension_spec.rb +1 -1
  193. data/spec/masamune/transform/rollup_fact_spec.rb +1 -1
  194. data/spec/masamune/transform/snapshot_dimension_spec.rb +1 -1
  195. data/spec/masamune/transform/stage_dimension_spec.rb +1 -1
  196. data/spec/masamune/transform/stage_fact_spec.rb +1 -1
  197. data/spec/masamune_spec.rb +1 -1
  198. data/spec/spec_helper.rb +1 -1
  199. data/spec/support/masamune/example_group.rb +1 -1
  200. data/spec/support/masamune/job_example_group.rb +1 -1
  201. data/spec/support/masamune/job_fixture.rb +1 -1
  202. data/spec/support/masamune/mock_command.rb +1 -1
  203. data/spec/support/masamune/mock_delegate.rb +1 -1
  204. data/spec/support/masamune/mock_filesystem.rb +1 -1
  205. data/spec/support/masamune/shared_example_group.rb +1 -1
  206. data/spec/support/masamune/step_example_group.rb +1 -1
  207. data/spec/support/masamune/step_fixture.rb +1 -1
  208. data/spec/support/masamune/task_example_group.rb +1 -1
  209. data/spec/support/masamune/thor_mute.rb +1 -1
  210. data/spec/support/rspec/example/action_example_group.rb +1 -1
  211. data/spec/support/rspec/example/task_example_group.rb +1 -1
  212. data/spec/support/rspec/example/transform_example_group.rb +1 -1
  213. data/spec/support/shared_examples/postgres_common_examples.rb +1 -1
  214. metadata +14 -13
  215. data/lib/masamune/commands/interactive.rb +0 -37
  216. data/lib/masamune/tasks/elastic_mapreduce_thor.rb +0 -61
  217. data/spec/masamune/tasks/elastic_mapreduce_thor_spec.rb +0 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b70cf7812702e987cc6c1f72d7f50cbb3ddde9b
4
- data.tar.gz: 2d487a59b8da26e186f2eefab0f7067b5e9f950f
3
+ metadata.gz: c8bcd874b8f53a052225b41043cfda18de823cec
4
+ data.tar.gz: 9e4c71e47097a5035be079b92ce9d2698d74c7b4
5
5
  SHA512:
6
- metadata.gz: 91777fd4da7e0928d678ce4574f91305da2673e8bbbbeed65ce892ac612808552afa68689906f70a54c8f61d4f592b821ecb4ae9e67588bb988a6dc38e2a07b7
7
- data.tar.gz: 76a2f706860eae74756e2c4b7a04e596913f3c0189e591d5c5f250681fcada14177be815f4033bede60ba1fa75a70a073d7a3bb91bac6692ab21c1ee04d8df3b
6
+ metadata.gz: 8e4b65c5424fdf38915854a32299cc7825418f96798c63719619a8cc4bfd7a69d81e286006974b5660a03cb3b020a677b7db838cf5efa0f03d79ff4cac209053
7
+ data.tar.gz: 8099dca87827675a761f9882025452d0c8bfd24773b09538006747e5b155d1ef9ec2f82a16bb16d5dc7b313aec748081d07541c332be5e633299c0dfeb88000c
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -22,5 +22,5 @@
22
22
  # THE SOFTWARE.
23
23
 
24
24
  $: << File.expand_path('../../lib/', __FILE__)
25
- require 'masamune/tasks/elastic_mapreduce_thor'
26
- Masamune::Tasks::ElasticMapreduceThor.start(ARGV)
25
+ require 'masamune/tasks/aws_emr_thor'
26
+ Masamune::Tasks::AwsEmrThor.start(ARGV)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # The MIT License (MIT)
3
3
  #
4
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
4
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -21,49 +21,33 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Masamune::Actions
24
- module ElasticMapreduce
24
+ module AwsEmr
25
25
  extend ActiveSupport::Concern
26
26
 
27
- def elastic_mapreduce(opts = {})
27
+ def aws_emr(opts = {})
28
28
  opts = opts.to_hash.symbolize_keys
29
- opts[:jobflow] = resolve_jobflow(opts[:jobflow]) if opts[:jobflow]
30
29
 
31
- command = Masamune::Commands::Interactive.new(environment, :interactive => opts.fetch(:interactive, false))
32
- command = Masamune::Commands::ElasticMapReduce.new(command, opts)
33
- command = Masamune::Commands::RetryWithBackoff.new(command, configuration.elastic_mapreduce.slice(:retries, :backoff).merge(opts))
30
+ command = Masamune::Commands::AwsEmr.new(environment, opts)
31
+ command = Masamune::Commands::RetryWithBackoff.new(command, configuration.aws_emr.slice(:retries, :backoff).merge(opts))
34
32
  command = Masamune::Commands::Shell.new(command, opts)
35
33
 
36
34
  command.interactive? ? command.replace : command.execute
37
35
  end
38
36
 
39
- def defined_jobflows
40
- @defined_jobflows ||= configuration.elastic_mapreduce.fetch(:jobflows, {}).symbolize_keys
41
- end
42
-
43
- def resolve_jobflow(jobflow)
44
- return unless jobflow
45
- defined_jobflows[jobflow.to_sym] || jobflow
46
- end
47
-
48
- def jobflow_required?
49
- extra.empty?
50
- end
51
-
52
- def validate_jobflow!
53
- return unless jobflow_required?
54
- jobflow = configuration.elastic_mapreduce[:jobflow]
55
- raise ::Thor::RequiredArgumentMissingError, "No value provided for required options '--jobflow'" unless jobflow
56
- raise ::Thor::RequiredArgumentMissingError, %Q(Value '#{jobflow}' for '--jobflow' doesn't exist) unless elastic_mapreduce(extra: '--list', jobflow: jobflow, fail_fast: false).success?
37
+ def validate_cluster_id!
38
+ cluster_id = configuration.aws_emr[:cluster_id]
39
+ raise ::Thor::RequiredArgumentMissingError, "No value provided for required options '--cluster-id'" unless cluster_id
40
+ raise ::Thor::RequiredArgumentMissingError, %Q(AWS EMR cluster '#{cluster_id}' does not exist) unless aws_emr(action: 'describe-cluster', cluster_id: cluster_id, fail_fast: false).success?
57
41
  end
58
42
 
59
43
  included do |base|
60
- base.class_option :jobflow, :aliases => '-j', :desc => 'Elastic MapReduce jobflow ID (Hint: elastic-mapreduce --list)' if defined?(base.class_option)
44
+ base.class_option :cluster_id, :desc => "AWS EMR cluster_id ID (Hint: `masamune-emr-aws list-clusters`)" if defined?(base.class_option)
61
45
  base.after_initialize(:early) do |thor, options|
62
- next unless thor.configuration.elastic_mapreduce.any?
63
- next unless thor.configuration.elastic_mapreduce.fetch(:enabled, true)
64
- thor.configuration.elastic_mapreduce[:jobflow] = thor.resolve_jobflow(options[:jobflow] || thor.configuration.elastic_mapreduce[:jobflow])
46
+ next unless thor.configuration.aws_emr.any?
47
+ next unless thor.configuration.aws_emr.fetch(:enabled, true)
48
+ thor.configuration.aws_emr[:cluster_id] = options[:cluster_id] if options[:cluster_id]
65
49
  next unless options[:initialize]
66
- thor.validate_jobflow!
50
+ thor.validate_cluster_id!
67
51
  end if defined?(base.after_initialize)
68
52
  end
69
53
  end
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -25,17 +25,19 @@ module Masamune::Actions
25
25
  def hadoop_streaming(opts = {})
26
26
  opts = opts.to_hash.symbolize_keys
27
27
 
28
- command = if configuration.elastic_mapreduce[:jobflow]
29
- Masamune::Commands::HadoopStreaming.new(environment, opts.merge(quote: true, upload: false))
30
- else
31
- Masamune::Commands::HadoopStreaming.new(environment, opts)
32
- end
33
-
34
- command = Masamune::Commands::ElasticMapReduce.new(command, opts.except(:extra)) if configuration.elastic_mapreduce[:jobflow]
28
+ command = Masamune::Commands::HadoopStreaming.new(environment, aws_emr_options(opts))
29
+ command = Masamune::Commands::AwsEmr.new(command, opts.except(:extra)) if configuration.aws_emr[:cluster_id]
35
30
  command = Masamune::Commands::RetryWithBackoff.new(command, configuration.hadoop_streaming.slice(:retries, :backoff).merge(opts))
36
31
  command = Masamune::Commands::Shell.new(command, opts)
37
32
 
38
33
  command.execute
39
34
  end
35
+
36
+ private
37
+
38
+ def aws_emr_options(opts = {})
39
+ return opts unless configuration.aws_emr[:cluster_id]
40
+ opts.merge(quote: true, upload: false)
41
+ end
40
42
  end
41
43
  end
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -33,7 +33,7 @@ module Masamune::Actions
33
33
  opts.merge!(block: block.to_proc) if block_given?
34
34
 
35
35
  command = Masamune::Commands::Hive.new(environment, opts)
36
- command = Masamune::Commands::ElasticMapReduce.new(command, opts.except(:extra)) if configuration.elastic_mapreduce[:jobflow]
36
+ command = Masamune::Commands::AwsEmr.new(command, opts.except(:extra)) if configuration.aws_emr[:cluster_id]
37
37
  command = Masamune::Commands::RetryWithBackoff.new(command, configuration.hive.slice(:retries, :backoff).merge(opts))
38
38
  command = Masamune::Commands::Shell.new(command, opts)
39
39
 
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,7 @@ module Masamune
36
36
  end
37
37
 
38
38
  def exists?(file)
39
- glob(file, max_depth: 0).include?(file) || @cache.any?(file)
39
+ glob(file, max_depth: 0).include?(file)
40
40
  end
41
41
 
42
42
  def glob(file_or_glob, options = {})
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
  #
3
- # Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
3
+ # Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the "Software"), to deal
@@ -25,22 +25,23 @@ require 'delegate'
25
25
  require 'masamune/actions/execute'
26
26
 
27
27
  module Masamune::Commands
28
- class ElasticMapReduce < SimpleDelegator
28
+ class AwsEmr < SimpleDelegator
29
29
  include Masamune::Actions::Execute
30
30
 
31
31
  DEFAULT_ATTRIBUTES =
32
32
  {
33
- :path => 'elastic-mapreduce',
34
- :options => [],
35
- :extra => [],
36
- :jobflow => nil,
37
- :input => nil,
33
+ :path => 'aws',
34
+ :extra => [],
35
+ :config_file => nil,
36
+ :action => nil,
37
+ :cluster_id => nil,
38
+ :interactive => false
38
39
  }
39
40
 
40
41
  def initialize(delegate, attrs = {})
41
42
  super delegate
42
43
  @delegate = delegate
43
- DEFAULT_ATTRIBUTES.merge(configuration.elastic_mapreduce).merge(attrs).each do |name, value|
44
+ DEFAULT_ATTRIBUTES.merge(configuration.aws_emr).merge(attrs).each do |name, value|
44
45
  instance_variable_set("@#{name}", value)
45
46
  end
46
47
  end
@@ -48,55 +49,55 @@ module Masamune::Commands
48
49
  def interactive?
49
50
  if @delegate.respond_to?(:interactive?)
50
51
  @delegate.interactive?
51
- elsif @extra.any?
52
- true
53
52
  else
54
- @input == nil
53
+ @interactive
55
54
  end
56
55
  end
57
56
 
58
- def stdin
59
- if @delegate.respond_to?(:stdin)
60
- @delegate.stdin
61
- elsif @input
62
- @stdin ||= StringIO.new(@input)
63
- end
64
- end
65
-
66
- def elastic_mapreduce_command
57
+ def aws_emr_command
67
58
  args = []
68
59
  args << @path
69
- args << @options.map(&:to_a)
70
- args << ['--jobflow', @jobflow] if @jobflow
71
- args.flatten
60
+ args << 'emr'
61
+ args << action
62
+ args << 'cluster-running' if @action == 'wait'
63
+ args << action_options.map(&:to_a)
64
+ args << ['--cluster-id', @cluster_id] if @cluster_id
65
+ args
72
66
  end
73
67
 
74
68
  def ssh_args
75
69
  args = []
76
- args << elastic_mapreduce_command
77
- args << '--ssh'
70
+ args << aws_emr_command
71
+ args << '--command'
78
72
  args << 'exit'
79
73
  args.flatten
80
74
  end
81
75
 
82
- # Use elastic-mapreduce to translate jobflow into raw ssh command
76
+ # Use `aws emr` to translate cluster_id into raw ssh command
83
77
  def ssh_command
84
78
  @ssh_command ||= begin
85
79
  result = nil
86
80
  execute(*ssh_args, fail_fast: true, safe: true) do |line|
81
+ next if result
87
82
  if line =~ /exit\Z/
88
83
  result = line.sub(/ exit\Z/, '').split(' ')
89
84
  else
90
- logger.error(line)
85
+ logger.debug(line)
91
86
  end
92
87
  end
93
88
  result
94
89
  end
95
90
  end
96
91
 
92
+ def command_env
93
+ {}.tap do |env|
94
+ env['AWS_CONFIG_FILE'] = @config_file if @config_file
95
+ end
96
+ end
97
+
97
98
  def command_args
98
99
  args = []
99
- args << (ssh_command? ? ssh_command : elastic_mapreduce_command)
100
+ args << (ssh_command? ? ssh_command : aws_emr_command)
100
101
  args << @extra
101
102
  args << @delegate.command_args if @delegate.respond_to?(:command_args)
102
103
  args.flatten
@@ -112,8 +113,16 @@ module Masamune::Commands
112
113
 
113
114
  private
114
115
 
116
+ def action
117
+ @action || 'ssh'
118
+ end
119
+
120
+ def action_options
121
+ configuration.aws_emr.fetch(action.underscore.to_sym, {}).with_indifferent_access.fetch(:options, {}).reject { |key, _| @extra.include?(key.to_s) }
122
+ end
123
+
115
124
  def ssh_command?
116
- @delegate.respond_to?(:command_args) || @input.present?
125
+ @delegate.respond_to?(:command_args)
117
126
  end
118
127
  end
119
128
  end