HBASE-15043 region_status.rb broken with TypeError: no public constructors for Java::OrgApacheHadoopHbaseClient::HBaseAdmin (Samir Ahmic)
This commit is contained in:
parent
1e4992c6ec
commit
9b8895ba29
@ -22,6 +22,7 @@ require 'optparse'
|
||||
include Java
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil
|
||||
import org.apache.commons.logging.Log
|
||||
@ -60,6 +61,7 @@ end
|
||||
|
||||
def getServerNames(hostOrServers, config)
|
||||
ret = []
|
||||
connection = ConnectionFactory.createConnection(config)
|
||||
|
||||
for hostOrServer in hostOrServers
|
||||
# check whether it is already serverName. No need to connect to cluster
|
||||
@ -67,7 +69,7 @@ def getServerNames(hostOrServers, config)
|
||||
if parts.size() == 3
|
||||
ret << hostOrServer
|
||||
else
|
||||
admin = HBaseAdmin.new(config) if not admin
|
||||
admin = connection.getAdmin() if not admin
|
||||
servers = getServers(admin)
|
||||
|
||||
hostOrServer = hostOrServer.gsub(/:/, ",")
|
||||
@ -78,6 +80,7 @@ def getServerNames(hostOrServers, config)
|
||||
end
|
||||
|
||||
admin.close() if admin
|
||||
connection.close()
|
||||
return ret
|
||||
end
|
||||
|
||||
|
@ -67,12 +67,11 @@ org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(log_level)
|
||||
config = HBaseConfiguration.create
|
||||
config.set 'fs.defaultFS', config.get(HConstants::HBASE_DIR)
|
||||
connection = ConnectionFactory.createConnection(config)
|
||||
|
||||
# wait until the master is running
|
||||
admin = nil
|
||||
while true
|
||||
begin
|
||||
admin = HBaseAdmin.new config
|
||||
admin = connection.getAdmin()
|
||||
break
|
||||
rescue MasterNotRunningException => e
|
||||
print 'Waiting for master to start...\n'
|
||||
@ -119,7 +118,7 @@ while iter.hasNext
|
||||
# Gone too far, break
|
||||
break
|
||||
end
|
||||
region = HRegionInfo.getHRegionInfo result
|
||||
region = MetaTableAccessor::getHRegionInfo(result)
|
||||
if not region.isOffline
|
||||
# only include regions that should be online
|
||||
meta_count += 1
|
||||
@ -151,5 +150,7 @@ while true
|
||||
break
|
||||
end
|
||||
end
|
||||
admin.close()
|
||||
connection.close()
|
||||
|
||||
exit server_count == meta_count ? 0 : 1
|
||||
|
@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.EmptyWatcher
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin
|
||||
import org.apache.hadoop.hbase.HTableDescriptor
|
||||
import org.apache.hadoop.conf.Configuration
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory
|
||||
|
||||
# Name of this script
|
||||
NAME = "copy_tables_desc"
|
||||
@ -56,18 +57,23 @@ c1.set(HConstants::ZOOKEEPER_QUORUM, parts1[0])
|
||||
c1.set("hbase.zookeeper.property.clientPort", parts1[1])
|
||||
c1.set(HConstants::ZOOKEEPER_ZNODE_PARENT, parts1[2])
|
||||
|
||||
admin1 = HBaseAdmin.new(c1)
|
||||
connection1 = ConnectionFactory.createConnection(c1)
|
||||
admin1 = connection1.getAdmin()
|
||||
|
||||
c2 = HBaseConfiguration.create()
|
||||
c2.set(HConstants::ZOOKEEPER_QUORUM, parts2[0])
|
||||
c2.set("hbase.zookeeper.property.clientPort", parts2[1])
|
||||
c2.set(HConstants::ZOOKEEPER_ZNODE_PARENT, parts2[2])
|
||||
|
||||
admin2 = HBaseAdmin.new(c2)
|
||||
connection2 = ConnectionFactory.createConnection(c2)
|
||||
admin2 = connection2.getAdmin()
|
||||
|
||||
for t in admin1.listTables()
|
||||
admin2.createTable(t)
|
||||
end
|
||||
|
||||
|
||||
puts "All descriptions were copied"
|
||||
admin1.close()
|
||||
admin2.close()
|
||||
connection1.close()
|
||||
connection2.close()
|
||||
|
@ -25,6 +25,7 @@
|
||||
include Java
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory
|
||||
|
||||
def usage(msg=nil)
|
||||
$stderr.puts 'Usage: shutdown_regionserver.rb <host:port>..'
|
||||
@ -41,8 +42,9 @@ ARGV.each do |x|
|
||||
end
|
||||
|
||||
config = HBaseConfiguration.create()
|
||||
connection = ConnectionFactory.createConnection(config)
|
||||
begin
|
||||
admin = HBaseAdmin.new(config)
|
||||
admin = connection.getAdmin()
|
||||
rescue
|
||||
abort "Error: Couldn't instantiate HBaseAdmin"
|
||||
end
|
||||
@ -50,3 +52,5 @@ end
|
||||
ARGV.each do |hostport|
|
||||
admin.stopRegionServer(hostport)
|
||||
end
|
||||
admin.close()
|
||||
connection.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user