HBASE-13112 quota.rb, security.rb and visibility_labels.rb leak connection (Ashish Singhi)

This commit is contained in:
tedyu 2015-02-26 18:44:19 -08:00
parent 49b4f3737e
commit 458846ef7b
4 changed files with 23 additions and 17 deletions

View File

@ -57,15 +57,15 @@ module Hbase
end end
def security_admin(formatter) def security_admin(formatter)
::Hbase::SecurityAdmin.new(configuration, formatter) ::Hbase::SecurityAdmin.new(@connection.getAdmin, formatter)
end end
def visibility_labels_admin(formatter) def visibility_labels_admin(formatter)
::Hbase::VisibilityLabelsAdmin.new(configuration, formatter) ::Hbase::VisibilityLabelsAdmin.new(@connection.getAdmin, formatter)
end end
def quotas_admin(formatter) def quotas_admin(formatter)
::Hbase::QuotasAdmin.new(configuration, formatter) ::Hbase::QuotasAdmin.new(@connection.getAdmin, formatter)
end end
def shutdown def shutdown

View File

@ -34,13 +34,15 @@ end
module Hbase module Hbase
class QuotasAdmin class QuotasAdmin
def initialize(configuration, formatter) def initialize(admin, formatter)
@config = configuration @admin = admin
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(configuration)
@admin = @connection.getAdmin()
@formatter = formatter @formatter = formatter
end end
def close
@admin.close
end
def throttle(args) def throttle(args)
raise(ArgumentError, "Arguments should be a Hash") unless args.kind_of?(Hash) raise(ArgumentError, "Arguments should be a Hash") unless args.kind_of?(Hash)
type = args.fetch(THROTTLE_TYPE, REQUEST) type = args.fetch(THROTTLE_TYPE, REQUEST)

View File

@ -24,13 +24,16 @@ module Hbase
class SecurityAdmin class SecurityAdmin
include HBaseConstants include HBaseConstants
def initialize(configuration, formatter) def initialize(admin, formatter)
@config = configuration @admin = admin
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(@config) @config = @admin.getConfiguration()
@admin = @connection.getAdmin()
@formatter = formatter @formatter = formatter
end end
def close
@admin.close
end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
def grant(user, permissions, table_name=nil, family=nil, qualifier=nil) def grant(user, permissions, table_name=nil, family=nil, qualifier=nil)
security_available? security_available?

View File

@ -24,13 +24,14 @@ java_import org.apache.hadoop.hbase.util.Bytes
module Hbase module Hbase
class VisibilityLabelsAdmin class VisibilityLabelsAdmin
def initialize(configuration, formatter) def initialize(admin, formatter)
@config = configuration @admin = admin
@config = @admin.getConfiguration()
@formatter = formatter @formatter = formatter
end
# @connection = org.apache.hadoop.hbase.client.ConnectionFactory(configuration)
# @admin = @connection.getAdmin() def close
@admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration) @admin.close
end end
def add_labels(*args) def add_labels(*args)