Method: HBase#initialize
- Defined in:
- lib/hbase-jruby/hbase.rb
permalink #initialize(zookeeper_quorum) ⇒ HBase #initialize(config) ⇒ HBase
Connects to HBase
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/hbase-jruby/hbase.rb', line 52 def initialize config = {} begin org.apache.hadoop.conf.Configuration rescue NameError raise NameError.new( "Required Java classes not loaded. Set up CLASSPATH.`") end HBase.import_java_classes! @config = case config when String HBaseConfiguration.create.tap do |hbcfg| hbcfg.set 'hbase.zookeeper.quorum', config end when org.apache.hadoop.conf.Configuration config else HBaseConfiguration.create.tap do |hbcfg| config.each do |k, v| hbcfg.set k.to_s, v.to_s end end end @connection = HConnectionManager.createConnection @config @htable_pool = if @connection.respond_to?(:getTable) nil else HTablePool.new @config, java.lang.Integer::MAX_VALUE end @mutex = Mutex.new @schema = Schema.new @closed = false end |