2008-06-13 01:50:00 -04:00
|
|
|
# File passed to org.jruby.Main by bin/hbase. Pollutes jirb with hbase imports
|
|
|
|
# and hbase commands and then loads jirb. Outputs a banner that tells user
|
|
|
|
# where to find help, shell version, and loads up a custom hirb.
|
2008-05-30 15:19:46 -04:00
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# TODO: Add 'debug' support (client-side logs show in shell). Add it as
|
|
|
|
# command-line option and as command.
|
|
|
|
# TODO: Interrupt a table creation or a connection to a bad master. Currently
|
2008-06-18 18:24:34 -04:00
|
|
|
# has to time out. Below we've set down the retries for rpc and hbase but
|
|
|
|
# still can be annoying (And there seem to be times when we'll retry for
|
|
|
|
# ever regardless)
|
2008-06-13 01:50:00 -04:00
|
|
|
# TODO: Add support for listing and manipulating catalog tables, etc.
|
2008-06-17 19:58:05 -04:00
|
|
|
# TODO: Encoding; need to know how to go from ruby String to UTF-8 bytes
|
2008-05-30 01:13:58 -04:00
|
|
|
|
2008-06-12 02:00:35 -04:00
|
|
|
# Run the java magic include and import basic HBase types that will help ease
|
|
|
|
# hbase hacking.
|
2008-05-30 01:13:58 -04:00
|
|
|
include Java
|
|
|
|
|
2008-05-30 15:19:46 -04:00
|
|
|
# Some goodies for hirb. Should these be left up to the user's discretion?
|
|
|
|
require 'irb/completion'
|
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# Add the $HBASE_HOME/bin directory, the location of this script, to the ruby
|
|
|
|
# load path so I can load up my HBase ruby modules
|
2008-06-12 02:00:35 -04:00
|
|
|
$LOAD_PATH.unshift File.dirname($PROGRAM_NAME)
|
2008-06-13 01:50:00 -04:00
|
|
|
# Require formatter and hbase
|
2008-06-12 02:00:35 -04:00
|
|
|
require 'Formatter'
|
|
|
|
require 'HBase'
|
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# See if there are args for this shell. If any, read and then strip from ARGV
|
|
|
|
# so they don't go through to irb. Output shell 'usage' if user types '--help'
|
|
|
|
cmdline_help = <<HERE # HERE document output as shell usage
|
2008-06-12 02:00:35 -04:00
|
|
|
HBase Shell command-line options:
|
2008-06-18 18:24:34 -04:00
|
|
|
format Formatter for outputting results: console | html. Default: console
|
2009-01-24 02:11:32 -05:00
|
|
|
format-width Width of table outputs. Default: 110 characters.
|
2008-06-18 18:24:34 -04:00
|
|
|
master HBase master shell should connect to: e.g --master=example:60000
|
2008-06-12 02:00:35 -04:00
|
|
|
HERE
|
|
|
|
master = nil
|
|
|
|
found = []
|
2008-06-18 18:24:34 -04:00
|
|
|
format = 'console'
|
|
|
|
format_width = 110
|
2008-06-12 02:00:35 -04:00
|
|
|
for arg in ARGV
|
|
|
|
if arg =~ /^--master=(.+)/i
|
|
|
|
master = $1
|
|
|
|
found.push(arg)
|
|
|
|
elsif arg =~ /^--format=(.+)/i
|
|
|
|
format = $1
|
|
|
|
if format =~ /^html$/i
|
2008-06-18 18:24:34 -04:00
|
|
|
raise NoMethodError.new("Not yet implemented")
|
2008-06-12 02:00:35 -04:00
|
|
|
elsif format =~ /^console$/i
|
|
|
|
# This is default
|
|
|
|
else
|
|
|
|
raise ArgumentError.new("Unsupported format " + arg)
|
|
|
|
end
|
2008-06-18 18:24:34 -04:00
|
|
|
found.push(arg)
|
|
|
|
elsif arg =~ /^--format-width=(.+)/i
|
|
|
|
format_width = $1.to_i
|
|
|
|
found.push(arg)
|
2008-06-12 02:00:35 -04:00
|
|
|
elsif arg == '-h' || arg == '--help'
|
2008-06-13 01:50:00 -04:00
|
|
|
puts cmdline_help
|
2008-06-12 02:00:35 -04:00
|
|
|
exit
|
2008-10-08 20:03:50 -04:00
|
|
|
else
|
|
|
|
# Presume it a script and try running it. Will go on to run the shell unless
|
|
|
|
# script calls 'exit' or 'exit 0' or 'exit errcode'.
|
|
|
|
load(arg)
|
2008-06-12 02:00:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
for arg in found
|
|
|
|
ARGV.delete(arg)
|
|
|
|
end
|
2008-06-18 18:24:34 -04:00
|
|
|
# Presume console format.
|
|
|
|
@formatter = Formatter::Console.new(STDOUT, format_width)
|
|
|
|
# TODO, etc. @formatter = Formatter::XHTML.new(STDOUT)
|
2008-06-12 02:00:35 -04:00
|
|
|
|
|
|
|
# Setup the HBase module. Create a configuration. If a master, set it.
|
2008-06-17 19:58:05 -04:00
|
|
|
# Turn off retries in hbase and ipc. Human doesn't want to wait on N retries.
|
|
|
|
@configuration = org.apache.hadoop.hbase.HBaseConfiguration.new()
|
2008-06-12 02:00:35 -04:00
|
|
|
@configuration.set("hbase.master", master) if master
|
2008-09-05 19:57:40 -04:00
|
|
|
@configuration.setInt("hbase.client.retries.number", 5)
|
2008-06-17 19:58:05 -04:00
|
|
|
@configuration.setInt("ipc.client.connect.max.retries", 3)
|
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# Do lazy create of admin because if we are pointed at bad master, it will hang
|
2008-06-12 02:00:35 -04:00
|
|
|
# shell on startup trying to connect.
|
|
|
|
@admin = nil
|
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# Promote hbase constants to be constants of this module so can
|
|
|
|
# be used bare as keys in 'create', 'alter', etc. To see constants
|
2008-06-13 18:42:11 -04:00
|
|
|
# in IRB, type 'Object.constants'. Don't promote defaults because
|
|
|
|
# flattens all types to String. Can be confusing.
|
2008-06-13 01:50:00 -04:00
|
|
|
def promoteConstants(constants)
|
|
|
|
# The constants to import are all in uppercase
|
|
|
|
for c in constants
|
|
|
|
if c == c.upcase
|
2008-06-13 18:42:11 -04:00
|
|
|
eval("%s = \"%s\"" % [c, c]) unless c =~ /DEFAULT_.*/
|
2008-06-13 01:50:00 -04:00
|
|
|
end
|
2008-06-12 02:00:35 -04:00
|
|
|
end
|
2008-06-13 01:50:00 -04:00
|
|
|
end
|
2008-06-17 19:58:05 -04:00
|
|
|
promoteConstants(org.apache.hadoop.hbase.HColumnDescriptor.constants)
|
|
|
|
promoteConstants(org.apache.hadoop.hbase.HTableDescriptor.constants)
|
|
|
|
promoteConstants(HBase.constants)
|
2008-06-13 01:50:00 -04:00
|
|
|
|
|
|
|
# Start of the hbase shell commands.
|
2008-06-12 02:00:35 -04:00
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
# General shell methods
|
2008-06-12 02:00:35 -04:00
|
|
|
|
2008-12-23 18:10:25 -05:00
|
|
|
def tools
|
|
|
|
# Help for hbase shell surgery tools
|
|
|
|
h = <<HERE
|
|
|
|
HBASE SURGERY TOOLS:
|
|
|
|
close_region Close a single region. Optionally specify regionserver.
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
hbase> close_region 'REGIONNAME'
|
|
|
|
hbase> close_region 'REGIONNAME', 'REGIONSERVER_IP:PORT'
|
|
|
|
|
2009-01-05 20:12:36 -05:00
|
|
|
compact Compact all regions in passed table or pass a region row
|
|
|
|
to compact an individual region
|
|
|
|
|
|
|
|
disable_region Disable a single region
|
|
|
|
|
|
|
|
enable_region Enable a single region. For example:
|
|
|
|
|
|
|
|
hbase> enable_region 'REGIONNAME'
|
|
|
|
|
|
|
|
flush Flush all regions in passed table or pass a region row to
|
|
|
|
flush an individual region. For example:
|
|
|
|
|
|
|
|
hbase> flush 'TABLENAME'
|
|
|
|
hbase> flush 'REGIONNAME'
|
|
|
|
|
|
|
|
major_compact Run major compaction on passed table or pass a region row
|
|
|
|
to major compact an individual region
|
|
|
|
|
|
|
|
split Split table or pass a region row to split individual region
|
|
|
|
|
2008-12-23 18:10:25 -05:00
|
|
|
Above commands are for 'experts'-only as misuse can damage an install
|
|
|
|
HERE
|
|
|
|
puts h
|
|
|
|
end
|
|
|
|
|
2008-06-01 01:19:08 -04:00
|
|
|
def help
|
2008-06-13 01:50:00 -04:00
|
|
|
# Output help. Help used to be a dictionary of name to short and long
|
|
|
|
# descriptions emitted using Formatters but awkward getting it to show
|
|
|
|
# nicely on console; instead use a HERE document. Means we can't
|
|
|
|
# output help other than on console but not an issue at the moment.
|
|
|
|
# TODO: Add help to the commands themselves rather than keep it distinct
|
|
|
|
h = <<HERE
|
|
|
|
HBASE SHELL COMMANDS:
|
2008-06-17 19:58:05 -04:00
|
|
|
alter Alter column family schema; pass table name and a dictionary
|
|
|
|
specifying new column family schema. Dictionaries are described
|
|
|
|
below in the GENERAL NOTES section. Dictionary must include name
|
2008-09-22 17:16:21 -04:00
|
|
|
of column family to alter. For example,
|
|
|
|
|
|
|
|
To change or add the 'f1' column family in table 't1' from defaults
|
|
|
|
to instead keep a maximum of 5 cell VERSIONS, do:
|
2008-06-17 19:58:05 -04:00
|
|
|
hbase> alter 't1', {NAME => 'f1', VERSIONS => 5}
|
2008-08-12 14:30:33 -04:00
|
|
|
|
2008-09-22 17:16:21 -04:00
|
|
|
To delete the 'f1' column family in table 't1', do:
|
|
|
|
hbase> alter 't1', {NAME => 'f1', METHOD => 'delete'}
|
2009-01-29 11:51:26 -05:00
|
|
|
|
|
|
|
You can also change table-scope attributes like MAX_FILESIZE
|
|
|
|
MEMCACHE_FLUSHSIZE and READONLY.
|
|
|
|
|
|
|
|
For example, to change the max size of a family to 128MB, do:
|
|
|
|
hbase> alter 't1', {METHOD => 'table_att', MAX_FILESIZE => '134217728'}
|
2008-09-22 17:16:21 -04:00
|
|
|
|
2008-08-12 14:30:33 -04:00
|
|
|
count Count the number of rows in a table. This operation may take a LONG
|
|
|
|
time (Run '$HADOOP_HOME/bin/hadoop jar hbase.jar rowcount' to run a
|
|
|
|
counting mapreduce job). Current count is shown every 1000 rows by
|
|
|
|
default. Count interval may be optionally specified. Examples:
|
|
|
|
|
|
|
|
hbase> count 't1'
|
|
|
|
hbase> count 't1', 100000
|
2008-06-17 19:58:05 -04:00
|
|
|
|
|
|
|
create Create table; pass table name, a dictionary of specifications per
|
|
|
|
column family, and optionally a dictionary of table configuration.
|
|
|
|
Dictionaries are described below in the GENERAL NOTES section.
|
2008-07-22 15:22:21 -04:00
|
|
|
Examples:
|
2008-06-17 19:58:05 -04:00
|
|
|
|
2008-06-25 13:19:17 -04:00
|
|
|
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
|
2008-07-01 00:15:50 -04:00
|
|
|
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
|
2008-07-22 15:22:21 -04:00
|
|
|
hbase> # The above in shorthand would be the following:
|
2008-07-01 00:15:50 -04:00
|
|
|
hbase> create 't1', 'f1', 'f2', 'f3'
|
2008-08-17 18:13:13 -04:00
|
|
|
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, \\
|
2008-07-22 15:22:21 -04:00
|
|
|
BLOCKCACHE => true}
|
2008-07-01 00:15:50 -04:00
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
describe Describe the named table: e.g. "hbase> describe 't1'"
|
|
|
|
|
|
|
|
delete Put a delete cell value at specified table/row/column and optionally
|
|
|
|
timestamp coordinates. Deletes must match the deleted cell's
|
|
|
|
coordinates exactly. When scanning, a delete cell suppresses older
|
2008-07-09 17:39:45 -04:00
|
|
|
versions. Takes arguments like the 'put' command described below
|
2008-06-17 19:58:05 -04:00
|
|
|
|
2008-07-09 17:39:45 -04:00
|
|
|
deleteall Delete all cells in a given row; pass a table name, row, and optionally
|
|
|
|
a column and timestamp
|
2008-06-17 19:58:05 -04:00
|
|
|
|
|
|
|
disable Disable the named table: e.g. "hbase> disable 't1'"
|
2008-07-09 17:39:45 -04:00
|
|
|
|
|
|
|
drop Drop the named table. Table must first be disabled
|
2008-06-17 19:58:05 -04:00
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
enable Enable the named table
|
2008-06-17 19:58:05 -04:00
|
|
|
|
|
|
|
exists Does the named table exist? e.g. "hbase> exists 't1'"
|
|
|
|
|
|
|
|
exit Type "hbase> exit" to leave the HBase Shell
|
|
|
|
|
|
|
|
get Get row or cell contents; pass table name, row, and optionally
|
|
|
|
a dictionary of column(s), timestamp and versions. Examples:
|
|
|
|
|
|
|
|
hbase> get 't1', 'r1'
|
|
|
|
hbase> get 't1', 'r1', {COLUMN => 'c1'}
|
|
|
|
hbase> get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']}
|
2008-07-19 18:25:46 -04:00
|
|
|
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
|
2008-08-17 18:13:13 -04:00
|
|
|
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, \\
|
2008-08-15 15:24:14 -04:00
|
|
|
VERSIONS => 4}
|
2008-06-17 19:58:05 -04:00
|
|
|
|
|
|
|
list List all tables in hbase
|
|
|
|
|
2008-07-19 18:25:46 -04:00
|
|
|
put Put a cell 'value' at specified table/row/column and optionally
|
2008-06-17 19:58:05 -04:00
|
|
|
timestamp coordinates. To put a cell value into table 't1' at
|
|
|
|
row 'r1' under column 'c1' marked with the time 'ts1', do:
|
|
|
|
|
2008-07-19 18:25:46 -04:00
|
|
|
hbase> put 't1', 'r1', 'c1', 'value', ts1
|
2008-06-17 19:58:05 -04:00
|
|
|
|
2008-12-23 18:10:25 -05:00
|
|
|
tools Listing of hbase surgery tools
|
|
|
|
|
2008-10-08 19:45:30 -04:00
|
|
|
scan Scan a table; pass table name and optionally a dictionary of scanner
|
|
|
|
specifications. Scanner specifications may include one or more of
|
|
|
|
the following: LIMIT, STARTROW, STOPROW, TIMESTAMP, or COLUMNS. If
|
|
|
|
no columns are specified, all columns will be scanned. To scan all
|
|
|
|
members of a column family, leave the qualifier empty as in
|
|
|
|
'col_family:'. Examples:
|
2008-06-18 18:24:34 -04:00
|
|
|
|
|
|
|
hbase> scan '.META.'
|
2008-10-08 19:45:30 -04:00
|
|
|
hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
|
|
|
|
hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \\
|
|
|
|
STARTROW => 'xyz'}
|
2008-10-29 14:01:35 -04:00
|
|
|
|
2009-02-03 05:22:06 -05:00
|
|
|
shutdown Shut down the cluster.
|
|
|
|
|
2008-10-29 14:01:35 -04:00
|
|
|
truncate Disables, drops and recreates the specified table.
|
2008-07-09 17:39:45 -04:00
|
|
|
|
2008-06-13 01:50:00 -04:00
|
|
|
version Output this HBase version
|
|
|
|
|
|
|
|
GENERAL NOTES:
|
|
|
|
Quote all names in the hbase shell such as table and column names. Don't
|
2008-06-17 19:58:05 -04:00
|
|
|
forget commas delimit command parameters. Type <RETURN> after entering a
|
|
|
|
command to run it. Dictionaries of configuration used in the creation and
|
|
|
|
alteration of tables are ruby Hashes. They look like this:
|
|
|
|
|
|
|
|
{'key1' => 'value1', 'key2' => 'value2', ...}
|
|
|
|
|
|
|
|
They are opened and closed with curley-braces. Key/values are delimited by
|
|
|
|
the '=>' character combination. Usually keys are predefined constants such as
|
|
|
|
NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type
|
2008-06-13 18:42:11 -04:00
|
|
|
'Object.constants' to see a (messy) list of all constants in the environment.
|
2008-06-17 19:58:05 -04:00
|
|
|
|
|
|
|
This HBase shell is the JRuby IRB with the above HBase-specific commands added.
|
|
|
|
For more on the HBase Shell, see http://wiki.apache.org/hadoop/Hbase/Shell
|
2008-06-13 01:50:00 -04:00
|
|
|
HERE
|
|
|
|
puts h
|
2008-05-30 01:13:58 -04:00
|
|
|
end
|
|
|
|
|
2008-06-01 01:06:52 -04:00
|
|
|
def version
|
2008-06-13 01:50:00 -04:00
|
|
|
# Output version.
|
|
|
|
puts "Version: #{org.apache.hadoop.hbase.util.VersionInfo.getVersion()},\
|
2008-05-30 15:19:46 -04:00
|
|
|
r#{org.apache.hadoop.hbase.util.VersionInfo.getRevision()},\
|
2008-06-13 01:50:00 -04:00
|
|
|
#{org.apache.hadoop.hbase.util.VersionInfo.getDate()}"
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2009-02-03 05:22:06 -05:00
|
|
|
def shutdown
|
|
|
|
admin().shutdown()
|
|
|
|
end
|
|
|
|
|
2008-06-01 01:19:08 -04:00
|
|
|
# DDL
|
|
|
|
|
2008-06-13 18:42:11 -04:00
|
|
|
def admin()
|
2008-06-12 02:00:35 -04:00
|
|
|
@admin = HBase::Admin.new(@configuration, @formatter) unless @admin
|
2008-06-13 18:42:11 -04:00
|
|
|
@admin
|
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def table(table)
|
|
|
|
# Create new one each time
|
|
|
|
HBase::Table.new(@configuration, table, @formatter)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def create(table, *args)
|
|
|
|
admin().create(table, args)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def drop(table)
|
|
|
|
admin().drop(table)
|
|
|
|
end
|
|
|
|
|
|
|
|
def alter(table, args)
|
|
|
|
admin().alter(table, args)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-12 02:00:35 -04:00
|
|
|
# Administration
|
|
|
|
|
|
|
|
def list
|
2008-06-13 18:42:11 -04:00
|
|
|
admin().list()
|
2008-06-12 02:00:35 -04:00
|
|
|
end
|
2008-06-13 01:50:00 -04:00
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def describe(table)
|
|
|
|
admin().describe(table)
|
2008-06-13 01:50:00 -04:00
|
|
|
end
|
2008-06-01 01:19:08 -04:00
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def enable(table)
|
|
|
|
admin().enable(table)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def disable(table)
|
|
|
|
admin().disable(table)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-12-23 18:10:25 -05:00
|
|
|
def enable_region(regionName)
|
|
|
|
admin().enable_region(regionName)
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable_region(regionName)
|
|
|
|
admin().disable_region(regionName)
|
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def exists(table)
|
|
|
|
admin().exists(table)
|
2008-06-12 02:00:35 -04:00
|
|
|
end
|
2008-10-29 14:01:35 -04:00
|
|
|
|
|
|
|
def truncate(table)
|
|
|
|
admin().truncate(table)
|
|
|
|
end
|
2008-12-23 18:10:25 -05:00
|
|
|
|
|
|
|
def close_region(regionName, server = nil)
|
|
|
|
admin().close_region(regionName, server)
|
|
|
|
end
|
2008-06-12 02:00:35 -04:00
|
|
|
|
2008-06-01 01:19:08 -04:00
|
|
|
# CRUD
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def get(table, row, args = {})
|
|
|
|
table(table).get(row, args)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-17 19:58:05 -04:00
|
|
|
def put(table, row, column, value, timestamp = nil)
|
|
|
|
table(table).put(row, column, value, timestamp)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-10-08 19:45:30 -04:00
|
|
|
def scan(table, args = {})
|
|
|
|
table(table).scan(args)
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-07-09 17:39:45 -04:00
|
|
|
def delete(table, row, column,
|
|
|
|
timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
|
|
|
|
table(table).delete(row, column, timestamp)
|
2008-06-17 19:58:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def deleteall(table, row, column = nil,
|
|
|
|
timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
|
2008-06-23 14:19:54 -04:00
|
|
|
table(table).deleteall(row, column, timestamp)
|
2008-06-17 19:58:05 -04:00
|
|
|
end
|
|
|
|
|
2008-08-12 14:30:33 -04:00
|
|
|
def count(table, interval = 1000)
|
|
|
|
table(table).count(interval)
|
|
|
|
end
|
|
|
|
|
2009-01-05 20:12:36 -05:00
|
|
|
def flush(tableNameOrRegionName)
|
|
|
|
admin().flush(tableNameOrRegionName)
|
|
|
|
end
|
|
|
|
|
|
|
|
def compact(tableNameOrRegionName)
|
|
|
|
admin().compact(tableNameOrRegionName)
|
|
|
|
end
|
|
|
|
|
|
|
|
def major_compact(tableNameOrRegionName)
|
|
|
|
admin().major_compact(tableNameOrRegionName)
|
|
|
|
end
|
|
|
|
|
|
|
|
def split(tableNameOrRegionName)
|
|
|
|
admin().split(tableNameOrRegionName)
|
|
|
|
end
|
|
|
|
|
2008-05-30 15:19:46 -04:00
|
|
|
# Output a banner message that tells users where to go for help
|
2008-06-13 18:42:11 -04:00
|
|
|
puts <<HERE
|
|
|
|
HBase Shell; enter 'help<RETURN>' for list of supported commands.
|
|
|
|
HERE
|
2008-06-12 02:00:35 -04:00
|
|
|
version
|
2008-06-01 01:19:08 -04:00
|
|
|
|
|
|
|
require "irb"
|
|
|
|
|
|
|
|
module IRB
|
2008-06-17 19:58:05 -04:00
|
|
|
# Subclass of IRB so can intercept methods
|
2008-06-12 02:00:35 -04:00
|
|
|
class HIRB < Irb
|
2008-06-18 18:24:34 -04:00
|
|
|
def initialize
|
|
|
|
# This is ugly. Our 'help' method above provokes the following message
|
|
|
|
# on irb construction: 'irb: warn: can't alias help from irb_help.'
|
|
|
|
# Below, we reset the output so its pointed at /dev/null during irb
|
|
|
|
# construction just so this message does not come out after we emit
|
|
|
|
# the banner. Other attempts at playing with the hash of methods
|
|
|
|
# down in IRB didn't seem to work. I think the worst thing that can
|
|
|
|
# happen is the shell exiting because of failed IRB construction with
|
|
|
|
# no error (though we're not blanking STDERR)
|
|
|
|
begin
|
|
|
|
f = File.open("/dev/null", "w")
|
|
|
|
$stdout = f
|
|
|
|
super
|
|
|
|
ensure
|
|
|
|
f.close()
|
|
|
|
$stdout = STDOUT
|
|
|
|
end
|
|
|
|
end
|
2008-06-17 19:58:05 -04:00
|
|
|
|
2008-06-12 02:00:35 -04:00
|
|
|
def output_value
|
|
|
|
# Suppress output if last_value is 'nil'
|
|
|
|
# Otherwise, when user types help, get ugly 'nil'
|
|
|
|
# after all output.
|
2008-12-22 12:50:02 -05:00
|
|
|
if @context.last_value != nil
|
2008-06-12 02:00:35 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-06-01 01:19:08 -04:00
|
|
|
def IRB.start(ap_path = nil)
|
|
|
|
$0 = File::basename(ap_path, ".rb") if ap_path
|
|
|
|
|
|
|
|
IRB.setup(ap_path)
|
2008-06-18 18:24:34 -04:00
|
|
|
@CONF[:IRB_NAME] = 'hbase'
|
|
|
|
@CONF[:AP_NAME] = 'hbase'
|
2008-06-01 01:19:08 -04:00
|
|
|
|
|
|
|
if @CONF[:SCRIPT]
|
2008-06-12 02:00:35 -04:00
|
|
|
hirb = HIRB.new(nil, @CONF[:SCRIPT])
|
2008-06-01 01:19:08 -04:00
|
|
|
else
|
2008-06-12 02:00:35 -04:00
|
|
|
hirb = HIRB.new
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
|
2008-06-12 02:00:35 -04:00
|
|
|
@CONF[:IRB_RC].call(hirb.context) if @CONF[:IRB_RC]
|
|
|
|
@CONF[:MAIN_CONTEXT] = hirb.context
|
2008-06-01 01:19:08 -04:00
|
|
|
|
|
|
|
catch(:IRB_EXIT) do
|
2008-06-12 02:00:35 -04:00
|
|
|
hirb.eval_input
|
2008-06-01 01:19:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
IRB.start
|