jruby_whirr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rvmrc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ target/
20
+ whirr.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jruby_whirr.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Xianheng Ma
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # JrubyWhirr
2
+
3
+ jruby_whirr is a Jruby gem of Apache Whirr. Apache Whirr is a set of libraries for running cloud services.
4
+
5
+ Whirr provides:
6
+ A cloud-neutral way to run services. You don't have to worry about the idiosyncrasies of each provider.
7
+ A common service API. The details of provisioning are particular to the service.
8
+ Smart defaults for services. You can get a properly configured system running quickly, while still being able to override settings as needed.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'jruby_whirr'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install jruby_whirr
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/hadoop.properties ADDED
@@ -0,0 +1,97 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ #
19
+ # Setup an Apache Hadoop Cluster
20
+ #
21
+
22
+ # Read the Configuration Guide for more info:
23
+ # http://whirr.apache.org/docs/latest/configuration-guide.html
24
+
25
+ # Change the cluster name here
26
+ whirr.cluster-name=hadoop
27
+
28
+ # Change the name of cluster admin user
29
+ whirr.cluster-user=${sys:user.name}
30
+
31
+ # Change the number of machines in the cluster here
32
+ whirr.instance-templates=1 hadoop-namenode+hadoop-jobtracker,5 hadoop-datanode+hadoop-tasktracker
33
+
34
+ #
35
+ # Customise instance type or template / AMI per instance template
36
+ #
37
+
38
+ # whirr.templates.hadoop-namenode+hadoop.jobtracker.hardware-id=m1.xlarge
39
+ # whirr.templates.hadoop-datanode+hadoop.tasktracker.image-id=us-east-1/ami-da0cf8b3
40
+
41
+ #
42
+ # Uncomment out the following two lines to run CDH
43
+ #
44
+
45
+ #whirr.hadoop.install-function=install_cdh_hadoop
46
+ #whirr.hadoop.configure-function=configure_cdh_hadoop
47
+
48
+ #
49
+ # Customise instance types & AMI for Amazon EC2
50
+ #
51
+
52
+ # Use a specific instance type. See http://aws.amazon.com/ec2/instance-types/
53
+ # whirr.hardware-id=c1.xlarge
54
+
55
+ # Ubuntu 10.04 LTS Lucid. See http://cloud.ubuntu.com/ami/
56
+ # whirr.image-id=us-east-1/ami-35de095c
57
+
58
+ # You can also specify the spot instance price: http://aws.amazon.com/ec2/spot-instances/
59
+ # whirr.aws-ec2-spot-price=0.15
60
+
61
+ #
62
+ # Or for Rackspace Cloud
63
+ #
64
+
65
+ # The size of the instance to use. See http://www.rackspacecloud.com/cloud_hosting_products/servers/faq/
66
+ # id 3: 1GB, 1 virtual core
67
+ # id 4: 2GB, 2 virtual cores
68
+ # id 5: 4GB, 2 virtual cores
69
+ # id 6: 8GB, 4 virtual cores
70
+ # id 7: 15.5GB, 4 virtual cores
71
+ # whirr.hardware-id=6
72
+ # Ubuntu 10.04 LTS Lucid
73
+ # whirr.image-id=49
74
+
75
+ #
76
+ # By default use the user system SSH keys. Override them here.
77
+ #
78
+
79
+ # whirr.private-key-file=${sys:user.home}/.ssh/id_rsa
80
+ # whirr.public-key-file=${whirr.private-key-file}.pub
81
+
82
+ #
83
+ # Expert: override Hadoop properties by setting properties with the prefix
84
+ #
85
+
86
+ # hadoop-common, hadoop-hdfs, hadoop-mapreduce to set Common, HDFS, MapReduce
87
+ # site properties, respectively. The prefix is removed by Whirr, so that for
88
+ # example, setting
89
+ # hadoop-common.fs.trash.interval=1440
90
+ # will result in fs.trash.interval being set to 1440 in core-site.xml.
91
+
92
+ #
93
+ # Expert: specify the version of Hadoop to install.
94
+ #
95
+
96
+ #whirr.hadoop.version=1.0.4
97
+ #whirr.hadoop.tarball.url=http://archive.apache.org/dist/hadoop/core/hadoop-${whirr.hadoop.version}/hadoop-${whirr.hadoop.version}.tar.gz
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jruby_whirr/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jruby_whirr"
8
+ spec.version = JrubyWhirr::VERSION
9
+ spec.authors = ["Xianheng Ma"]
10
+ spec.email = ["xianheng.ma@gmail.com"]
11
+ spec.description = %q{jruby_whirr is a Jruby gem of Apache Whirr}
12
+ spec.summary = %q{jruby_whirr is a Jruby gem of Apache Whirr. Apache Whirr is a set of libraries for running cloud services.
13
+
14
+ Whirr provides:
15
+ A cloud-neutral way to run services. You don't have to worry about the idiosyncrasies of each provider.
16
+ A common service API. The details of provisioning are particular to the service.
17
+ Smart defaults for services. You can get a properly configured system running quickly, while still being able to override settings as needed. }
18
+ spec.homepage = ""
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files`.split($/)
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ end
@@ -0,0 +1,11 @@
1
+ Dir.glob(File.join(ENV["WHIRR_HOME"], 'lib/*.jar')).each { |d| require d }
2
+
3
+ require "jruby_whirr/version"
4
+ require "jruby_whirr/cluster_controller"
5
+ require "jruby_whirr/cluster_spec"
6
+ require 'java'
7
+
8
+
9
+ module JrubyWhirr
10
+
11
+ end
@@ -0,0 +1,21 @@
1
+ module JrubyWhirr
2
+ class Cluster
3
+ java_import org.apache.whirr.Cluster
4
+
5
+ attr_accessor :cluster
6
+
7
+ def initialize (cluster)
8
+ @cluster = cluster
9
+ end
10
+
11
+ #Get a set of Instances in the cluster
12
+ def get_instances
13
+ @cluster.getInstances()
14
+ end
15
+
16
+ def get_configuration
17
+ @cluster.getConfiguration()
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ module JrubyWhirr
2
+ class ClusterController
3
+ java_import org.apache.whirr.ClusterController
4
+ java_import org.apache.whirr.ClusterControllerFactory
5
+ java_import org.apache.whirr.Cluster
6
+ java_import org.apache.whirr.cli.command.RunScriptCommand
7
+ java_import org.jclouds.scriptbuilder.domain.Statements
8
+ java_import java.lang.System
9
+
10
+ attr_accessor :controller, :spec, :cluster
11
+
12
+ def initialize (cluster_spec)
13
+ @spec = cluster_spec
14
+ factory = ClusterControllerFactory.new;
15
+ @controller = factory.create(cluster_spec.get_service_name)
16
+ end
17
+
18
+ def launch_cluster()
19
+ @cluster = @controller.launchCluster(@spec.cluster_spec)
20
+ end
21
+
22
+ def destroy_cluster(spec)
23
+ @controller.destroyCluster(spec)
24
+ end
25
+
26
+ # def run_script(spec, script, instances, roles)
27
+ # script_runner = RunScriptCommand.new
28
+ # script_runner.run(System.in, System.out, System.err, spec, instances, roles, Statements.exec(script))
29
+ # end
30
+
31
+ # def run_script_in_file(sepc, file, instances, roles)
32
+ # script_runner = RunScriptCommand.new
33
+ # script_runner.run(System.in, System.out, System.err, spec, instances, roles, file)
34
+ # end
35
+
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ module JrubyWhirr
2
+ class ClusterSpec
3
+ java_import org.apache.whirr.ClusterSpec
4
+
5
+ attr_accessor :cluster_spec
6
+
7
+ #TODO: add methods for configuring the ClusterSpec
8
+
9
+ def initialize (proerty_file_path)
10
+ property_configuration = org.apache.commons.configuration.PropertiesConfiguration.new(proerty_file_path)
11
+ @cluster_spec = ClusterSpec.new(property_configuration)
12
+ end
13
+
14
+ def get_service_name
15
+ @cluster_spec.getServiceName()
16
+ end
17
+
18
+ def set_service_name (name)
19
+ @cluster_spec.setServiceName(name)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module JrubyWhirr
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe JrubyWhirr::ClusterController do
4
+
5
+ describe ".new" do
6
+ it "should return JrubyWhirr::ClusterController" do
7
+ spec = JrubyWhirr::ClusterSpec.new("hadoop.properties")
8
+ JrubyWhirr::ClusterController.new(spec).should be_an_instance_of JrubyWhirr::ClusterController
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe JrubyWhirr::ClusterSpec do
4
+ describe ".new" do
5
+ it "should return JrubyWhirr::ClusterSpec" do
6
+ JrubyWhirr::ClusterSpec.new("hadoop.properties").should be_an_instance_of JrubyWhirr::ClusterSpec
7
+ end
8
+ end
9
+
10
+ describe ".set_service_name and get_service_name" do
11
+ it "should set the service name of a cluster spec" do
12
+ spec = JrubyWhirr::ClusterSpec.new("hadoop.properties")
13
+ name = "hadoop_service"
14
+ spec.set_service_name(name)
15
+ spec.get_service_name.should eq name
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'jruby_whirr'
4
+
5
+ RSpec.configure do |config|
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_whirr
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Xianheng Ma
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ none: false
44
+ prerelease: false
45
+ type: :development
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ none: false
60
+ prerelease: false
61
+ type: :development
62
+ description: jruby_whirr is a Jruby gem of Apache Whirr
63
+ email:
64
+ - xianheng.ma@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - hadoop.properties
75
+ - jruby_whirr.gemspec
76
+ - lib/jruby_whirr.rb
77
+ - lib/jruby_whirr/cluster.rb
78
+ - lib/jruby_whirr/cluster_controller.rb
79
+ - lib/jruby_whirr/cluster_spec.rb
80
+ - lib/jruby_whirr/version.rb
81
+ - spec/cluster_controller_spec.rb
82
+ - spec/cluster_spec_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: ''
85
+ licenses:
86
+ - MIT
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ none: false
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ none: false
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.24
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: 'jruby_whirr is a Jruby gem of Apache Whirr. Apache Whirr is a set of libraries
109
+ for running cloud services. Whirr provides: A cloud-neutral way to run services.
110
+ You don''t have to worry about the idiosyncrasies of each provider. A common service
111
+ API. The details of provisioning are particular to the service. Smart defaults
112
+ for services. You can get a properly configured system running quickly, while still
113
+ being able to override settings as needed.'
114
+ test_files:
115
+ - spec/cluster_controller_spec.rb
116
+ - spec/cluster_spec_spec.rb
117
+ - spec/spec_helper.rb