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