hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-19619 Modify replication_admin.rb to use ReplicationPeerConfigBuilder
Date Wed, 27 Dec 2017 10:35:52 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 3317b8738 -> 41c2dd04d


HBASE-19619 Modify replication_admin.rb to use ReplicationPeerConfigBuilder


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/41c2dd04
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/41c2dd04
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/41c2dd04

Branch: refs/heads/master
Commit: 41c2dd04da21bb76208f04af104df2e2f444970d
Parents: 3317b87
Author: tedyu <yuzhihong@gmail.com>
Authored: Wed Dec 27 02:35:41 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Dec 27 02:35:41 2017 -0800

----------------------------------------------------------------------
 .../src/main/ruby/hbase/replication_admin.rb    | 51 ++++++++++++--------
 1 file changed, 30 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/41c2dd04/hbase-shell/src/main/ruby/hbase/replication_admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/replication_admin.rb b/hbase-shell/src/main/ruby/hbase/replication_admin.rb
index f80c547..b9d4a0c 100644
--- a/hbase-shell/src/main/ruby/hbase/replication_admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/replication_admin.rb
@@ -66,22 +66,22 @@ module Hbase
         peer_state = args.fetch(STATE, nil)
 
         # Create and populate a ReplicationPeerConfig
-        replication_peer_config = ReplicationPeerConfig.new
-        replication_peer_config.set_cluster_key(cluster_key)
+        builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig
+          .newBuilder()
+        builder.set_cluster_key(cluster_key)
 
         unless endpoint_classname.nil?
-          replication_peer_config.set_replication_endpoint_impl(endpoint_classname)
+          builder.set_replication_endpoint_impl(endpoint_classname)
         end
 
         unless config.nil?
-          replication_peer_config.get_configuration.put_all(config)
+          builder.putAllConfiguration(config)
         end
 
         unless data.nil?
           # Convert Strings to Bytes for peer_data
-          peer_data = replication_peer_config.get_peer_data
           data.each do |key, val|
-            peer_data.put(Bytes.to_bytes(key), Bytes.to_bytes(val))
+            builder.putPeerData(Bytes.to_bytes(key), Bytes.to_bytes(val))
           end
         end
 
@@ -90,8 +90,8 @@ module Hbase
           namespaces.each do |n|
             ns_set.add(n)
           end
-          replication_peer_config.setReplicateAllUserTables(false)
-          replication_peer_config.set_namespaces(ns_set)
+          builder.setReplicateAllUserTables(false)
+          builder.set_namespaces(ns_set)
         end
 
         unless table_cfs.nil?
@@ -100,15 +100,15 @@ module Hbase
           table_cfs.each do |key, val|
             map.put(org.apache.hadoop.hbase.TableName.valueOf(key), val)
           end
-          replication_peer_config.setReplicateAllUserTables(false)
-          replication_peer_config.set_table_cfs_map(map)
+          builder.setReplicateAllUserTables(false)
+          builder.set_table_cfs_map(map)
         end
 
         enabled = true
         unless peer_state.nil?
           enabled = false if peer_state == 'DISABLED'
         end
-        @admin.addReplicationPeer(id, replication_peer_config, enabled)
+        @admin.addReplicationPeer(id, builder.build, enabled)
       else
         raise(ArgumentError, 'args must be a Hash')
       end
@@ -220,13 +220,18 @@ module Hbase
       unless namespaces.nil?
         rpc = get_peer_config(id)
         unless rpc.nil?
-          ns_set = rpc.getNamespaces
-          ns_set = java.util.HashSet.new if ns_set.nil?
+          if rpc.getNamespaces.nil?
+            ns_set = java.util.HashSet.new
+          else
+            ns_set = java.util.HashSet.new(rpc.getNamespaces)
+          end
           namespaces.each do |n|
             ns_set.add(n)
           end
-          rpc.setNamespaces(ns_set)
-          @admin.updateReplicationPeerConfig(id, rpc)
+          builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig
+            .newBuilder(rpc)
+          builder.setNamespaces(ns_set)
+          @admin.updateReplicationPeerConfig(id, builder.build)
         end
       end
     end
@@ -238,12 +243,15 @@ module Hbase
         unless rpc.nil?
           ns_set = rpc.getNamespaces
           unless ns_set.nil?
+            ns_set = java.util.HashSet.new(ns_set)
             namespaces.each do |n|
               ns_set.remove(n)
             end
           end
-          rpc.setNamespaces(ns_set)
-          @admin.updateReplicationPeerConfig(id, rpc)
+          builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig
+            .newBuilder(rpc)
+          builder.setNamespaces(ns_set)
+          @admin.updateReplicationPeerConfig(id, builder.build)
         end
       end
     end
@@ -353,19 +361,20 @@ module Hbase
 
       # Create and populate a ReplicationPeerConfig
       replication_peer_config = get_peer_config(id)
+      builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig
+        .newBuilder(replication_peer_config)
       unless config.nil?
-        replication_peer_config.get_configuration.put_all(config)
+        builder.putAllConfiguration(config)
       end
 
       unless data.nil?
         # Convert Strings to Bytes for peer_data
-        peer_data = replication_peer_config.get_peer_data
         data.each do |key, val|
-          peer_data.put(Bytes.to_bytes(key), Bytes.to_bytes(val))
+          builder.putPeerData(Bytes.to_bytes(key), Bytes.to_bytes(val))
         end
       end
 
-      @admin.updateReplicationPeerConfig(id, replication_peer_config)
+      @admin.updateReplicationPeerConfig(id, builder.build)
     end
   end
 end


Mime
View raw message