You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2015/01/22 22:12:57 UTC
[1/4] hbase git commit: HBASE-12904 Threading issues in
region_mover.rb
Repository: hbase
Updated Branches:
refs/heads/0.98 65f944282 -> 077f9ea4b
refs/heads/branch-1 0bec3a7bf -> 44fa36b42
refs/heads/branch-1.0 99b0f4446 -> cad517a9a
refs/heads/master 418ea9377 -> e370baf8a
HBASE-12904 Threading issues in region_mover.rb
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e370baf8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e370baf8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e370baf8
Branch: refs/heads/master
Commit: e370baf8a50adb0533bf6cae78f7b7986bdd2714
Parents: 418ea93
Author: Andrew Purtell <ap...@apache.org>
Authored: Thu Jan 22 13:11:31 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jan 22 13:11:31 2015 -0800
----------------------------------------------------------------------
bin/region_mover.rb | 81 ++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/e370baf8/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 7dfedd1..7a09854 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -43,41 +43,6 @@ import org.apache.hadoop.hbase.HRegionInfo
# Name of this script
NAME = "region_mover"
-# Get meta table reference
-def getMetaTable(config)
- # Keep meta reference in ruby global
- if not $META
- $META = HTable.new(config, HConstants::META_TABLE_NAME)
- end
- return $META
-end
-
-# Get table instance.
-# Maintains cache of table instances.
-def getTable(config, name)
- # Keep dictionary of tables in ruby global
- if not $TABLES
- $TABLES = {}
- end
- key = name.toString()
- if not $TABLES[key]
- $TABLES[key] = HTable.new(config, name)
- end
- return $TABLES[key]
-end
-
-def closeTables()
- if not $TABLES
- return
- end
-
- $LOG.info("Close all tables")
- $TABLES.each do |name, table|
- $TABLES.delete(name)
- table.close()
- end
-end
-
# Returns true if passed region is still on 'original' when we look at hbase:meta.
def isSameServer(admin, r, original)
server = getServerNameForRegion(admin, r)
@@ -111,17 +76,20 @@ def getServerNameForRegion(admin, r)
zkw.close()
end
end
- table = nil
- table = getMetaTable(admin.getConfiguration())
- g = Get.new(r.getRegionName())
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- result = table.get(g)
- return nil unless result
- server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- return nil unless server
- return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ table = HTable.new(admin.getConfiguration(), HConstants::META_TABLE_NAME)
+ begin
+ g = Get.new(r.getRegionName())
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ result = table.get(g)
+ return nil unless result
+ server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ return nil unless server
+ return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ ensure
+ table.close()
+ end
end
# Trys to scan a row from passed region
@@ -132,23 +100,22 @@ def isSuccessfulScan(admin, r)
scan.setCaching(1)
scan.setFilter(FirstKeyOnlyFilter.new())
begin
- table = getTable(admin.getConfiguration(), r.getTableName())
+ table = HTable.new(admin.getConfiguration(), r.getTableName())
scanner = table.getScanner(scan)
+ begin
+ results = scanner.next()
+ # We might scan into next region, this might be an empty table.
+ # But if no exception, presume scanning is working.
+ ensure
+ scanner.close()
+ end
rescue org.apache.hadoop.hbase.TableNotFoundException,
org.apache.hadoop.hbase.TableNotEnabledException => e
$LOG.warn("Region " + r.getEncodedName() + " belongs to recently " +
"deleted/disabled table. Skipping... " + e.message)
return
- end
- begin
- results = scanner.next()
- # We might scan into next region, this might be an empty table.
- # But if no exception, presume scanning is working.
ensure
- scanner.close()
- # Do not close the htable. It is cached in $TABLES and
- # may be reused in moving another region of same table.
- # table.close()
+ table.close() unless table.nil?
end
end
@@ -517,5 +484,3 @@ case ARGV[0]
puts optparse
exit 3
end
-
-closeTables()
[3/4] hbase git commit: HBASE-12904 Threading issues in
region_mover.rb
Posted by ap...@apache.org.
HBASE-12904 Threading issues in region_mover.rb
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cad517a9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cad517a9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cad517a9
Branch: refs/heads/branch-1.0
Commit: cad517a9a5a4e8fb51d3822b62209b928f272592
Parents: 99b0f44
Author: Andrew Purtell <ap...@apache.org>
Authored: Thu Jan 22 13:11:31 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jan 22 13:11:44 2015 -0800
----------------------------------------------------------------------
bin/region_mover.rb | 81 ++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/cad517a9/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 7dfedd1..7a09854 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -43,41 +43,6 @@ import org.apache.hadoop.hbase.HRegionInfo
# Name of this script
NAME = "region_mover"
-# Get meta table reference
-def getMetaTable(config)
- # Keep meta reference in ruby global
- if not $META
- $META = HTable.new(config, HConstants::META_TABLE_NAME)
- end
- return $META
-end
-
-# Get table instance.
-# Maintains cache of table instances.
-def getTable(config, name)
- # Keep dictionary of tables in ruby global
- if not $TABLES
- $TABLES = {}
- end
- key = name.toString()
- if not $TABLES[key]
- $TABLES[key] = HTable.new(config, name)
- end
- return $TABLES[key]
-end
-
-def closeTables()
- if not $TABLES
- return
- end
-
- $LOG.info("Close all tables")
- $TABLES.each do |name, table|
- $TABLES.delete(name)
- table.close()
- end
-end
-
# Returns true if passed region is still on 'original' when we look at hbase:meta.
def isSameServer(admin, r, original)
server = getServerNameForRegion(admin, r)
@@ -111,17 +76,20 @@ def getServerNameForRegion(admin, r)
zkw.close()
end
end
- table = nil
- table = getMetaTable(admin.getConfiguration())
- g = Get.new(r.getRegionName())
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- result = table.get(g)
- return nil unless result
- server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- return nil unless server
- return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ table = HTable.new(admin.getConfiguration(), HConstants::META_TABLE_NAME)
+ begin
+ g = Get.new(r.getRegionName())
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ result = table.get(g)
+ return nil unless result
+ server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ return nil unless server
+ return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ ensure
+ table.close()
+ end
end
# Trys to scan a row from passed region
@@ -132,23 +100,22 @@ def isSuccessfulScan(admin, r)
scan.setCaching(1)
scan.setFilter(FirstKeyOnlyFilter.new())
begin
- table = getTable(admin.getConfiguration(), r.getTableName())
+ table = HTable.new(admin.getConfiguration(), r.getTableName())
scanner = table.getScanner(scan)
+ begin
+ results = scanner.next()
+ # We might scan into next region, this might be an empty table.
+ # But if no exception, presume scanning is working.
+ ensure
+ scanner.close()
+ end
rescue org.apache.hadoop.hbase.TableNotFoundException,
org.apache.hadoop.hbase.TableNotEnabledException => e
$LOG.warn("Region " + r.getEncodedName() + " belongs to recently " +
"deleted/disabled table. Skipping... " + e.message)
return
- end
- begin
- results = scanner.next()
- # We might scan into next region, this might be an empty table.
- # But if no exception, presume scanning is working.
ensure
- scanner.close()
- # Do not close the htable. It is cached in $TABLES and
- # may be reused in moving another region of same table.
- # table.close()
+ table.close() unless table.nil?
end
end
@@ -517,5 +484,3 @@ case ARGV[0]
puts optparse
exit 3
end
-
-closeTables()
[4/4] hbase git commit: HBASE-12904 Threading issues in
region_mover.rb
Posted by ap...@apache.org.
HBASE-12904 Threading issues in region_mover.rb
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/077f9ea4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/077f9ea4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/077f9ea4
Branch: refs/heads/0.98
Commit: 077f9ea4b0e276960a7171c005faad56a06812c4
Parents: 65f9442
Author: Andrew Purtell <ap...@apache.org>
Authored: Thu Jan 22 13:11:31 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jan 22 13:12:12 2015 -0800
----------------------------------------------------------------------
bin/region_mover.rb | 81 ++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/077f9ea4/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 2ee4bcd..de25170 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -43,41 +43,6 @@ import org.apache.hadoop.hbase.HRegionInfo
# Name of this script
NAME = "region_mover"
-# Get meta table reference
-def getMetaTable(config)
- # Keep meta reference in ruby global
- if not $META
- $META = HTable.new(config, HConstants::META_TABLE_NAME)
- end
- return $META
-end
-
-# Get table instance.
-# Maintains cache of table instances.
-def getTable(config, name)
- # Keep dictionary of tables in ruby global
- if not $TABLES
- $TABLES = {}
- end
- key = name.toString()
- if not $TABLES[key]
- $TABLES[key] = HTable.new(config, name)
- end
- return $TABLES[key]
-end
-
-def closeTables()
- if not $TABLES
- return
- end
-
- $LOG.info("Close all tables")
- $TABLES.each do |name, table|
- $TABLES.delete(name)
- table.close()
- end
-end
-
# Returns true if passed region is still on 'original' when we look at .META.
def isSameServer(admin, r, original)
server = getServerNameForRegion(admin, r)
@@ -113,17 +78,20 @@ def getServerNameForRegion(admin, r)
zkw.close()
end
end
- table = nil
- table = getMetaTable(admin.getConfiguration())
- g = Get.new(r.getRegionName())
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- result = table.get(g)
- return nil unless result
- server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- return nil unless server
- return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ table = HTable.new(admin.getConfiguration(), HConstants::META_TABLE_NAME)
+ begin
+ g = Get.new(r.getRegionName())
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ result = table.get(g)
+ return nil unless result
+ server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ return nil unless server
+ return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ ensure
+ table.close()
+ end
end
# Trys to scan a row from passed region
@@ -134,23 +102,22 @@ def isSuccessfulScan(admin, r)
scan.setCaching(1)
scan.setFilter(FirstKeyOnlyFilter.new())
begin
- table = getTable(admin.getConfiguration(), r.getTableName())
+ table = HTable.new(admin.getConfiguration(), r.getTableName())
scanner = table.getScanner(scan)
+ begin
+ results = scanner.next()
+ # We might scan into next region, this might be an empty table.
+ # But if no exception, presume scanning is working.
+ ensure
+ scanner.close()
+ end
rescue org.apache.hadoop.hbase.TableNotFoundException,
org.apache.hadoop.hbase.TableNotEnabledException => e
$LOG.warn("Region " + r.getEncodedName() + " belongs to recently " +
"deleted/disabled table. Skipping... " + e.message)
return
- end
- begin
- results = scanner.next()
- # We might scan into next region, this might be an empty table.
- # But if no exception, presume scanning is working.
ensure
- scanner.close()
- # Do not close the htable. It is cached in $TABLES and
- # may be reused in moving another region of same table.
- # table.close()
+ table.close() unless table.nil?
end
end
@@ -519,5 +486,3 @@ case ARGV[0]
puts optparse
exit 3
end
-
-closeTables()
[2/4] hbase git commit: HBASE-12904 Threading issues in
region_mover.rb
Posted by ap...@apache.org.
HBASE-12904 Threading issues in region_mover.rb
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/44fa36b4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/44fa36b4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/44fa36b4
Branch: refs/heads/branch-1
Commit: 44fa36b425aadc7806512758b5bbe258b82e03ed
Parents: 0bec3a7
Author: Andrew Purtell <ap...@apache.org>
Authored: Thu Jan 22 13:11:31 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jan 22 13:11:40 2015 -0800
----------------------------------------------------------------------
bin/region_mover.rb | 81 ++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/44fa36b4/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 7dfedd1..7a09854 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -43,41 +43,6 @@ import org.apache.hadoop.hbase.HRegionInfo
# Name of this script
NAME = "region_mover"
-# Get meta table reference
-def getMetaTable(config)
- # Keep meta reference in ruby global
- if not $META
- $META = HTable.new(config, HConstants::META_TABLE_NAME)
- end
- return $META
-end
-
-# Get table instance.
-# Maintains cache of table instances.
-def getTable(config, name)
- # Keep dictionary of tables in ruby global
- if not $TABLES
- $TABLES = {}
- end
- key = name.toString()
- if not $TABLES[key]
- $TABLES[key] = HTable.new(config, name)
- end
- return $TABLES[key]
-end
-
-def closeTables()
- if not $TABLES
- return
- end
-
- $LOG.info("Close all tables")
- $TABLES.each do |name, table|
- $TABLES.delete(name)
- table.close()
- end
-end
-
# Returns true if passed region is still on 'original' when we look at hbase:meta.
def isSameServer(admin, r, original)
server = getServerNameForRegion(admin, r)
@@ -111,17 +76,20 @@ def getServerNameForRegion(admin, r)
zkw.close()
end
end
- table = nil
- table = getMetaTable(admin.getConfiguration())
- g = Get.new(r.getRegionName())
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- result = table.get(g)
- return nil unless result
- server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
- startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
- return nil unless server
- return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ table = HTable.new(admin.getConfiguration(), HConstants::META_TABLE_NAME)
+ begin
+ g = Get.new(r.getRegionName())
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ result = table.get(g)
+ return nil unless result
+ server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
+ startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
+ return nil unless server
+ return java.lang.String.new(Bytes.toString(server)).replaceFirst(":", ",") + "," + Bytes.toLong(startcode).to_s
+ ensure
+ table.close()
+ end
end
# Trys to scan a row from passed region
@@ -132,23 +100,22 @@ def isSuccessfulScan(admin, r)
scan.setCaching(1)
scan.setFilter(FirstKeyOnlyFilter.new())
begin
- table = getTable(admin.getConfiguration(), r.getTableName())
+ table = HTable.new(admin.getConfiguration(), r.getTableName())
scanner = table.getScanner(scan)
+ begin
+ results = scanner.next()
+ # We might scan into next region, this might be an empty table.
+ # But if no exception, presume scanning is working.
+ ensure
+ scanner.close()
+ end
rescue org.apache.hadoop.hbase.TableNotFoundException,
org.apache.hadoop.hbase.TableNotEnabledException => e
$LOG.warn("Region " + r.getEncodedName() + " belongs to recently " +
"deleted/disabled table. Skipping... " + e.message)
return
- end
- begin
- results = scanner.next()
- # We might scan into next region, this might be an empty table.
- # But if no exception, presume scanning is working.
ensure
- scanner.close()
- # Do not close the htable. It is cached in $TABLES and
- # may be reused in moving another region of same table.
- # table.close()
+ table.close() unless table.nil?
end
end
@@ -517,5 +484,3 @@ case ARGV[0]
puts optparse
exit 3
end
-
-closeTables()