Browse files

Elasticsearch as a Service support

Patch set 1
- Main code is based on Neo4j as a Service
- Test code is based on Neo4j & vblob as a Service
- dev_setup to be committed seperately

Patch set 2
- Delete unnecessary "require" statements
- Delete memory property in the ProvisionedService class
- Add logging to all_bindings_list
- Add varz_details method
- Change logic for installing Elasticsearch to use single executable
- To support for using single elasticsearch executable, Patch set 2 of dev_setup to be committed seperately

Patch set 3
- Rename some methods

Patch set 4
- Modify service version
- Modify service description
- Delete allow_over_provisioning option
- Introduce log dir option in config
- Rename some methods

Patch set 5
- Add a missing "require" statement for pretty_inspect

Change-Id: I5aa1150d5a74bc43dfbe9ca8bcec3707aae43e30
  • Loading branch information...
1 parent 9983149 commit 9be53c80f11619a9d59779655b58dcd7d921729f @frhwang frhwang committed May 16, 2012
Showing with 1,259 additions and 0 deletions.
  1. +3 −0 elasticsearch/.gitignore
  2. +26 −0 elasticsearch/Gemfile
  3. +176 −0 elasticsearch/Gemfile.lock
  4. +46 −0 elasticsearch/Rakefile
  5. +25 −0 elasticsearch/bin/elasticsearch_gateway
  6. +35 −0 elasticsearch/bin/elasticsearch_node
  7. +20 −0 elasticsearch/config/elasticsearch_gateway.yml
  8. +21 −0 elasticsearch/config/elasticsearch_node.yml
  9. +12 −0 elasticsearch/lib/elasticsearch_service/common.rb
  10. +420 −0 elasticsearch/lib/elasticsearch_service/elasticsearch_node.rb
  11. +8 −0 elasticsearch/lib/elasticsearch_service/elasticsearch_provisioner.rb
  12. +20 −0 elasticsearch/resources/elasticsearch.yml.erb
  13. +44 −0 elasticsearch/resources/logging.yml
  14. +49 −0 elasticsearch/spec/Rakefile
  15. +111 −0 elasticsearch/spec/elasticsearch_node_bind_spec.rb
  16. +66 −0 elasticsearch/spec/elasticsearch_node_orphan_spec.rb
  17. +97 −0 elasticsearch/spec/elasticsearch_node_provision_spec.rb
  18. +80 −0 elasticsearch/spec/spec_helper.rb
  19. BIN elasticsearch/vendor/cache/addressable-2.2.4.gem
  20. BIN elasticsearch/vendor/cache/bcrypt-ruby-2.1.4.gem
  21. BIN elasticsearch/vendor/cache/builder-3.0.0.gem
  22. BIN elasticsearch/vendor/cache/ci_reporter-1.6.4.gem
  23. BIN elasticsearch/vendor/cache/curb-0.7.16.gem
  24. BIN elasticsearch/vendor/cache/daemons-1.1.5.gem
  25. BIN elasticsearch/vendor/cache/data_objects-0.10.3.gem
  26. BIN elasticsearch/vendor/cache/datamapper-1.1.0.gem
  27. BIN elasticsearch/vendor/cache/diff-lcs-1.1.2.gem
  28. BIN elasticsearch/vendor/cache/dm-aggregates-1.1.0.gem
  29. BIN elasticsearch/vendor/cache/dm-constraints-1.1.0.gem
  30. BIN elasticsearch/vendor/cache/dm-core-1.1.0.gem
  31. BIN elasticsearch/vendor/cache/dm-do-adapter-1.1.0.gem
  32. BIN elasticsearch/vendor/cache/dm-migrations-1.1.0.gem
  33. BIN elasticsearch/vendor/cache/dm-serializer-1.1.0.gem
  34. BIN elasticsearch/vendor/cache/dm-sqlite-adapter-1.1.0.gem
  35. BIN elasticsearch/vendor/cache/dm-timestamps-1.1.0.gem
  36. BIN elasticsearch/vendor/cache/dm-transactions-1.1.0.gem
  37. BIN elasticsearch/vendor/cache/dm-types-1.1.0.gem
  38. BIN elasticsearch/vendor/cache/dm-validations-1.1.0.gem
  39. BIN elasticsearch/vendor/cache/do_sqlite3-0.10.3.gem
  40. BIN elasticsearch/vendor/cache/em-http-request-0.3.0.gem
  41. BIN elasticsearch/vendor/cache/escape_utils-0.2.3.gem
  42. BIN elasticsearch/vendor/cache/eventmachine-0.12.11.cloudfoundry.3.gem
  43. BIN elasticsearch/vendor/cache/eventmachine_httpserver-0.2.1.gem
  44. BIN elasticsearch/vendor/cache/fastercsv-1.5.4.gem
  45. BIN elasticsearch/vendor/cache/json-1.4.6.gem
  46. BIN elasticsearch/vendor/cache/json_pure-1.6.5.gem
  47. BIN elasticsearch/vendor/cache/macaddr-1.5.0.gem
  48. BIN elasticsearch/vendor/cache/mime-types-1.16.gem
  49. BIN elasticsearch/vendor/cache/multi_json-1.0.4.gem
  50. BIN elasticsearch/vendor/cache/nats-0.4.22.beta.8.gem
  51. BIN elasticsearch/vendor/cache/posix-spawn-0.3.6.gem
  52. BIN elasticsearch/vendor/cache/rack-1.4.0.gem
  53. BIN elasticsearch/vendor/cache/rake-0.9.2.2.gem
  54. BIN elasticsearch/vendor/cache/rcov-0.9.9.gem
  55. BIN elasticsearch/vendor/cache/redis-2.2.2.gem
  56. BIN elasticsearch/vendor/cache/redis-namespace-1.0.3.gem
  57. BIN elasticsearch/vendor/cache/redisk-0.2.2.gem
  58. BIN elasticsearch/vendor/cache/resque-1.20.0.gem
  59. BIN elasticsearch/vendor/cache/resque-status-0.3.2.gem
  60. BIN elasticsearch/vendor/cache/rest-client-1.6.1.gem
  61. BIN elasticsearch/vendor/cache/rspec-2.5.0.gem
  62. BIN elasticsearch/vendor/cache/rspec-core-2.5.1.gem
  63. BIN elasticsearch/vendor/cache/rspec-expectations-2.5.0.gem
  64. BIN elasticsearch/vendor/cache/rspec-mocks-2.5.0.gem
  65. BIN elasticsearch/vendor/cache/ruby-hmac-0.4.0.gem
  66. BIN elasticsearch/vendor/cache/simplecov-0.5.4.gem
  67. BIN elasticsearch/vendor/cache/simplecov-html-0.5.3.gem
  68. BIN elasticsearch/vendor/cache/simplecov-rcov-0.2.3.gem
  69. BIN elasticsearch/vendor/cache/sinatra-1.2.7.gem
  70. BIN elasticsearch/vendor/cache/stringex-1.2.1.gem
  71. BIN elasticsearch/vendor/cache/systemu-2.5.0.gem
  72. BIN elasticsearch/vendor/cache/thin-1.3.1.gem
  73. BIN elasticsearch/vendor/cache/tilt-1.3.3.gem
  74. BIN elasticsearch/vendor/cache/uuid-2.3.5.gem
  75. BIN elasticsearch/vendor/cache/uuidtools-2.1.2.gem
  76. BIN elasticsearch/vendor/cache/vcap_common-1.0.8.gem
  77. BIN elasticsearch/vendor/cache/vcap_logging-0.1.3.gem
  78. BIN elasticsearch/vendor/cache/vcap_services_base-0.1.9.gem
  79. BIN elasticsearch/vendor/cache/vegas-0.1.11.gem
  80. BIN elasticsearch/vendor/cache/yajl-ruby-0.8.3.gem
