diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
index ebdd335..2dfa9c3 100644
--- hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
+++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/replication/ReplicationAdmin.java
@@ -30,10 +30,16 @@ import org.apache.hadoop.hbase.replication.ReplicationPeers;
import org.apache.hadoop.hbase.replication.ReplicationQueuesClient;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.zookeeper.KeeperException;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.HColumnDescriptor;
import java.io.Closeable;
import java.io.IOException;
import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.lang.Integer;
/**
*
@@ -166,4 +172,53 @@ public class ReplicationAdmin implements Closeable {
this.connection.close();
}
}
+
+
+ /**
+ * Find all column families that are replicated from this cluster
+ * @param none
+ * @return the full list of the replicated column families of this cluster as: table name, column
+ * tableName, family name, replicationType
+ *
+ * Currently replicationType is Global. In the future, more replication
+ * type may be extended here. For example
+ * 1) the replication may only apply to selected peers instead of all peers
+ * 2) the replicationType may indicate the host Cluster servers as Slave
+ * for the table:columnFam.
+ */
+
+ public List> listReplicated() throws IOException {
+
+ final String TName = "tableName";
+ final String CFName = "columnFamlyName";
+
+ // only Global for now, can add other type
+ // such as, 1) no global replication, or 2) the table is replicated to this cluster, etc.
+ final String replicationType = "replicationType";
+ final String replicationGlobal = Integer.toString(HConstants.REPLICATION_SCOPE_GLOBAL);
+
+ List> replicationColFams = new ArrayList>();
+ HTableDescriptor[] tables;
+
+ tables = this.connection.listTables();
+
+ for (HTableDescriptor table : tables) {
+ HColumnDescriptor[] columns = table.getColumnFamilies();
+ String tableName = table.getNameAsString();
+ for (HColumnDescriptor column : columns) {
+ HashMap replicationEntry;
+
+ if (column.getScope() != HConstants.REPLICATION_SCOPE_LOCAL) {
+ // At this moment, the columfam is replicated to all peers
+ replicationEntry = new HashMap();
+ replicationEntry.put(TName, tableName);
+ replicationEntry.put(CFName, column.getNameAsString());
+ replicationEntry.put(replicationType, replicationGlobal);
+ replicationColFams.add(replicationEntry);
+ }
+ }
+ }
+
+ return replicationColFams;
+ }
}
diff --git hbase-server/src/main/ruby/hbase/replication_admin.rb hbase-server/src/main/ruby/hbase/replication_admin.rb
index 27d141a..c89488d 100644
--- hbase-server/src/main/ruby/hbase/replication_admin.rb
+++ hbase-server/src/main/ruby/hbase/replication_admin.rb
@@ -42,6 +42,13 @@ module Hbase
@replication_admin.removePeer(id)
end
+
+ #---------------------------------------------------------------------------------------------
+ # Show replcated tables/column families, and their ReplicationType
+ def list_replicated_tables
+ @replication_admin.listReplicated()
+ end
+
#----------------------------------------------------------------------------------------------
# List all peer clusters
def list_peers
diff --git hbase-server/src/main/ruby/shell.rb hbase-server/src/main/ruby/shell.rb
index b1d5cc0..464b20e 100644
--- hbase-server/src/main/ruby/shell.rb
+++ hbase-server/src/main/ruby/shell.rb
@@ -304,6 +304,7 @@ Shell.load_command_group(
list_peers
enable_peer
disable_peer
+ list_replicated_tables
]
)
diff --git hbase-server/src/main/ruby/shell/commands/list_replicated_tables.rb hbase-server/src/main/ruby/shell/commands/list_replicated_tables.rb
new file mode 100644
index 0000000..a777b5f
--- /dev/null
+++ hbase-server/src/main/ruby/shell/commands/list_replicated_tables.rb
@@ -0,0 +1,52 @@
+#
+# Copyright The Apache Software Foundation
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Shell
+ module Commands
+ class ListReplicatedTables< Command
+ def help
+ return <<-EOF
+List all the tables and column families replicated from this cluster
+
+ hbase> list_replicated_tables
+ hbase> list_replicated_tables 'abc.*'
+EOF
+ end
+
+ def command(regex = ".*")
+ now = Time.now
+
+ formatter.header([ "TABLE:COLUMNFAMILY", "ReplicationType" ], [ 32 ])
+ list = replication_admin.list_replicated_tables
+ regex = /#{regex}/ unless regex.is_a?(Regexp)
+ list = list.select {|s| regex.match(s.get("tableName"))}
+ list.each do |e|
+ if e.get("replicationType") == "1"
+ replicateType = "GLOBAL"
+ else
+ replicateType = "unknown"
+ end
+ formatter.row([e.get("tableName") + ":" + e.get("columnFamlyName"), replicateType], true, [32])
+ end
+ formatter.footer(now)
+ end
+ end
+ end
+end