HBASE-12675 Use interface methods in shell scripts (solomon duskis)
This commit is contained in:
parent
7cf86b62a7
commit
ee4d9b5315
|
@ -23,6 +23,7 @@ java_import org.apache.hadoop.hbase.util.Pair
|
||||||
java_import org.apache.hadoop.hbase.util.RegionSplitter
|
java_import org.apache.hadoop.hbase.util.RegionSplitter
|
||||||
java_import org.apache.hadoop.hbase.util.Bytes
|
java_import org.apache.hadoop.hbase.util.Bytes
|
||||||
java_import org.apache.hadoop.hbase.ServerName
|
java_import org.apache.hadoop.hbase.ServerName
|
||||||
|
java_import org.apache.hadoop.hbase.TableName
|
||||||
java_import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos::SnapshotDescription
|
java_import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos::SnapshotDescription
|
||||||
|
|
||||||
# Wrapper for org.apache.hadoop.hbase.client.HBaseAdmin
|
# Wrapper for org.apache.hadoop.hbase.client.HBaseAdmin
|
||||||
|
@ -43,7 +44,7 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Returns a list of tables in hbase
|
# Returns a list of tables in hbase
|
||||||
def list(regex = ".*")
|
def list(regex = ".*")
|
||||||
@admin.listTableNames(regex).map { |t| t.getNameAsString }
|
@admin.listTables(regex).map { |t| t.getNameAsString }
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
@ -346,17 +347,17 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Returns table's structure description
|
# Returns table's structure description
|
||||||
def describe(table_name)
|
def describe(table_name)
|
||||||
@admin.getTableDescriptor(table_name.to_java_bytes).to_s
|
@admin.getTableDescriptor(TableName.valueOf(table_name)).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_column_families(table_name)
|
def get_column_families(table_name)
|
||||||
@admin.getTableDescriptor(table_name.to_java_bytes).getColumnFamilies()
|
@admin.getTableDescriptor(TableName.valueOf(table_name)).getColumnFamilies()
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Truncates table (deletes all records by recreating the table)
|
# Truncates table (deletes all records by recreating the table)
|
||||||
def truncate(table_name, conf = @conf)
|
def truncate(table_name, conf = @conf)
|
||||||
table_description = @admin.getTableDescriptor(table_name.to_java_bytes)
|
table_description = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
||||||
raise ArgumentError, "Table #{table_name} is not enabled. Enable it first.'" unless enabled?(table_name)
|
raise ArgumentError, "Table #{table_name} is not enabled. Enable it first.'" unless enabled?(table_name)
|
||||||
yield 'Disabling table...' if block_given?
|
yield 'Disabling table...' if block_given?
|
||||||
@admin.disableTable(table_name)
|
@admin.disableTable(table_name)
|
||||||
|
@ -446,7 +447,7 @@ module Hbase
|
||||||
raise(ArgumentError, "There should be at least one argument but the table name") if args.empty?
|
raise(ArgumentError, "There should be at least one argument but the table name") if args.empty?
|
||||||
|
|
||||||
# Get table descriptor
|
# Get table descriptor
|
||||||
htd = @admin.getTableDescriptor(table_name.to_java_bytes)
|
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
||||||
|
|
||||||
# Process all args
|
# Process all args
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
|
@ -478,7 +479,7 @@ module Hbase
|
||||||
end
|
end
|
||||||
|
|
||||||
# We bypass descriptor when adding column families; refresh it to apply other args correctly.
|
# We bypass descriptor when adding column families; refresh it to apply other args correctly.
|
||||||
htd = @admin.getTableDescriptor(table_name.to_java_bytes)
|
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -513,7 +514,7 @@ module Hbase
|
||||||
|
|
||||||
if method == "delete"
|
if method == "delete"
|
||||||
# We bypass descriptor when deleting column families; refresh it to apply other args correctly.
|
# We bypass descriptor when deleting column families; refresh it to apply other args correctly.
|
||||||
htd = @admin.getTableDescriptor(table_name.to_java_bytes)
|
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,7 @@ module Hbase
|
||||||
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
||||||
|
|
||||||
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name.to_java_bytes)
|
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name.to_java_bytes)
|
||||||
htd = @admin.getTableDescriptor(tablebytes)
|
htd = @admin.getTableDescriptor(tableName)
|
||||||
|
|
||||||
if (family != nil)
|
if (family != nil)
|
||||||
raise(ArgumentError, "Can't find a family: #{family}") unless htd.hasFamily(family.to_java_bytes)
|
raise(ArgumentError, "Can't find a family: #{family}") unless htd.hasFamily(family.to_java_bytes)
|
||||||
|
|
|
@ -115,11 +115,11 @@ EOF
|
||||||
if @@thread_pool then
|
if @@thread_pool then
|
||||||
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
|
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
|
||||||
configuration, @@thread_pool)
|
configuration, @@thread_pool)
|
||||||
@table = @connection.getTable(table_name)
|
@table = @connection.getTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
||||||
else
|
else
|
||||||
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
|
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
|
||||||
configuration)
|
configuration)
|
||||||
@table = @connection.getTable(table_name)
|
@table = @connection.getTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
||||||
@@thread_pool = @table.getPool()
|
@@thread_pool = @table.getPool()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -612,9 +612,7 @@ EOF
|
||||||
|
|
||||||
# Checks if current table is one of the 'meta' tables
|
# Checks if current table is one of the 'meta' tables
|
||||||
def is_meta_table?
|
def is_meta_table?
|
||||||
tn = @table.table_name
|
org.apache.hadoop.hbase.TableName::META_TABLE_NAME.equals(@table.getName())
|
||||||
org.apache.hadoop.hbase.util.Bytes.equals(tn,
|
|
||||||
org.apache.hadoop.hbase.TableName::META_TABLE_NAME.getName)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns family and (when has it) qualifier for a column name
|
# Returns family and (when has it) qualifier for a column name
|
||||||
|
|
Loading…
Reference in New Issue