View
3 elasticsearch/.gitignore
@@ -0,0 +1,3 @@
+./configs/*
+./databases/*
+*.db
View
26 elasticsearch/Gemfile
@@ -0,0 +1,26 @@
+source :rubygems
+
+gem "datamapper", ">= 0.10.2"
+gem "dm-sqlite-adapter"
+gem "do_sqlite3"
+gem "eventmachine"
+gem "em-http-request"
+gem "nats"
+gem "ruby-hmac"
+gem "uuidtools"
+gem "rest-client"
+gem "sinatra"
+gem "thin"
+
+gem 'vcap_common', '>= 1.0.8', :require => ['vcap/common', 'vcap/component']
+gem 'vcap_logging', '>=0.1.3', :require => ['vcap/logging']
+gem "vcap_services_base"
+
+group :test do
+ gem "rake"
+ gem "rspec"
+ gem "rcov"
+ gem "simplecov"
+ gem "simplecov-rcov"
+ gem "ci_reporter"
+end
View
176 elasticsearch/Gemfile.lock
@@ -0,0 +1,176 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.4)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
+ ci_reporter (1.6.4)
+ builder (>= 2.1.2)
+ curb (0.7.16)
+ daemons (1.1.5)
+ data_objects (0.10.3)
+ addressable (~> 2.1)
+ datamapper (1.1.0)
+ dm-aggregates (= 1.1.0)
+ dm-constraints (= 1.1.0)
+ dm-core (= 1.1.0)
+ dm-migrations (= 1.1.0)
+ dm-serializer (= 1.1.0)
+ dm-timestamps (= 1.1.0)
+ dm-transactions (= 1.1.0)
+ dm-types (= 1.1.0)
+ dm-validations (= 1.1.0)
+ diff-lcs (1.1.2)
+ dm-aggregates (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-constraints (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-core (1.1.0)
+ addressable (~> 2.2.4)
+ dm-do-adapter (1.1.0)
+ data_objects (~> 0.10.2)
+ dm-core (~> 1.1.0)
+ dm-migrations (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-serializer (1.1.0)
+ dm-core (~> 1.1.0)
+ fastercsv (~> 1.5.4)
+ json (~> 1.4.6)
+ dm-sqlite-adapter (1.1.0)
+ dm-do-adapter (~> 1.1.0)
+ do_sqlite3 (~> 0.10.2)
+ dm-timestamps (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-transactions (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-types (1.1.0)
+ bcrypt-ruby (~> 2.1.4)
+ dm-core (~> 1.1.0)
+ fastercsv (~> 1.5.4)
+ json (~> 1.4.6)
+ stringex (~> 1.2.0)
+ uuidtools (~> 2.1.2)
+ dm-validations (1.1.0)
+ dm-core (~> 1.1.0)
+ do_sqlite3 (0.10.3)
+ data_objects (= 0.10.3)
+ em-http-request (0.3.0)
+ addressable (>= 2.0.0)
+ escape_utils
+ eventmachine (>= 0.12.9)
+ escape_utils (0.2.3)
+ eventmachine (0.12.11.cloudfoundry.3)
+ eventmachine_httpserver (0.2.1)
+ fastercsv (1.5.4)
+ json (1.4.6)
+ json_pure (1.6.5)
+ macaddr (1.5.0)
+ systemu (>= 2.4.0)
+ mime-types (1.16)
+ multi_json (1.0.4)
+ nats (0.4.22.beta.8)
+ daemons (>= 1.1.4)
+ eventmachine (>= 0.12.10)
+ json_pure (>= 1.6.1)
+ thin (>= 1.3.1)
+ posix-spawn (0.3.6)
+ rack (1.4.0)
+ rake (0.9.2.2)
+ rcov (0.9.9)
+ redis (2.2.2)
+ redis-namespace (1.0.3)
+ redis (< 3.0.0)
+ redisk (0.2.2)
+ redis (>= 0.1.1)
+ redis-namespace (>= 0.1.0)
+ resque (1.20.0)
+ multi_json (~> 1.0)
+ redis-namespace (~> 1.0.2)
+ sinatra (>= 0.9.2)
+ vegas (~> 0.1.2)
+ resque-status (0.3.2)
+ redisk (>= 0.2.1)
+ resque (~> 1.19)
+ uuid (~> 2.3)
+ rest-client (1.6.1)
+ mime-types (>= 1.16)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ ruby-hmac (0.4.0)
+ simplecov (0.5.4)
+ multi_json (~> 1.0.3)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ simplecov-rcov (0.2.3)
+ simplecov (>= 0.4.1)
+ sinatra (1.2.7)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ stringex (1.2.1)
+ systemu (2.5.0)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ tilt (1.3.3)
+ uuid (2.3.5)
+ macaddr (~> 1.0)
+ uuidtools (2.1.2)
+ vcap_common (1.0.8)
+ eventmachine (~> 0.12.11.cloudfoundry.3)
+ nats (~> 0.4.22.beta.8)
+ posix-spawn (~> 0.3.6)
+ thin (~> 1.3.1)
+ yajl-ruby (~> 0.8.3)
+ vcap_logging (0.1.3)
+ vcap_services_base (0.1.9)
+ curb (~> 0.7.16)
+ datamapper (~> 1.1.0)
+ do_sqlite3 (~> 0.10.3)
+ em-http-request (~> 0.3.0)
+ eventmachine (~> 0.12.11.cloudfoundry.3)
+ eventmachine_httpserver (~> 0.2.1)
+ json (~> 1.4.6)
+ nats (~> 0.4.22.beta.8)
+ resque (~> 1.20)
+ resque-status (~> 0.3.2)
+ ruby-hmac (~> 0.4.0)
+ sinatra (~> 1.2.3)
+ thin (~> 1.3.1)
+ uuidtools (~> 2.1.2)
+ vcap_common (>= 1.0.8)
+ vcap_logging (>= 0.1.3)
+ vegas (0.1.11)
+ rack (>= 1.0.0)
+ yajl-ruby (0.8.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ci_reporter
+ datamapper (>= 0.10.2)
+ dm-sqlite-adapter
+ do_sqlite3
+ em-http-request
+ eventmachine
+ nats
+ rake
+ rcov
+ rest-client
+ rspec
+ ruby-hmac
+ simplecov
+ simplecov-rcov
+ sinatra
+ thin
+ uuidtools
+ vcap_common (>= 1.0.8)
+ vcap_logging (>= 0.1.3)
+ vcap_services_base
View
46 elasticsearch/Rakefile
@@ -0,0 +1,46 @@
+require 'rake'
+
+desc "Run specs"
+task "spec" => ["bundler:install:test", "test:spec"]
+
+desc "Run specs using SimpleCov"
+task "spec:rcov" => ["bundler:install:test", "test:spec:rcov"]
+
+desc "Run ci using SimpleCov"
+task "spec:ci" => ["bundler:install:test", "test:spec:ci"]
+
+namespace "bundler" do
+ desc "Install gems"
+ task "install" do
+ sh("bundle install")
+ end
+
+ desc "Install gems for test"
+ task "install:test" do
+ sh("bundle install --without development production")
+ end
+
+ desc "Install gems for production"
+ task "install:production" do
+ sh("bundle install --without development test")
+ end
+
+ desc "Install gems for development"
+ task "install:development" do
+ sh("bundle install --without test production")
+ end
+end
+
+namespace "test" do
+ task "spec" do |t|
+ sh("cd spec && ../../base/bin/nats-util start && rake spec && ../../base/bin/nats-util stop")
+ end
+
+ task "spec:rcov" do |t|
+ sh("cd spec && ../../base/bin/nats-util start && rake simcov && ../../base/bin/nats-util stop")
+ end
+
+ task "spec:ci" do |t|
+ sh("cd spec && ../../base/bin/nats-util start && rake spec:ci && ../../base/bin/nats-util stop")
+ end
+end
View
25 elasticsearch/bin/elasticsearch_gateway
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+# -*- mode: ruby -*-
+# Copyright (c) 2009-2011 VMware, Inc.
+#
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
+require 'bundler/setup'
+require 'vcap_services_base'
+
+$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+require 'elasticsearch_service/elasticsearch_provisioner'
+
+class VCAP::Services::ElasticSearch::Gateway < VCAP::Services::Base::Gateway
+
+ def provisioner_class
+ VCAP::Services::ElasticSearch::Provisioner
+ end
+
+ def default_config_file
+ config_base_dir = ENV["CLOUD_FOUNDRY_CONFIG_PATH"] || File.join(File.dirname(__FILE__), '..', 'config')
+ File.join(config_base_dir, 'elasticsearch_gateway.yml')
+ end
+
+end
+
+VCAP::Services::ElasticSearch::Gateway.new.start
View
35 elasticsearch/bin/elasticsearch_node
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+# -*- mode: ruby -*-
+# Copyright (c) 2009-2011 VMware, Inc.
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
+require 'bundler/setup'
+require 'vcap_services_base'
+
+$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
+require "elasticsearch_service/elasticsearch_node"
+
+class VCAP::Services::ElasticSearch::NodeBin < VCAP::Services::Base::NodeBin
+
+ def node_class
+ VCAP::Services::ElasticSearch::Node
+ end
+
+ def default_config_file
+ config_base_dir = ENV["CLOUD_FOUNDRY_CONFIG_PATH"] || File.join(File.dirname(__FILE__), '..', 'config')
+ File.join(config_base_dir, 'elasticsearch_node.yml')
+ end
+
+ def additional_config(options, config)
+ options[:config_template] = File.expand_path("../../resources/elasticsearch.yml.erb", __FILE__)
+ options[:logging_config_file] = File.expand_path("../../resources/logging.yml", __FILE__)
+ options[:elasticsearch_log_dir] = parse_property(config, "elasticsearch_log_dir", String)
+ options[:elasticsearch_path] = parse_property(config, "elasticsearch_path", String)
+ options[:elasticsearch_plugin_dir] = parse_property(config, "elasticsearch_plugin_dir", String)
+ options[:port_range] = parse_property(config, "port_range", Range)
+ options[:max_memory] = parse_property(config, "max_memory", Integer)
+ options
+ end
+
+end
+
+VCAP::Services::ElasticSearch::NodeBin.new.start
View
20 elasticsearch/config/elasticsearch_gateway.yml
@@ -0,0 +1,20 @@
+---
+# cloud_controller_uri: api.vcap.me
+service:
+ name: elasticsearch
+ version: "0.19"
+ description: 'Elasticsearch text search service'
+ plans: ['free']
+ tags: ['elasticsearch', 'elasticsearch-0.19', 'search']
+ timeout: 20
+ip_route: localhost
+index: 0
+token: "0xdeadbeef"
+logging:
+ level: debug
+mbus: nats://localhost:4222
+pid: /var/vcap/sys/run/elasticsearch_service.pid
+node_timeout: 20
+# z_interval: 30
+# check_orphan_interval: 3600
+# double_check_orphan_interval: 300
View
21 elasticsearch/config/elasticsearch_node.yml
@@ -0,0 +1,21 @@
+---
+capacity: 200
+plan: "free"
+local_db: sqlite3:/var/vcap/services/elasticsearch/elasticsearch_node.db
+mbus: nats://localhost:4222/
+index: 0
+base_dir: /var/vcap/services/elasticsearch/instances
+logging:
+ level: debug
+pid: /var/vcap/sys/run/elasticsearch_node.pid
+max_memory: 512
+node_id: elasticsearch_node_1
+elasticsearch_log_dir: /var/vcap/sys/log/elasticsearch
+elasticsearch_path: /var/vcap/package/elasticsearch/bin/elasticsearch
+elasticsearch_plugin_dir: /var/vcap/package/elasticsearch/plugins
+port_range:
+ first: 45001
+ last: 55000
+# z_interval: 30
+# max_nats_payload: 1048576
+# fqdn_hosts: false
View
12 elasticsearch/lib/elasticsearch_service/common.rb
@@ -0,0 +1,12 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+module VCAP
+ module Services
+ module ElasticSearch
+ module Common
+ def service_name
+ "ElasticSearchaaS"
+ end
+ end
+ end
+ end
+end
View
420 elasticsearch/lib/elasticsearch_service/elasticsearch_node.rb
@@ -0,0 +1,420 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+require "erb"
+require "fileutils"
+require "logger"
+require "set"
+require "timeout"
+require "uuidtools"
+require "pp"
+
+require 'vcap/common'
+require 'vcap/component'
+require "elasticsearch_service/common"
+require 'rest-client'
+require 'net/http'
+
+module VCAP
+ module Services
+ module ElasticSearch
+ class Node < VCAP::Services::Base::Node
+ end
+ end
+ end
+end
+
+class VCAP::Services::ElasticSearch::Node
+
+ include VCAP::Services::ElasticSearch::Common
+
+ # Default value is 2 seconds
+ ES_TIMEOUT = 2
+
+ class ProvisionedService
+ include DataMapper::Resource
+ property :name, String, :key => true
+ property :port, Integer, :unique => true
+ property :password, String, :required => true
+ property :plan, Enum[:free], :required => true
+ property :pid, Integer
+ property :username, String, :required => true
+
+ def listening?
+ begin
+ TCPSocket.open('localhost', port).close
+ return true
+ rescue => e
+ return false
+ end
+ end
+
+ def running?
+ VCAP.process_running? pid
+ end
+
+ def kill(sig=9)
+ Process.kill(sig, pid) if running?
+ end
+ end
+
+ def initialize(options)
+ super(options)
+ @base_dir = options[:base_dir]
+ FileUtils.mkdir_p(@base_dir)
+ @elasticsearch_log_dir = options[:elasticsearch_log_dir]
+ @elasticsearch_path = options[:elasticsearch_path]
+ @elasticsearch_plugin_dir = options[:elasticsearch_plugin_dir]
+ @logger.debug(options[:elasticsearch_plugin_dir])
+ @max_memory = options[:max_memory]
+ @config_template = ERB.new(File.read(options[:config_template]))
+ @default_logging_config = options[:logging_config_file]
+
+ DataMapper.setup(:default, options[:local_db])
+ DataMapper::auto_upgrade!
+
+ @free_ports = Set.new
+ options[:port_range].each {|port| @free_ports << port}
+ @mutex = Mutex.new
+ end
+
+ def pre_send_announcement
+ @capacity_lock.synchronize do
+ ProvisionedService.all.each do |provisioned_service|
+ @capacity -= capacity_unit
+ delete_port(provisioned_service.port)
+ if provisioned_service.listening?
+ @logger.info("Service #{provisioned_service.name} already listening on port #{provisioned_service.port}")
+ next
+ end
+ begin
+ pid = start_instance(provisioned_service)
+ provisioned_service.pid = pid
+ unless provisioned_service.save
+ provisioned_service.kill
+ raise "Couldn't save pid (#{pid})"
+ end
+ rescue => e
+ @logger.error("Error starting service #{provisioned_service.name}: #{e}")
+ end
+ end
+ end
+ end
+
+ def shutdown
+ super
+ @logger.info("Shutting down instances..")
+ ProvisionedService.all.each do |service|
+ @logger.info("Shutting down #{service}")
+ stop_service(service)
+ end
+ end
+
+ def announcement
+ @capacity_lock.synchronize do
+ { :available_capacity => @capacity,
+ :capacity_unit => capacity_unit }
+ end
+ end
+
+ def all_instances_list
+ ProvisionedService.all.map{ |ps| ps["name"] }
+ end
+
+ def all_bindings_list
+ list = []
+ ProvisionedService.all.each do |ps|
+ begin
+ url = "http://#{ps.username}:#{ps.password}@#{@local_ip}:#{ps.port}/_nodes/#{ps.name}"
+ response = ''
+ Timeout::timeout(ES_TIMEOUT) do
+ response = RestClient.get(url)
+ end
+ credential = {
+ 'name' => ps.name,
+ 'port' => ps.port,
+ 'username' => ps.username
+ }
+ list << credential if response =~ /"#{ps.name}"/
+ rescue => e
+ @logger.warn("Failed to fetch status for #{ps.name}: #{e.message}")
+ end
+ end
+ list
+ end
+
+ def varz_details
+ # Do disk summary
+ du_hash = {}
+ du_all_out = `cd #{@base_dir}; du -sk * 2> /dev/null`
+ du_entries = du_all_out.split("\n")
+ du_entries.each do |du_entry|
+ size, dir = du_entry.split("\t")
+ size = size.to_i * 1024 # Convert to bytes
+ du_hash[dir] = size
+ end
+
+ # Get elasticsearch health, index & process status
+ stats = []
+ ProvisionedService.all.each do |provisioned_service|
+ stat = {}
+ stat['health'] = elasticsearch_health_stats(provisioned_service)
+ stat['index'] = elasticsearch_index_stats(provisioned_service)
+ stat['process'] = elasticsearch_process_stats(provisioned_service)
+ stat['name'] = provisioned_service.name
+ stats << stat
+ end
+
+ # Get service instance status
+ provisioned_instances = {}
+ begin
+ ProvisionedService.all.each do |instance|
+ provisioned_instances[instance.name.to_sym] = elasticsearch_status(instance)
+ end
+ rescue => e
+ @logger.error("Error get instance list: #{e}")
+ end
+
+ {
+ :running_services => stats,
+ :disk => du_hash,
+ :max_capacity => @max_capacity,
+ :available_capacity => @capacity,
+ :instances => provisioned_instances
+ }
+ end
+
+ def provision(plan, credentials = nil)
+ provisioned_service = ProvisionedService.new
+ if credentials
+ provisioned_service.name = credentials["name"]
+ provisioned_service.username = credentials["username"]
+ provisioned_service.password = credentials["password"]
+ else
+ provisioned_service.name = "elasticsearch-#{UUIDTools::UUID.random_create.to_s}"
+ provisioned_service.username = UUIDTools::UUID.random_create.to_s
+ provisioned_service.password = UUIDTools::UUID.random_create.to_s
+ end
+
+ provisioned_service.port = fetch_port
+ provisioned_service.plan = plan
+ provisioned_service.pid = start_instance(provisioned_service)
+
+ unless provisioned_service.pid && provisioned_service.save
+ cleanup_service(provisioned_service)
+ raise "Could not save entry: #{provisioned_service.errors.pretty_inspect}"
+ end
+
+ response = get_credentials(provisioned_service)
+ @logger.debug("response: #{response}")
+ return response
+ rescue => e
+ @logger.warn(e)
+ end
+
+ def unprovision(name, credentials = nil)
+ provisioned_service = ProvisionedService.get(name)
+ raise "Could not find service: #{name}" if provisioned_service.nil?
+
+ cleanup_service(provisioned_service)
+ @logger.debug("Successfully fulfilled unprovision request: #{name}.")
+ end
+
+ # FIXME Elasticsearch has no user level security, just return provisioned credentials.
+ # Elasticsearch has not built-in user authentication system.
+ # So "http-basic(https://github.com/Asquera/elasticsearch-http-basic)" plugin
+ # is added for authentication. But It has not support multi-user authentication.
+ # It supports only 1 user per 1 instance. Provisioned credentials does not changed
+ # regardless of any bind requests.
+ def bind(name, bind_opts = 'rw', credentials = nil)
+ @logger.debug("Bind request: name=#{name}, bind_opts=#{bind_opts}")
+
+ provisioned_service = ProvisionedService.get(name)
+ raise "Could not find service: #{name}" if provisioned_service.nil?
+
+ response = get_credentials(provisioned_service)
+ @logger.debug("response: #{response}")
+ response
+ end
+
+ # FIXME Elasticsearch has no user level security, just return.
+ def unbind(credentials)
+ @logger.debug("Unbind request: credentials=#{credentials}")
+
+ name = credentials['name']
+ provisioned_service = ProvisionedService.get(name)
+ raise "Could not find service: #{name}" if provisioned_service.nil?
+
+ @logger.debug("Successfully unbound #{credentials}")
+ true
+ end
+
+ def start_instance(provisioned_service)
+ @logger.debug("Starting: #{provisioned_service.pretty_inspect}")
+
+ dir = service_dir(provisioned_service.name)
+
+ setup_server(dir, provisioned_service) unless File.directory? "#{dir}/data"
+
+ config_file = config_path(dir)
+ pid_file = File.join(dir, "elasticsearch.pid")
+
+ `export ES_HEAP_SIZE="#{@max_memory}m" && #{@elasticsearch_path} -p #{pid_file} -Des.config=#{config_file}`
+ status = $?
+ @logger.send(status.success? ? :debug : :error, "Start up finished, status = #{status}")
+
+ pid = `[ -f #{pid_file} ] && cat #{pid_file}`
+ status = $?
+ @logger.send(status.success? ? :debug : :error, "Service #{provisioned_service.name} running with pid #{pid}")
+
+ return pid.to_i
+ end
+
+ def elasticsearch_health_stats(instance)
+ url = "http://#{instance.username}:#{instance.password}@#{@local_ip}:#{instance.port}/_cluster/health"
+ response = nil
+ Timeout::timeout(ES_TIMEOUT) do
+ response = RestClient.get(url)
+ end
+ JSON.parse(response) if response
+ rescue => e
+ warning = "Failed elasticsearch_health_stats: #{e.message}, instance: #{instance.name}"
+ @logger.warn(warning)
+ warning
+ end
+
+ def elasticsearch_index_stats(instance)
+ url = "http://#{instance.username}:#{instance.password}@#{@local_ip}:#{instance.port}/_nodes/#{instance.name}/stats"
+ response = nil
+ Timeout::timeout(ES_TIMEOUT) do
+ response = RestClient.get(url)
+ end
+ JSON.parse(response)['nodes'].flatten[1]['indices']
+ rescue => e
+ warning = "Failed elasticsearch_index_stats: #{e.message}, instance: #{instance.name}"
+ @logger.warn(warning)
+ warning
+ end
+
+ def elasticsearch_process_stats(instance)
+ url = "http://#{instance.username}:#{instance.password}@#{@local_ip}:#{instance.port}/_nodes/#{instance.name}/process"
+ response = nil
+ Timeout::timeout(ES_TIMEOUT) do
+ response = RestClient.get(url)
+ end
+ JSON.parse(response)['nodes'].flatten[1]['process']
+ rescue => e
+ warning = "Failed elasticsearch_process_stats: #{e.message}, instance: #{instance.name}"
+ @logger.warn(warning)
+ warning
+ end
+
+ def elasticsearch_status(instance)
+ url = "http://#{instance.username}:#{instance.password}@#{@local_ip}:#{instance.port}/_nodes/#{instance.name}"
+ Timeout::timeout(ES_TIMEOUT) do
+ RestClient.get(url)
+ end
+ "ok"
+ rescue => e
+ "fail"
+ end
+
+ def setup_server(dir, provisioned_service)
+ @logger.info("Installing elasticsearch to #{dir}")
+
+ conf_dir = config_dir(dir)
+ data_dir = File.join(dir, 'data')
+ work_dir = File.join(dir, 'work')
+ logs_dir = log_dir(provisioned_service.name)
+ FileUtils.mkdir_p(dir)
+ FileUtils.mkdir_p(conf_dir)
+ FileUtils.mkdir_p(data_dir)
+ FileUtils.mkdir_p(work_dir)
+ FileUtils.mkdir_p(logs_dir)
+
+ name = provisioned_service.name
+ port = provisioned_service.port
+ password = provisioned_service.password
+ username = provisioned_service.username
+ plugins_dir = @elasticsearch_plugin_dir
+
+ File.open(config_path(dir), "w") { |f| f.write(@config_template.result(binding)) }
+ FileUtils.cp(@default_logging_config, conf_dir)
+ end
+
+ def get_credentials(provisioned_service)
+ raise "Could not access provisioned service" unless provisioned_service
+ credentials = {
+ "hostname" => @local_ip,
+ "host" => @local_ip,
+ "port" => provisioned_service.port,
+ "username" => provisioned_service.username,
+ "password" => provisioned_service.password,
+ "name" => provisioned_service.name,
+ }
+ credentials["url"] = "http://#{credentials['username']}:#{credentials['password']}@#{credentials['host']}:#{credentials['port']}"
+ credentials
+ end
+
+ def cleanup_service(provisioned_service)
+ @logger.debug("Killing #{provisioned_service.name} started with pid #{provisioned_service.pid}")
+
+ stop_service(provisioned_service)
+ raise "Could not cleanup service: #{provisioned_service.errors.pretty_inspect}" unless provisioned_service.new? || provisioned_service.destroy
+ provisioned_service.kill if provisioned_service.running?
+
+ EM.defer do
+ FileUtils.rm_rf(service_dir(provisioned_service.name))
+ FileUtils.rm_rf(log_dir(provisioned_service.name))
+ end
+ return_port(provisioned_service.port)
+
+ true
+ rescue => e
+ @logger.warn(e)
+ end
+
+ def stop_service(service)
+ begin
+ @logger.info("Stopping #{service.name} PORT #{service.port} PID #{service.pid}")
+ service.kill(:SIGTERM) if service.running?
+ rescue => e
+ @logger.error("Error stopping service #{service.name} PORT #{service.port} PID #{service.pid}: #{e}")
+ end
+ end
+
+ def fetch_port(port=nil)
+ @mutex.synchronize do
+ port ||= @free_ports.first
+ raise "port #{port} is already taken!" unless @free_ports.include?(port)
+ @free_ports.delete(port)
+ port
+ end
+ end
+
+ def return_port(port)
+ @mutex.synchronize do
+ @free_ports << port
+ end
+ end
+
+ def delete_port(port)
+ @mutex.synchronize do
+ @free_ports.delete(port)
+ end
+ end
+
+ def config_path(dir)
+ File.join(config_dir(dir), 'elasticsearch.yml')
+ end
+
+ def config_dir(dir)
+ File.join(dir, 'config')
+ end
+
+ def service_dir(instance_id)
+ File.join(@base_dir, instance_id)
+ end
+
+ def log_dir(instance_id)
+ File.join(@elasticsearch_log_dir, instance_id)
+ end
+end
View
8 elasticsearch/lib/elasticsearch_service/elasticsearch_provisioner.rb
@@ -0,0 +1,8 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+require "elasticsearch_service/common"
+
+class VCAP::Services::ElasticSearch::Provisioner < VCAP::Services::Base::Provisioner
+
+ include VCAP::Services::ElasticSearch::Common
+
+end
View
20 elasticsearch/resources/elasticsearch.yml.erb
@@ -0,0 +1,20 @@
+node.name: <%=name%>
+path:
+ conf: <%=conf_dir%>
+ data: <%=data_dir%>
+ work: <%=work_dir%>
+ logs: <%=logs_dir%>
+ plugins: <%=plugins_dir%>
+index:
+ number_of_shards: 1
+ number_of_replicas: 0
+http:
+ port: <%=port%>
+ basic:
+ enabled: true
+ user: <%=username%>
+ password: <%=password%>
+# disable node discovery via multicast
+discovery.zen.ping.multicast.enabled: false
+# disable shutdown REST API
+action.disable_shutdown: true
View
44 elasticsearch/resources/logging.yml
@@ -0,0 +1,44 @@
+rootLogger: INFO, console, file
+logger:
+ # log action execution errors for easier debugging
+ action: DEBUG
+ # reduce the logging for aws, too much is logged under the default INFO
+ com.amazonaws: WARN
+
+ # gateway
+ #gateway: DEBUG
+ #index.gateway: DEBUG
+
+ # peer shard recovery
+ #indices.recovery: DEBUG
+
+ # discovery
+ #discovery: TRACE
+
+ index.search.slowlog: TRACE, index_search_slow_log_file
+
+additivity:
+ index.search.slowlog: false
+
+appender:
+ console:
+ type: console
+ layout:
+ type: consolePattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ index_search_slow_log_file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}_index_search_slowlog.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
View
49 elasticsearch/spec/Rakefile
@@ -0,0 +1,49 @@
+require 'rake'
+require 'tempfile'
+
+require 'rubygems'
+require 'bundler/setup'
+Bundler.require(:default, :test)
+
+require 'rspec'
+require 'rspec/core/rake_task'
+require 'ci/reporter/rake/rspec'
+
+require "simplecov"
+require "simplecov-rcov"
+
+coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
+reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
+
+ENV['CI_REPORTS'] = reports_dir
+
+desc "Run specs using SimpleCov"
+task "spec:ci" => ["ci:setup:rspec", "simcov"]
+
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "**/*_spec.rb"
+ t.rspec_opts = ["--format", "documentation", "--colour"]
+end
+
+desc "Run spec with coverage"
+task "simcov" => "cleanup_coverage" do
+ class SimpleCov::Formatter::CombinedFormatter
+ def format(result)
+ SimpleCov::Formatter::RcovFormatter.new.format(result)
+ end
+ end
+
+ SimpleCov.formatter = SimpleCov::Formatter::CombinedFormatter
+ SimpleCov.root('..')
+ SimpleCov.coverage_dir('spec_coverage')
+ SimpleCov.start do
+ add_filter "/spec/"
+ spec_dir = File.expand_path("..", __FILE__)
+ Rspec::Core::Runner.disable_autorun!
+ Rspec::Core::Runner.run([spec_dir], STDERR, STDOUT)
+ end
+end
+
+task "cleanup_coverage" do
+ rm_rf coverage_dir
+end
View
111 elasticsearch/spec/elasticsearch_node_bind_spec.rb
@@ -0,0 +1,111 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+require "spec_helper"
+
+describe "elasticsearch_node bind" do
+
+ before :all do
+ EM.run do
+ @opts = get_node_config
+ @logger = @opts[:logger]
+ @node = Node.new(@opts)
+ EM.add_timer(1) { @resp = @node.provision("free") }
+ EM.add_timer(9) do
+ @bind_resp = @node.bind(@resp['name'], 'rw')
+ EM.stop
+ end
+ end
+ end
+
+ it "should have valid response" do
+ @resp.should_not be_nil
+ @resp['host'].should_not be_nil
+ @resp['port'].should_not be_nil
+ @resp['username'].should_not be_nil
+ @resp['password'].should_not be_nil
+ @bind_resp.should_not be_nil
+ @bind_resp['host'].should_not be_nil
+ @bind_resp['port'].should_not be_nil
+ @bind_resp['username'].should_not be_nil
+ @bind_resp['password'].should_not be_nil
+ end
+
+ it "should be able to connect to elasticsearch" do
+ is_port_open?(@bind_resp['host'], @bind_resp['port']).should be_true
+ response = RestClient.get "http://#{@bind_resp['host']}:#{@bind_resp['port']}"
+ response.should_not be_nil
+ response.code.should == 200
+ end
+
+ it "should allow authorized user to access the instance" do
+ response = RestClient.put("#{@bind_resp['url']}/foo", {})
+ response.code.should == 200
+ response = RestClient.put("#{@bind_resp['url']}/foo/bar/1", { "message" => "blah blah" }.to_json)
+ response.code.should == 201
+ response = RestClient.get "#{@bind_resp['url']}/foo/bar/_search"
+ response.code.should == 200
+ end
+
+ it "should not allow unauthorized user to access the instance" do
+ e = nil
+ begin
+ RestClient.get "http://foo:bar@#{@bind_resp['host']}:#{@bind_resp['port']}/foo/bar/_search"
+ rescue => e
+ end
+ e.should_not be_nil
+ e.class.should == RestClient::Unauthorized
+ end
+
+ it "should return error when tring to bind on non-existent instance" do
+ e = nil
+ begin
+ @node.bind('non-existent', 'rw')
+ rescue => e
+ end
+ e.should_not be_nil
+ end
+
+ it "should return error when trying to unbind a non-existent service" do
+ EM.run do
+ begin
+ resp = @node.unbind('not existed')
+ rescue => e
+ end
+ e.should be_true
+ EM.add_timer(1) do
+ EM.stop
+ end
+ end
+ end
+
+ # unbind here
+ it "should be able to unbind it" do
+ EM.run do
+ resp = @node.unbind(@bind_resp)
+ resp.should be_true
+ EM.add_timer(1) do
+ EM.stop
+ end
+ end
+ end
+
+ # unprovision here
+ it "should be able to unprovision an existing instance" do
+ EM.run do
+ @node.unprovision(@resp['name'])
+ is_port_open?(@resp['host'], @resp['port']).should_not be_true
+ EM.stop
+ end
+ end
+
+ after:all do
+ EM.run do
+ begin
+ @node.shutdown()
+ EM.stop
+ rescue
+ end
+ end
+ FileUtils.rm_rf(File.dirname(@opts[:base_dir]))
+ end
+
+end
View
66 elasticsearch/spec/elasticsearch_node_orphan_spec.rb
@@ -0,0 +1,66 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+require "spec_helper"
+
+describe "elasticsearch_node check & purge orphan" do
+
+ before :all do
+ EM.run do
+ @opts = get_node_config
+ @logger = @opts[:logger]
+ @node = Node.new(@opts)
+ EM.stop
+ end
+ end
+
+ it "should return proper instances & bindings list" do
+ before_instances = nil, after_instances = nil
+ before_bindings = nil, after_bindings = nil
+ EM.run do
+ before_instances = @node.all_instances_list
+ before_bindings = @node.all_bindings_list
+ @resp = @node.provision("free")
+ EM.add_timer(5) do
+ @bind_resp = @node.bind(@resp["name"], 'rw')
+ EM.add_timer(1) do
+ after_instances = @node.all_instances_list
+ after_bindings = @node.all_bindings_list
+ end
+ EM.add_timer(2) do
+ @node.unprovision(@resp["name"])
+ EM.stop
+ end
+ end
+ end
+ (after_instances - before_instances).include?(@resp["name"]).should be_true
+ (after_bindings - before_bindings).index { |credential| credential["username"] == @bind_resp["username"] }.should_not be_nil
+ end
+
+ it "should be able to purge the orphan" do
+ EM.run do
+ @resp = @node.provision("free")
+ EM.add_timer(5) do
+ @bind_resp = @node.bind(@resp["name"],'rw')
+ EM.add_timer(1) do
+ @node.purge_orphan([@resp["name"]], [@bind_resp])
+ end
+ EM.add_timer(2) do
+ @node.all_instances_list.include?(@resp["name"]).should be_false
+ @node.all_bindings_list.index { |credential| credential["username"] == @bind_resp["username"] }.should be_nil
+ EM.stop
+ end
+ end
+ end
+ end
+
+ after:all do
+ EM.run do
+ begin
+ @node.shutdown()
+ EM.stop
+ rescue
+ end
+ end
+ FileUtils.rm_rf(File.dirname(@opts[:base_dir]))
+ end
+
+end
View
97 elasticsearch/spec/elasticsearch_node_provision_spec.rb
@@ -0,0 +1,97 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+require "spec_helper"
+
+describe "elasticsearch_node provision" do
+
+ before :all do
+ EM.run do
+ @opts = get_node_config()
+ @logger = @opts[:logger]
+ @node = Node.new(@opts)
+ EM.add_timer(1) { @resp = @node.provision("free") }
+ EM.add_timer(9) { EM.stop }
+ end
+ end
+
+ it "should have valid response" do
+ @resp.should_not be_nil
+ inst_name = @resp['name']
+ inst_name.should_not be_nil
+ inst_name.should_not == ""
+ end
+
+ it "should be able to connect to elasticsearch gateway" do
+ is_port_open?(@resp['host'], @resp['port']).should be_true
+ end
+
+ it "should return varz" do
+ EM.run do
+ stats = nil
+ 10.times do
+ stats = @node.varz_details
+ end
+ stats.should_not be_nil
+ stats[:running_services].length.should > 0
+ stats[:running_services][0]['name'].should_not be_nil
+ stats[:running_services][0]['health'].should_not be_nil
+ stats[:running_services][0]['health'].has_key?('status').should be_true
+ stats[:running_services][0]['index'].should_not be_nil
+ stats[:running_services][0]['index'].has_key?('store').should be_true
+ stats[:running_services][0]['process'].should_not be_nil
+ stats[:running_services][0]['process'].has_key?('id').should be_true
+ stats[:disk].should_not be_nil
+ stats[:max_capacity].should > 0
+ stats[:available_capacity].should > 0
+ stats[:instances].length.should > 0
+ EM.stop
+ end
+ end
+
+ it "should keep the result after node restart" do
+ port_open_1 = nil, port_open_2 = nil
+ EM.run do
+ EM.add_timer(0) { @node.shutdown }
+ EM.add_timer(1) { port_open_1 = is_port_open?(@resp['host'], @resp['port']) }
+ EM.add_timer(3) { @node = Node.new(@opts) }
+ EM.add_timer(10) do
+ port_open_2 = is_port_open?(@resp['host'], @resp['port'])
+ EM.stop
+ end
+ end
+ port_open_1.should be_false
+ port_open_2.should be_true
+ end
+
+ it "should return error when unprovisioning a non-existent instance" do
+ EM.run do
+ e = nil
+ begin
+ @node.unprovision('not existent')
+ rescue => e
+ end
+ e.should_not be_nil
+ EM.stop
+ end
+ end
+
+ # unprovision here
+ it "should be able to unprovision an existing instance" do
+ EM.run do
+ @node.unprovision(@resp['name'])
+ is_port_open?(@resp['host'], @resp['port']).should_not be_true
+ EM.stop
+ end
+ end
+
+ after:all do
+ EM.run do
+ begin
+ @node.shutdown()
+ EM.stop
+ rescue
+ end
+ end
+ FileUtils.rm_rf(File.dirname(@opts[:base_dir]))
+ end
+
+end
View
80 elasticsearch/spec/spec_helper.rb
@@ -0,0 +1,80 @@
+# Copyright (c) 2009-2011 VMware, Inc.
+$:.unshift File.join(File.dirname(__FILE__), '..')
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+$LOAD_PATH.unshift(File.expand_path("../../../", __FILE__))
+$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
+require "rubygems"
+require "rspec"
+require 'bundler/setup'
+require 'vcap_services_base'
+require "socket"
+require "timeout"
+require "rest-client"
+require "elasticsearch_service/elasticsearch_node"
+
+include VCAP::Services::ElasticSearch
+
+def is_port_open?(host, port)
+ begin
+ Timeout::timeout(1) do
+ begin
+ TCPSocket.new(host, port).close
+ true
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
+ false
+ end
+ end
+ rescue Timeout::Error => e
+ false
+ end
+end
+
+def get_logger
+ logger = Logger.new(STDOUT)
+ logger.level = Logger::ERROR
+ logger
+end
+
+def parse_property(hash, key, type, options = {})
+ obj = hash[key]
+ if obj.nil?
+ raise "Missing required option: #{key}" unless options[:optional]
+ nil
+ elsif type == Range
+ raise "Invalid Range object: #{obj}" unless obj.kind_of?(Hash)
+ first, last = obj["first"], obj["last"]
+ raise "Invalid Range object: #{obj}" unless first.kind_of?(Integer) and last.kind_of?(Integer)
+ Range.new(first, last)
+ else
+ raise "Invalid #{type} object: #{obj}" unless obj.kind_of?(type)
+ obj
+ end
+end
+
+def config_base_dir
+ ENV["CLOUD_FOUNDRY_CONFIG_PATH"] || File.join(File.dirname(__FILE__), '..', 'config')
+end
+
+def get_node_config
+ config_file = File.join(config_base_dir, "elasticsearch_node.yml")
+ config = YAML.load_file(config_file)
+ config_template = File.join(File.dirname(__FILE__), "../resources/elasticsearch.yml.erb")
+ logging_config_file = File.join(File.dirname(__FILE__), "../resources/logging.yml")
+ options = {
+ :logger => get_logger,
+ :elasticsearch_log_dir => '/tmp/elasticsearch/logs',
+ :elasticsearch_path => parse_property(config, "elasticsearch_path", String),
+ :elasticsearch_plugin_dir => parse_property(config, "elasticsearch_plugin_dir", String),
+ :node_id => parse_property(config, "node_id", String),
+ :mbus => parse_property(config, "mbus", String),
+ :config_template => config_template,
+ :logging_config_file => logging_config_file,
+ :port_range => parse_property(config, "port_range", Range),
+ :max_memory => parse_property(config, "max_memory", Integer),
+ :capacity => parse_property(config, "capacity", Integer),
+ :base_dir => '/tmp/elasticsearch/instances',
+ :local_db => 'sqlite3:/tmp/elasticsearch/elasticsearch_node.db',
+ :pid => '/tmp/elasticsearch/elasticsearch_node.pid'
+ }
+ options
+end
View
BIN elasticsearch/vendor/cache/addressable-2.2.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/bcrypt-ruby-2.1.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/builder-3.0.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/ci_reporter-1.6.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/curb-0.7.16.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/daemons-1.1.5.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/data_objects-0.10.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/datamapper-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/diff-lcs-1.1.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-aggregates-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-constraints-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-core-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-do-adapter-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-migrations-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-serializer-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-sqlite-adapter-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-timestamps-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-transactions-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-types-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/dm-validations-1.1.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/do_sqlite3-0.10.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/em-http-request-0.3.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/escape_utils-0.2.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/eventmachine-0.12.11.cloudfoundry.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/eventmachine_httpserver-0.2.1.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/fastercsv-1.5.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/json-1.4.6.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/json_pure-1.6.5.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/macaddr-1.5.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/mime-types-1.16.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/multi_json-1.0.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/nats-0.4.22.beta.8.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/posix-spawn-0.3.6.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rack-1.4.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rake-0.9.2.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rcov-0.9.9.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/redis-2.2.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/redis-namespace-1.0.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/redisk-0.2.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/resque-1.20.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/resque-status-0.3.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rest-client-1.6.1.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rspec-2.5.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rspec-core-2.5.1.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rspec-expectations-2.5.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/rspec-mocks-2.5.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/ruby-hmac-0.4.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/simplecov-0.5.4.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/simplecov-html-0.5.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/simplecov-rcov-0.2.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/sinatra-1.2.7.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/stringex-1.2.1.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/systemu-2.5.0.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/thin-1.3.1.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/tilt-1.3.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/uuid-2.3.5.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/uuidtools-2.1.2.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/vcap_common-1.0.8.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/vcap_logging-0.1.3.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/vcap_services_base-0.1.9.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/vegas-0.1.11.gem
Binary file not shown.
View
BIN elasticsearch/vendor/cache/yajl-ruby-0.8.3.gem
Binary file not shown.

0 comments on commit 9be53c8

Please sign in to comment.