lib/riak/node/configuration.rb in riak-client-1.2.0 vs lib/riak/node/configuration.rb in riak-client-1.4.0
- old
+ new
@@ -1,20 +1,24 @@
require 'pathname'
require 'yaml'
module Riak
class Node
+
+ # do not copy these directories to the test node
+ NODE_DIR_SKIP_LIST = [:data, :pipe]
+
# The directories (and accessor methods) that will be created
# under the generated node.
- NODE_DIRECTORIES = [:bin, :etc, :log, :data, :ring, :pipe]
+ NODE_DIRECTORIES = [:bin, :etc, :log, :data, :pipe]
+ # Makes accessor methods for all the node directories that
+ # return Pathname objects.
NODE_DIRECTORIES.each do |dir|
- # Makes accessor methods for all the node directories that
- # return Pathname objects.
class_eval %Q{
def #{dir}
- root + '#{dir}'
+ root + '#{dir}/'
end
}
end
# @return [Hash] the contents of the Erlang environment, which will
@@ -53,23 +57,28 @@
def http_port
# We'll only support 0.14 and later, which uses http rather than web_ip/web_port
env[:riak_core][:http][0][1]
end
+ def pb_config_section
+ return :riak_kv if version < '1.4.0'
+ return :riak_api
+ end
+
# @return [Fixnum] the port to which the Protocol Buffers API is connected.
def pb_port
- env[:riak_kv][:pb_port]
+ env[pb_config_section][:pb_port]
end
# @return [String] the interface to which the HTTP API is connected
def http_ip
env[:riak_core][:http][0][0]
end
# @return [String] the interface to which the Protocol Buffers API is connected
def pb_ip
- env[:riak_kv][:pb_ip]
+ env[pb_config_section][:pb_ip]
end
# @return [Symbol] the storage backend for Riak Search.
def search_backend
env[:riak_search][:search_backend]
@@ -91,30 +100,32 @@
def cookie
vm['-setcookie']
end
# The source of the Riak installation from where the {Node} will
- # be generated. This should point to the directory that contains
- # the 'riak[search]' and 'riak[search]-admin' scripts.
+ # be generated.
# @return [Pathname] the source Riak installation
attr_reader :source
# The root directory of the {Node}, where all files are placed
# after generation.
# @return [Pathname] the root directory of the node
attr_reader :root
+ def env_script
+ @env_script ||= root + 'lib' + 'env.sh'
+ end
+
# The script for starting, stopping and pinging the Node.
# @return [Pathname] the path to the control script
def control_script
@control_script ||= root + 'bin' + control_script_name
end
- # The name of the 'riak' or 'riaksearch' control script.
- # @return [String] 'riak' or 'riaksearch'
+ # The name of the 'riak' control script.
def control_script_name
- @control_script_name ||= (source + 'riaksearch').exist? ? 'riaksearch' : 'riak'
+ @control_script_name ||= 'riak'
end
# The script for controlling non-lifecycle features of Riak like
# joining, leaving, status, ringready, etc.
# @return [Pathname] the path to the administrative script
@@ -153,42 +164,42 @@
def configure_data
[:bitcask, :eleveldb, :merge_index].each {|k| env[k] ||= {} }
env[:bitcask][:data_root] ||= (data + 'bitcask').expand_path.to_s
env[:eleveldb][:data_root] ||= (data + 'leveldb').expand_path.to_s
env[:merge_index][:data_root] ||= (data + 'merge_index').expand_path.to_s
- env[:riak_core][:ring_state_dir] ||= ring.expand_path.to_s
env[:riak_core][:slide_private_dir] ||= (data + 'slide-data').expand_path.to_s
+ env[:riak_core][:ring_state_dir] ||= (data + 'ring').expand_path.to_s
+
NODE_DIRECTORIES.each do |dir|
- next if [:ring, :pipe].include?(dir)
env[:riak_core][:"platform_#{dir}_dir"] ||= send(dir).to_s
end
end
# Sets directories and handlers for logging.
def configure_logging
if env[:lager]
env[:lager][:handlers] = {
:lager_console_backend => :info,
:lager_file_backend => [
- Tuple[(log+"error.log").expand_path.to_s, :error],
- Tuple[(log+"console.log").expand_path.to_s, :info]
+ Tuple[(log + "error.log").expand_path.to_s, :error],
+ Tuple[(log + "console.log").expand_path.to_s, :info]
]
}
- env[:lager][:crash_log] = (log+"crash.log").to_s
+ env[:lager][:crash_log] = (log + "crash.log").to_s
else
# TODO: Need a better way to detect this, the defaults point
# to 1.0-style configs. Maybe there should be some kind of
# detection routine.
# Use sasl error logger for 0.14.
env[:riak_err] ||= {
:term_max_size => 65536,
:fmt_max_bytes => 65536
}
env[:sasl] = {
- :sasl_error_logger => Tuple[:file, (log+"sasl-error.log").expand_path.to_s],
+ :sasl_error_logger => Tuple[:file, (log + "sasl-error.log").expand_path.to_s],
:errlog_type => :error,
- :error_logger_mf_dir => (log+"sasl").expand_path.to_s,
+ :error_logger_mf_dir => (log + "sasl").expand_path.to_s,
:error_logger_mf_maxbytes => 10485760,
:error_logger_mf_maxfiles => 5
}
end
vm['-env ERL_CRASH_DUMP'] = (log + 'erl_crash.dump').to_s
@@ -225,12 +236,12 @@
unless env[:riak_core][:http]
env[:riak_core][:http] = [Tuple[interface, min_port]]
min_port += 1
end
env[:riak_core][:http] = env[:riak_core][:http].map {|pair| Tuple[*pair] }
- env[:riak_kv][:pb_ip] = interface unless env[:riak_kv][:pb_ip]
- unless env[:riak_kv][:pb_port]
- env[:riak_kv][:pb_port] = min_port
+ env[pb_config_section][:pb_ip] = interface unless env[pb_config_section][:pb_ip]
+ unless env[pb_config_section][:pb_port]
+ env[pb_config_section][:pb_port] = min_port
min_port += 1
end
unless env[:riak_core][:handoff_port]
env[:riak_core][:handoff_port] = min_port
min_port += 1