class Mcrain::Hbase

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.

Constants

DEFAULT_CLIENT_DEP_JAR_URL
PORT_DEFS

blog.cloudera.com/blog/2013/07/guide-to-using-apache-hbase-ports/

Attributes

client_dep_jar_path[W]
client_dep_jar_url[W]

Public Instance Methods

build_client() click to toggle source
Calls superclass method Mcrain::ClientProvider#build_client
# 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() click to toggle source
# 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() click to toggle source
# File lib/mcrain/hbase.rb, line 30
def client_class
  ::HBase
end
client_dep_jar_path() click to toggle source
# 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() click to toggle source
# File lib/mcrain/hbase.rb, line 17
def client_dep_jar_url
  @client_dep_jar_url ||= DEFAULT_CLIENT_DEP_JAR_URL
end
client_init_args() click to toggle source
# 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() click to toggle source
# File lib/mcrain/hbase.rb, line 26
def client_require
  'hbase-jruby'
end
client_script() click to toggle source
Calls superclass method Mcrain::ClientProvider#client_script
# 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() click to toggle source
# 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() click to toggle source
# File lib/mcrain/hbase.rb, line 36
def port # hbase.master.port
  60000 # static port number which is defined by the container
end
regionserver_port() click to toggle source
# File lib/mcrain/hbase.rb, line 40
def regionserver_port # hbase.regionserver.port
  60020 # static port number which is defined by the container
end
wait_for_ready() click to toggle source
# File lib/mcrain/hbase.rb, line 92
def wait_for_ready
  c = client
  c.tables
end