Class: Mcrain::Hbase
- Inherits:
-
Base
- Object
- Base
- Mcrain::Hbase
show all
- Defined in:
- lib/mcrain/hbase.rb
Overview
Mcrain::Hbase can’t start 2 containers concurrently.
The zookeeper in a container of nerdammer/hbase has static configuration for client in same network, so the clients outside of container’s network can’t get the correct configuration from the zookeepr. So Mcrain::Hbase uses static port mapping for 60000 and 60020.
Constant Summary
collapse
- DEFAULT_CLIENT_DEP_JAR_URL =
"https://github.com/junegunn/hbase-client-dep/releases/download/1.0.0/hbase-client-dep-1.0.jar"
- PORT_DEFS =
{
'hbase.zookeeper.property.clientPort' => {method: :zookeeper_port , default: 2181},
'hbase.master.port' => {method: :port , default: 60000},
'hbase.master.info.port' => {method: :master_info_port , default: 60010},
'hbase.regionserver.port' => {method: :regionserver_port , default: 60020},
'hbase.regionserver.info.port' => {method: :regionserver_info_port, default: 60030},
}.freeze
Instance Attribute Summary collapse
Attributes inherited from Base
#skip_reset_after_teardown
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #logger, #reset, #setup, #start, #start_callback, #stop_or_kill_and_remove, #teardown, #wait, #wait_port, work_dir
#client, #client_instantiation_script
#add_volume_options, #container, #container_image, #find_portno, #host, included, #info, #ip, #name, #ssh_uri, #url
Constructor Details
This class inherits a constructor from Mcrain::Base
Instance Attribute Details
#client_dep_jar_path ⇒ Object
22
23
24
|
# File 'lib/mcrain/hbase.rb', line 22
def client_dep_jar_path
@client_dep_jar_path = File.join(self.class.work_dir, File.basename(client_dep_jar_url))
end
|
#client_dep_jar_url ⇒ Object
Instance Method Details
#build_client ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/mcrain/hbase.rb', line 74
def build_client
logger.debug("#{self.class.name}#build_client STARTED")
download_jar unless File.exist?(client_dep_jar_path)
$CLASSPATH << client_dep_jar_path
$LOAD_PATH << 'hbase-jruby/lib'
r = super
logger.debug("#{self.class.name}#build_client COMPLETED")
return r
end
|
#build_docker_options ⇒ Object
97
98
99
100
101
102
103
104
|
# File 'lib/mcrain/hbase.rb', line 97
def build_docker_options
r = super
r["Hostname"] = Mcrain::DockerMachine.docker_hostname!
PORT_DEFS.each do |key, d|
r['HostConfig']['PortBindings']["#{d[:default]}/tcp"] = [{ 'HostPort' => send(d[:method]).to_s }]
end
return r
end
|
#client_class ⇒ Object
30
31
32
|
# File 'lib/mcrain/hbase.rb', line 30
def client_class
::HBase
end
|
#client_init_args ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/mcrain/hbase.rb', line 59
def client_init_args
options = {'hbase.zookeeper.quorum' => host}
PORT_DEFS.each do |key, d|
options[key] = send(d[:method])
end
return [options]
end
|
#client_require ⇒ Object
26
27
28
|
# File 'lib/mcrain/hbase.rb', line 26
def client_require
'hbase-jruby'
end
|
#client_script ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/mcrain/hbase.rb', line 84
def client_script
[
"$CLASSPATH << #{client_dep_jar_path.inspect}",
'$LOAD_PATH << "hbase-jruby/lib"',
super,
].join("\n")
end
|
#download_jar ⇒ Object
67
68
69
70
71
72
|
# File 'lib/mcrain/hbase.rb', line 67
def download_jar
logger.debug("#{self.class.name}#download_jar STARTED")
FileUtils.mkdir_p(File.dirname(client_dep_jar_path))
LoggerPipe.run(Mcrain.logger, "curl -L -o #{client_dep_jar_path} #{client_dep_jar_url}")
logger.debug("#{self.class.name}#download_jar COMPLETED")
end
|
#port ⇒ Object
36
37
38
|
# File 'lib/mcrain/hbase.rb', line 36
def port 60000 end
|
#regionserver_port ⇒ Object
40
41
42
|
# File 'lib/mcrain/hbase.rb', line 40
def regionserver_port 60020 end
|
#wait_for_ready ⇒ Object
92
93
94
95
|
# File 'lib/mcrain/hbase.rb', line 92
def wait_for_ready
c = client
c.tables
end
|