diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon index e7fb621e338..404aabd40ac 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon @@ -81,7 +81,6 @@ org.apache.hadoop.hbase.HBaseConfiguration;
  • Local logs
  • Log Level
  • Debug dump
  • -
  • Metrics Dump
  • <%if HBaseConfiguration.isShowConfInServlet()%>
  • HBase Configuration
  • diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon index ee66fdd9231..540ce06831b 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon @@ -77,7 +77,6 @@ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
  • Local logs
  • Log Level
  • Debug dump
  • -
  • Metrics Dump
  • <%if HBaseConfiguration.isShowConfInServlet()%>
  • HBase Configuration
  • diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index 8d06aa3cff9..d227ff22d6e 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -97,7 +97,6 @@
  • Local logs
  • Log Level
  • Debug dump
  • -
  • Metrics Dump
  • diff --git a/hbase-server/src/main/resources/hbase-webapps/master/tablesDetailed.jsp b/hbase-server/src/main/resources/hbase-webapps/master/tablesDetailed.jsp index 6ddd4213cf5..d720995ca0b 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/tablesDetailed.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/tablesDetailed.jsp @@ -63,7 +63,6 @@
  • Local logs
  • Log Level
  • Debug dump
  • -
  • Metrics Dump
  • diff --git a/hbase-server/src/main/resources/hbase-webapps/master/zk.jsp b/hbase-server/src/main/resources/hbase-webapps/master/zk.jsp index 77d5f7bc4b7..2c545930c2f 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/zk.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/zk.jsp @@ -68,7 +68,6 @@
  • Local logs
  • Log Level
  • Debug dump
  • -
  • Metrics Dump
  • diff --git a/hbase-server/src/main/ruby/hbase/admin.rb b/hbase-server/src/main/ruby/hbase/admin.rb index 41c21fb1df5..9f869321c60 100644 --- a/hbase-server/src/main/ruby/hbase/admin.rb +++ b/hbase-server/src/main/ruby/hbase/admin.rb @@ -26,13 +26,14 @@ module Hbase class Admin include HBaseConstants - def initialize(configuration) + def initialize(configuration, formatter) @admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration) connection = @admin.getConnection() @conf = configuration @zk_wrapper = connection.getZooKeeperWatcher() zk = @zk_wrapper.getRecoverableZooKeeper().getZooKeeper() @zk_main = org.apache.zookeeper.ZooKeeperMain.new(zk) + @formatter = formatter end #---------------------------------------------------------------------------------------------- diff --git a/hbase-server/src/main/ruby/hbase/hbase.rb b/hbase-server/src/main/ruby/hbase/hbase.rb index 556b1b4e582..64482c5e0d8 100644 --- a/hbase-server/src/main/ruby/hbase/hbase.rb +++ b/hbase-server/src/main/ruby/hbase/hbase.rb @@ -39,8 +39,8 @@ module Hbase end end - def admin - ::Hbase::Admin.new(configuration) + def admin(formatter) + ::Hbase::Admin.new(configuration, formatter) end # Create new one each time diff --git a/hbase-server/src/main/ruby/hbase/table.rb b/hbase-server/src/main/ruby/hbase/table.rb index fb53ecedfe3..b9ecf87c1b6 100644 --- a/hbase-server/src/main/ruby/hbase/table.rb +++ b/hbase-server/src/main/ruby/hbase/table.rb @@ -129,8 +129,6 @@ EOF p.add(family, qualifier, value.to_s.to_java_bytes) end @table.put(p) - #return number of rows added/updated. - return p.size() end #---------------------------------------------------------------------------------------------- @@ -148,8 +146,6 @@ EOF d.deleteColumns(family, qualifier, timestamp) end @table.delete(d) - #return number of rows deleted. - return d.size() end #---------------------------------------------------------------------------------------------- diff --git a/hbase-server/src/main/ruby/shell.rb b/hbase-server/src/main/ruby/shell.rb index 6ab25609692..0a1d7c8072f 100644 --- a/hbase-server/src/main/ruby/shell.rb +++ b/hbase-server/src/main/ruby/shell.rb @@ -19,9 +19,7 @@ # Shell commands module module Shell - require 'shell/formatter' @@commands = {} - @@formatters={} def self.commands @@commands end @@ -31,17 +29,7 @@ module Shell @@command_groups end - def self.getFormatter (type = :RowFormatter) - type ||= :RowFormatter - format = @@formatters[type] - unless format - @@formatters[type] = eval("::Shell::Formatter::#{type}").new - return getFormatter type - end - return format - end - - def self.load_command(name, group,formatter) + def self.load_command(name, group) return if commands[name] # Register command in the group @@ -52,7 +40,7 @@ module Shell begin require "shell/commands/#{name}" klass_name = name.to_s.gsub(/(?:^|_)(.)/) { $1.upcase } # camelize - commands[name] = {:command => eval("Commands::#{klass_name}"), :formatter => formatter} + commands[name] = eval("Commands::#{klass_name}") rescue => e raise "Can't load hbase shell command: #{name}. Error: #{e}\n#{e.backtrace.join("\n")}" end @@ -68,11 +56,8 @@ module Shell :comment => opts[:comment] } - formatterType = opts[:formatterType] - formatter = getFormatter formatterType - opts[:commands].each do |command| - load_command(command, group, formatter) + load_command(command, group) end end @@ -84,12 +69,13 @@ module Shell @debug = false attr_accessor :debug - def initialize(hbase) + def initialize(hbase, formatter) self.hbase = hbase + self.formatter = formatter end def hbase_admin - @hbase_admin ||= hbase.admin + @hbase_admin ||= hbase.admin(formatter) end def hbase_table(name) @@ -121,8 +107,7 @@ module Shell end def command_instance(command) - commandObj = ::Shell.commands[command.to_s] - commandObj[:command].new(self, commandObj[:formatter]) + ::Shell.commands[command.to_s].new(self) end #call the method 'command' on the specified command @@ -265,8 +250,7 @@ Shell.load_command_group( alter_status alter_async get_table - ], - :formatterType => 'AdminFormatter' + ] ) Shell.load_command_group( @@ -282,8 +266,7 @@ Shell.load_command_group( put scan truncate - ], - :formatterType => 'RowFormatter' + ] ) Shell.load_command_group( diff --git a/hbase-server/src/main/ruby/shell/commands.rb b/hbase-server/src/main/ruby/shell/commands.rb index 34d2d869afb..eb026070771 100644 --- a/hbase-server/src/main/ruby/shell/commands.rb +++ b/hbase-server/src/main/ruby/shell/commands.rb @@ -20,10 +20,9 @@ module Shell module Commands class Command - attr_reader :formatter - def initialize(shell, formatter) + + def initialize(shell) @shell = shell - @formatter = formatter end #wrap an execution of cmd to catch hbase exceptions @@ -61,18 +60,22 @@ module Shell #---------------------------------------------------------------------- + def formatter + @shell.formatter + end + def format_simple_command now = Time.now - ret = yield - @formatter.header - @formatter.footer(now, ret) + yield + formatter.header + formatter.footer(now) end def format_and_return_simple_command now = Time.now ret = yield - @formatter.header - @formatter.footer(now, ret) + formatter.header + formatter.footer(now) return ret end diff --git a/hbase-server/src/main/ruby/shell/formatter.rb b/hbase-server/src/main/ruby/shell/formatter.rb index 604e04b7937..36aaf76aea7 100644 --- a/hbase-server/src/main/ruby/shell/formatter.rb +++ b/hbase-server/src/main/ruby/shell/formatter.rb @@ -146,39 +146,25 @@ module Shell end end - def calculateRunTime(start_time = nil) - return unless start_time - return (Time.now - start_time) - end - end - - #RowFormatter formats the return response with number of rows altered. - #Use this for operations (command groups) for which row count makes sense, eg: delete, add etc. - #Formatter is now defined at command group level. - class RowFormatter < Base def footer(start_time = nil, row_count = nil) - timeSpent = calculateRunTime(start_time) - unless(row_count.is_a?(Integer)) - row_count = nil - end + return unless start_time row_count ||= @row_count # Only output elapsed time and row count if startTime passed - @out.puts("%d row(s) in %.4f seconds" % [row_count, timeSpent]) + @out.puts("%d row(s) in %.4f seconds" % [row_count, Time.now - start_time]) end end - - #AdminFormatter is used for all non row specific operations (command groups) such as version, status etc. - #Formatter is now defined at command group level. - class AdminFormatter < Base - def footer(start_time = nil, msg = "") - timeSpent = calculateRunTime(start_time) - if(msg.is_a?(Integer)) - msg = msg, " rows" - end - @out.puts("Succeeded in %.4f seconds.\n%s" % [timeSpent, msg]) - end + + + class Console < Base + end + + class XHTMLFormatter < Base + # http://www.germane-software.com/software/rexml/doc/classes/REXML/Document.html + # http://www.crummy.com/writing/RubyCookbook/test_results/75942.html + end + + class JSON < Base end - end end