HBASE-10358 Shell changes for setting consistency per request (yi liang)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/70c3a785
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/70c3a785
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/70c3a785
Branch: refs/heads/branch-1
Commit: 70c3a7854f148acb1a04c6d873884c6b2f703cb9
Parents: 22aa501
Author: Enis Soztutar <enis@apache.org>
Authored: Thu May 26 14:20:01 2016 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Thu May 26 17:04:18 2016 -0700
----------------------------------------------------------------------
hbase-shell/src/main/ruby/hbase/table.rb | 10 ++++++++--
hbase-shell/src/main/ruby/shell/commands/get.rb | 4 ++--
hbase-shell/src/main/ruby/shell/commands/scan.rb | 5 ++---
hbase-shell/src/main/ruby/shell/formatter.rb | 9 +++++++--
4 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/70c3a785/hbase-shell/src/main/ruby/hbase/table.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb
index 74868c2..40095c8 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -281,6 +281,7 @@ EOF
def _get_internal(row, *args)
get = org.apache.hadoop.hbase.client.Get.new(row.to_s.to_java_bytes)
maxlength = -1
+ count = 0
@converters.clear()
# Normalize args
@@ -369,6 +370,10 @@ EOF
result = @table.get(get)
return nil if result.isEmpty
+ # Get stale info from results
+ is_stale = result.isStale
+ count += 1
+
# Print out results. Result can be Cell or RowResult.
res = {}
result.list.each do |kv|
@@ -386,7 +391,7 @@ EOF
end
# If block given, we've yielded all the results, otherwise just return them
- return ((block_given?) ? nil : res)
+ return ((block_given?) ? [count, is_stale]: res)
end
#----------------------------------------------------------------------------------------------
@@ -505,6 +510,7 @@ EOF
while iter.hasNext
row = iter.next
key = org.apache.hadoop.hbase.util.Bytes::toStringBinary(row.getRow)
+ is_stale |= row.isStale
row.list.each do |kv|
family = String.from_java_bytes(kv.getFamily)
@@ -530,7 +536,7 @@ EOF
end
scanner.close()
- return ((block_given?) ? count : res)
+ return ((block_given?) ? [count, is_stale] : res)
end
# Apply OperationAttributes to puts/scans/gets
http://git-wip-us.apache.org/repos/asf/hbase/blob/70c3a785/hbase-shell/src/main/ruby/shell/commands/get.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/get.rb b/hbase-shell/src/main/ruby/shell/commands/get.rb
index 1ab13cb..b8bfd52 100644
--- a/hbase-shell/src/main/ruby/shell/commands/get.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/get.rb
@@ -84,11 +84,11 @@ EOF
now = Time.now
formatter.header(["COLUMN", "CELL"])
- table._get_internal(row, *args) do |column, value|
+ count, is_stale = table._get_internal(row, *args) do |column, value|
formatter.row([ column, value ])
end
- formatter.footer(now)
+ formatter.footer(now, count, is_stale)
end
end
end
http://git-wip-us.apache.org/repos/asf/hbase/blob/70c3a785/hbase-shell/src/main/ruby/shell/commands/scan.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/scan.rb b/hbase-shell/src/main/ruby/shell/commands/scan.rb
index 7278578..106eccf 100644
--- a/hbase-shell/src/main/ruby/shell/commands/scan.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/scan.rb
@@ -109,12 +109,11 @@ EOF
scan = table._hash_to_scan(args)
#actually do the scanning
- count = table._scan_internal(args, scan) do |row, cells|
+ count, is_stale = table._scan_internal(args, scan) do |row, cells|
formatter.row([ row, cells ])
end
- formatter.footer(now, count)
-
+ formatter.footer(now, count, is_stale)
# if scan metrics were enabled, print them after the results
if (scan != nil && scan.isScanMetricsEnabled())
formatter.scan_metrics(scan.getScanMetrics(), args["METRICS"])
http://git-wip-us.apache.org/repos/asf/hbase/blob/70c3a785/hbase-shell/src/main/ruby/shell/formatter.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/formatter.rb b/hbase-shell/src/main/ruby/shell/formatter.rb
index 47c9c8d..6e598fb 100644
--- a/hbase-shell/src/main/ruby/shell/formatter.rb
+++ b/hbase-shell/src/main/ruby/shell/formatter.rb
@@ -177,11 +177,16 @@ module Shell
end
end
- def footer(start_time = nil, row_count = nil)
+ def footer(start_time = nil, row_count = nil, is_stale = false)
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, Time.now - start_time])
+ @out.print("%d row(s) in %.4f seconds" % [row_count, Time.now - start_time])
+ if is_stale == true
+ @out.puts(" (possible stale results) ")
+ else
+ @out.puts("")
+ end
end
end
|