Class: Mcrain::Riak::Node
- Inherits:
-
Object
- Object
- Mcrain::Riak::Node
- Includes:
- ContainerController
- Defined in:
- lib/mcrain/riak.rb
Overview
docker run -e “DOCKER_RIAK_CLUSTER_SIZE=$DOCKER_RIAK_CLUSTER_SIZE” \
-e "DOCKER_RIAK_AUTOMATIC_CLUSTERING=${DOCKER_RIAK_AUTOMATIC_CLUSTERING}" \
-e "DOCKER_RIAK_BACKEND=${DOCKER_RIAK_BACKEND}" \
-e "DOCKER_RIAK_STRONG_CONSISTENCY=${DOCKER_RIAK_STRONG_CONSISTENCY} \
-p $publish_http_port \
-p $publish_pb_port \
--link "riak01:seed" \
--name "riak${index}" \
-d hectcastro/riak > /dev/null 2>&1
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
self.http_port = 8098 # HTTP.
-
#primary_node ⇒ Object
Returns the value of attribute primary_node.
Class Method Summary collapse
Instance Method Summary collapse
- #build_docker_options ⇒ Object
- #http_port ⇒ Object
-
#initialize(owner) ⇒ Node
constructor
A new instance of Node.
- #ping ⇒ Object
- #reset ⇒ Object
Methods included from ContainerController
#add_volume_options, #container, #container_image, #find_portno, #host, included, #info, #ip, #name, #port, #ssh_uri, #url
Constructor Details
#initialize(owner) ⇒ Node
Returns a new instance of Node.
45 46 47 |
# File 'lib/mcrain/riak.rb', line 45 def initialize(owner) @owner = owner end |
Instance Attribute Details
#owner ⇒ Object (readonly)
self.http_port = 8098 # HTTP
43 44 45 |
# File 'lib/mcrain/riak.rb', line 43 def owner @owner end |
#primary_node ⇒ Object
Returns the value of attribute primary_node.
44 45 46 |
# File 'lib/mcrain/riak.rb', line 44 def primary_node @primary_node end |
Class Method Details
.container_image ⇒ Object
36 37 38 |
# File 'lib/mcrain/riak.rb', line 36 def self.container_image Mcrain.configuration.images[:riak] end |
Instance Method Details
#build_docker_options ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mcrain/riak.rb', line 53 def r = super r['HostConfig']['PortBindings']["8098/tcp"] = [{ 'HostPort' => http_port.to_s }] envs = [] envs << "DOCKER_RIAK_CLUSTER_SIZE=#{owner.cluster_size}" envs << "DOCKER_RIAK_AUTOMATIC_CLUSTERING=#{owner.automatic_clustering ? 1 : 0}" envs << "DOCKER_RIAK_BACKEND=#{owner.backend}" envs << "DOCKER_RIAK_STRONG_CONSISTENCY=#{owner.strong_consistency}" r['Env'] = envs unless envs.empty? if primary_node r['HostConfig']['Links'] = ["#{primary_node.name}:seed"] end return r end |
#http_port ⇒ Object
49 50 51 |
# File 'lib/mcrain/riak.rb', line 49 def http_port @http_port ||= find_portno end |
#ping ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/mcrain/riak.rb', line 68 def ping owner.logger.debug("sending a ping http://#{host}:#{http_port}/stats") res = Net::HTTP.start(host, http_port) {|http| http.get('/stats') } r = res.is_a?(Net::HTTPSuccess) owner.logger.debug("#{res.inspect} #=> #{r}") return r rescue => e return false end |
#reset ⇒ Object
78 79 80 81 82 |
# File 'lib/mcrain/riak.rb', line 78 def reset instance_variables.each do |var| instance_variable_set(var, nil) end end |