http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2d27954a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ModifyColumnFamilyFuture.html
----------------------------------------------------------------------
diff --git
a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ModifyColumnFamilyFuture.html
b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ModifyColumnFamilyFuture.html
index f5bc73a..feb42ea 100644
---
a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ModifyColumnFamilyFuture.html
+++
b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ModifyColumnFamilyFuture.html
@@ -4044,345 +4044,330 @@
<span class="sourceLineNo">4036</span><a name="line.4036"></a>
<span class="sourceLineNo">4037</span> @Override<a name="line.4037"></a>
<span class="sourceLineNo">4038</span> public void
drainRegionServers(List<ServerName> servers) throws IOException {<a
name="line.4038"></a>
-<span class="sourceLineNo">4039</span> final
List<HBaseProtos.ServerName> pbServers = new
ArrayList<>(servers.size());<a name="line.4039"></a>
-<span class="sourceLineNo">4040</span> for (ServerName server : servers)
{<a name="line.4040"></a>
-<span class="sourceLineNo">4041</span> // Parse to ServerName to do
simple validation.<a name="line.4041"></a>
-<span class="sourceLineNo">4042</span>
ServerName.parseServerName(server.toString());<a name="line.4042"></a>
-<span class="sourceLineNo">4043</span>
pbServers.add(ProtobufUtil.toServerName(server));<a name="line.4043"></a>
-<span class="sourceLineNo">4044</span> }<a name="line.4044"></a>
-<span class="sourceLineNo">4045</span><a name="line.4045"></a>
-<span class="sourceLineNo">4046</span> executeCallable(new
MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a
name="line.4046"></a>
-<span class="sourceLineNo">4047</span> @Override<a name="line.4047"></a>
-<span class="sourceLineNo">4048</span> public Void rpcCall() throws
ServiceException {<a name="line.4048"></a>
-<span class="sourceLineNo">4049</span> DrainRegionServersRequest req
=<a name="line.4049"></a>
-<span class="sourceLineNo">4050</span>
DrainRegionServersRequest.newBuilder().addAllServerName(pbServers).build();<a
name="line.4050"></a>
-<span class="sourceLineNo">4051</span>
master.drainRegionServers(getRpcController(), req);<a name="line.4051"></a>
-<span class="sourceLineNo">4052</span> return null;<a
name="line.4052"></a>
-<span class="sourceLineNo">4053</span> }<a name="line.4053"></a>
-<span class="sourceLineNo">4054</span> });<a name="line.4054"></a>
-<span class="sourceLineNo">4055</span> }<a name="line.4055"></a>
-<span class="sourceLineNo">4056</span><a name="line.4056"></a>
-<span class="sourceLineNo">4057</span> @Override<a name="line.4057"></a>
-<span class="sourceLineNo">4058</span> public List<ServerName>
listDrainingRegionServers() throws IOException {<a name="line.4058"></a>
-<span class="sourceLineNo">4059</span> return executeCallable(new
MasterCallable<List<ServerName>>(getConnection(),<a
name="line.4059"></a>
-<span class="sourceLineNo">4060</span> getRpcControllerFactory())
{<a name="line.4060"></a>
-<span class="sourceLineNo">4061</span> @Override<a name="line.4061"></a>
-<span class="sourceLineNo">4062</span> public List<ServerName>
rpcCall() throws ServiceException {<a name="line.4062"></a>
-<span class="sourceLineNo">4063</span> ListDrainingRegionServersRequest
req = ListDrainingRegionServersRequest.newBuilder().build();<a
name="line.4063"></a>
-<span class="sourceLineNo">4064</span> List<ServerName> servers =
new ArrayList<>();<a name="line.4064"></a>
-<span class="sourceLineNo">4065</span> for (HBaseProtos.ServerName
server : master.listDrainingRegionServers(null, req)<a name="line.4065"></a>
-<span class="sourceLineNo">4066</span> .getServerNameList()) {<a
name="line.4066"></a>
-<span class="sourceLineNo">4067</span>
servers.add(ProtobufUtil.toServerName(server));<a name="line.4067"></a>
-<span class="sourceLineNo">4068</span> }<a name="line.4068"></a>
-<span class="sourceLineNo">4069</span> return servers;<a
name="line.4069"></a>
-<span class="sourceLineNo">4070</span> }<a name="line.4070"></a>
-<span class="sourceLineNo">4071</span> });<a name="line.4071"></a>
-<span class="sourceLineNo">4072</span> }<a name="line.4072"></a>
-<span class="sourceLineNo">4073</span><a name="line.4073"></a>
-<span class="sourceLineNo">4074</span> @Override<a name="line.4074"></a>
-<span class="sourceLineNo">4075</span> public void
removeDrainFromRegionServers(List<ServerName> servers) throws IOException
{<a name="line.4075"></a>
-<span class="sourceLineNo">4076</span> final
List<HBaseProtos.ServerName> pbServers = new
ArrayList<>(servers.size());<a name="line.4076"></a>
-<span class="sourceLineNo">4077</span> for (ServerName server : servers)
{<a name="line.4077"></a>
-<span class="sourceLineNo">4078</span>
pbServers.add(ProtobufUtil.toServerName(server));<a name="line.4078"></a>
-<span class="sourceLineNo">4079</span> }<a name="line.4079"></a>
-<span class="sourceLineNo">4080</span><a name="line.4080"></a>
-<span class="sourceLineNo">4081</span> executeCallable(new
MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a
name="line.4081"></a>
-<span class="sourceLineNo">4082</span> @Override<a name="line.4082"></a>
-<span class="sourceLineNo">4083</span> public Void rpcCall() throws
ServiceException {<a name="line.4083"></a>
-<span class="sourceLineNo">4084</span>
RemoveDrainFromRegionServersRequest req =
RemoveDrainFromRegionServersRequest.newBuilder()<a name="line.4084"></a>
-<span class="sourceLineNo">4085</span>
.addAllServerName(pbServers).build();<a name="line.4085"></a>
-<span class="sourceLineNo">4086</span>
master.removeDrainFromRegionServers(getRpcController(), req);<a
name="line.4086"></a>
-<span class="sourceLineNo">4087</span> return null;<a
name="line.4087"></a>
+<span class="sourceLineNo">4039</span> executeCallable(new
MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a
name="line.4039"></a>
+<span class="sourceLineNo">4040</span> @Override<a name="line.4040"></a>
+<span class="sourceLineNo">4041</span> public Void rpcCall() throws
ServiceException {<a name="line.4041"></a>
+<span class="sourceLineNo">4042</span>
master.drainRegionServers(getRpcController(),<a name="line.4042"></a>
+<span class="sourceLineNo">4043</span>
RequestConverter.buildDrainRegionServersRequest(servers));<a
name="line.4043"></a>
+<span class="sourceLineNo">4044</span> return null;<a
name="line.4044"></a>
+<span class="sourceLineNo">4045</span> }<a name="line.4045"></a>
+<span class="sourceLineNo">4046</span> });<a name="line.4046"></a>
+<span class="sourceLineNo">4047</span> }<a name="line.4047"></a>
+<span class="sourceLineNo">4048</span><a name="line.4048"></a>
+<span class="sourceLineNo">4049</span> @Override<a name="line.4049"></a>
+<span class="sourceLineNo">4050</span> public List<ServerName>
listDrainingRegionServers() throws IOException {<a name="line.4050"></a>
+<span class="sourceLineNo">4051</span> return executeCallable(new
MasterCallable<List<ServerName>>(getConnection(),<a
name="line.4051"></a>
+<span class="sourceLineNo">4052</span> getRpcControllerFactory())
{<a name="line.4052"></a>
+<span class="sourceLineNo">4053</span> @Override<a name="line.4053"></a>
+<span class="sourceLineNo">4054</span> public List<ServerName>
rpcCall() throws ServiceException {<a name="line.4054"></a>
+<span class="sourceLineNo">4055</span> ListDrainingRegionServersRequest
req = ListDrainingRegionServersRequest.newBuilder().build();<a
name="line.4055"></a>
+<span class="sourceLineNo">4056</span> List<ServerName> servers =
new ArrayList<>();<a name="line.4056"></a>
+<span class="sourceLineNo">4057</span> for (HBaseProtos.ServerName
server : master.listDrainingRegionServers(null, req)<a name="line.4057"></a>
+<span class="sourceLineNo">4058</span> .getServerNameList()) {<a
name="line.4058"></a>
+<span class="sourceLineNo">4059</span>
servers.add(ProtobufUtil.toServerName(server));<a name="line.4059"></a>
+<span class="sourceLineNo">4060</span> }<a name="line.4060"></a>
+<span class="sourceLineNo">4061</span> return servers;<a
name="line.4061"></a>
+<span class="sourceLineNo">4062</span> }<a name="line.4062"></a>
+<span class="sourceLineNo">4063</span> });<a name="line.4063"></a>
+<span class="sourceLineNo">4064</span> }<a name="line.4064"></a>
+<span class="sourceLineNo">4065</span><a name="line.4065"></a>
+<span class="sourceLineNo">4066</span> @Override<a name="line.4066"></a>
+<span class="sourceLineNo">4067</span> public void
removeDrainFromRegionServers(List<ServerName> servers) throws IOException
{<a name="line.4067"></a>
+<span class="sourceLineNo">4068</span> executeCallable(new
MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a
name="line.4068"></a>
+<span class="sourceLineNo">4069</span> @Override<a name="line.4069"></a>
+<span class="sourceLineNo">4070</span> public Void rpcCall() throws
ServiceException {<a name="line.4070"></a>
+<span class="sourceLineNo">4071</span>
master.removeDrainFromRegionServers(getRpcController(),
RequestConverter.buildRemoveDrainFromRegionServersRequest(servers));<a
name="line.4071"></a>
+<span class="sourceLineNo">4072</span> return null;<a
name="line.4072"></a>
+<span class="sourceLineNo">4073</span> }<a name="line.4073"></a>
+<span class="sourceLineNo">4074</span> });<a name="line.4074"></a>
+<span class="sourceLineNo">4075</span> }<a name="line.4075"></a>
+<span class="sourceLineNo">4076</span><a name="line.4076"></a>
+<span class="sourceLineNo">4077</span> @Override<a name="line.4077"></a>
+<span class="sourceLineNo">4078</span> public List<TableCFs>
listReplicatedTableCFs() throws IOException {<a name="line.4078"></a>
+<span class="sourceLineNo">4079</span> List<TableCFs>
replicatedTableCFs = new ArrayList<>();<a name="line.4079"></a>
+<span class="sourceLineNo">4080</span> HTableDescriptor[] tables =
listTables();<a name="line.4080"></a>
+<span class="sourceLineNo">4081</span> for (HTableDescriptor table :
tables) {<a name="line.4081"></a>
+<span class="sourceLineNo">4082</span> HColumnDescriptor[] columns =
table.getColumnFamilies();<a name="line.4082"></a>
+<span class="sourceLineNo">4083</span> Map<String, Integer> cfs =
new HashMap<>();<a name="line.4083"></a>
+<span class="sourceLineNo">4084</span> for (HColumnDescriptor column :
columns) {<a name="line.4084"></a>
+<span class="sourceLineNo">4085</span> if (column.getScope() !=
HConstants.REPLICATION_SCOPE_LOCAL) {<a name="line.4085"></a>
+<span class="sourceLineNo">4086</span>
cfs.put(column.getNameAsString(), column.getScope());<a name="line.4086"></a>
+<span class="sourceLineNo">4087</span> }<a name="line.4087"></a>
<span class="sourceLineNo">4088</span> }<a name="line.4088"></a>
-<span class="sourceLineNo">4089</span> });<a name="line.4089"></a>
-<span class="sourceLineNo">4090</span> }<a name="line.4090"></a>
-<span class="sourceLineNo">4091</span><a name="line.4091"></a>
-<span class="sourceLineNo">4092</span> @Override<a name="line.4092"></a>
-<span class="sourceLineNo">4093</span> public List<TableCFs>
listReplicatedTableCFs() throws IOException {<a name="line.4093"></a>
-<span class="sourceLineNo">4094</span> List<TableCFs>
replicatedTableCFs = new ArrayList<>();<a name="line.4094"></a>
-<span class="sourceLineNo">4095</span> HTableDescriptor[] tables =
listTables();<a name="line.4095"></a>
-<span class="sourceLineNo">4096</span> for (HTableDescriptor table :
tables) {<a name="line.4096"></a>
-<span class="sourceLineNo">4097</span> HColumnDescriptor[] columns =
table.getColumnFamilies();<a name="line.4097"></a>
-<span class="sourceLineNo">4098</span> Map<String, Integer> cfs =
new HashMap<>();<a name="line.4098"></a>
-<span class="sourceLineNo">4099</span> for (HColumnDescriptor column :
columns) {<a name="line.4099"></a>
-<span class="sourceLineNo">4100</span> if (column.getScope() !=
HConstants.REPLICATION_SCOPE_LOCAL) {<a name="line.4100"></a>
-<span class="sourceLineNo">4101</span>
cfs.put(column.getNameAsString(), column.getScope());<a name="line.4101"></a>
-<span class="sourceLineNo">4102</span> }<a name="line.4102"></a>
-<span class="sourceLineNo">4103</span> }<a name="line.4103"></a>
-<span class="sourceLineNo">4104</span> if (!cfs.isEmpty()) {<a
name="line.4104"></a>
-<span class="sourceLineNo">4105</span> replicatedTableCFs.add(new
TableCFs(table.getTableName(), cfs));<a name="line.4105"></a>
-<span class="sourceLineNo">4106</span> }<a name="line.4106"></a>
-<span class="sourceLineNo">4107</span> }<a name="line.4107"></a>
-<span class="sourceLineNo">4108</span> return replicatedTableCFs;<a
name="line.4108"></a>
-<span class="sourceLineNo">4109</span> }<a name="line.4109"></a>
-<span class="sourceLineNo">4110</span><a name="line.4110"></a>
-<span class="sourceLineNo">4111</span> @Override<a name="line.4111"></a>
-<span class="sourceLineNo">4112</span> public void
enableTableReplication(final TableName tableName) throws IOException {<a
name="line.4112"></a>
-<span class="sourceLineNo">4113</span> if (tableName == null) {<a
name="line.4113"></a>
-<span class="sourceLineNo">4114</span> throw new
IllegalArgumentException("Table name cannot be null");<a name="line.4114"></a>
-<span class="sourceLineNo">4115</span> }<a name="line.4115"></a>
-<span class="sourceLineNo">4116</span> if (!tableExists(tableName)) {<a
name="line.4116"></a>
-<span class="sourceLineNo">4117</span> throw new
TableNotFoundException("Table '" + tableName.getNameAsString()<a
name="line.4117"></a>
-<span class="sourceLineNo">4118</span> + "' does not exists.");<a
name="line.4118"></a>
-<span class="sourceLineNo">4119</span> }<a name="line.4119"></a>
-<span class="sourceLineNo">4120</span> byte[][] splits =
getTableSplits(tableName);<a name="line.4120"></a>
-<span class="sourceLineNo">4121</span>
checkAndSyncTableDescToPeers(tableName, splits);<a name="line.4121"></a>
-<span class="sourceLineNo">4122</span> setTableRep(tableName, true);<a
name="line.4122"></a>
-<span class="sourceLineNo">4123</span> }<a name="line.4123"></a>
-<span class="sourceLineNo">4124</span><a name="line.4124"></a>
-<span class="sourceLineNo">4125</span> @Override<a name="line.4125"></a>
-<span class="sourceLineNo">4126</span> public void
disableTableReplication(final TableName tableName) throws IOException {<a
name="line.4126"></a>
-<span class="sourceLineNo">4127</span> if (tableName == null) {<a
name="line.4127"></a>
-<span class="sourceLineNo">4128</span> throw new
IllegalArgumentException("Table name is null");<a name="line.4128"></a>
-<span class="sourceLineNo">4129</span> }<a name="line.4129"></a>
-<span class="sourceLineNo">4130</span> if (!tableExists(tableName)) {<a
name="line.4130"></a>
-<span class="sourceLineNo">4131</span> throw new
TableNotFoundException("Table '" + tableName.getNamespaceAsString()<a
name="line.4131"></a>
-<span class="sourceLineNo">4132</span> + "' does not exists.");<a
name="line.4132"></a>
-<span class="sourceLineNo">4133</span> }<a name="line.4133"></a>
-<span class="sourceLineNo">4134</span> setTableRep(tableName, false);<a
name="line.4134"></a>
-<span class="sourceLineNo">4135</span> }<a name="line.4135"></a>
-<span class="sourceLineNo">4136</span><a name="line.4136"></a>
-<span class="sourceLineNo">4137</span> /**<a name="line.4137"></a>
-<span class="sourceLineNo">4138</span> * Copies the REPLICATION_SCOPE of
table descriptor passed as an argument. Before copy, the method<a
name="line.4138"></a>
-<span class="sourceLineNo">4139</span> * ensures that the name of table and
column-families should match.<a name="line.4139"></a>
-<span class="sourceLineNo">4140</span> * @param peerHtd descriptor on peer
cluster<a name="line.4140"></a>
-<span class="sourceLineNo">4141</span> * @param localHtd - The
HTableDescriptor of table from source cluster.<a name="line.4141"></a>
-<span class="sourceLineNo">4142</span> * @return true If the name of table
and column families match and REPLICATION_SCOPE copied<a name="line.4142"></a>
-<span class="sourceLineNo">4143</span> * successfully. false If
there is any mismatch in the names.<a name="line.4143"></a>
-<span class="sourceLineNo">4144</span> */<a name="line.4144"></a>
-<span class="sourceLineNo">4145</span> private boolean
copyReplicationScope(final HTableDescriptor peerHtd,<a name="line.4145"></a>
-<span class="sourceLineNo">4146</span> final HTableDescriptor localHtd)
{<a name="line.4146"></a>
-<span class="sourceLineNo">4147</span> // Copy the REPLICATION_SCOPE only
when table names and the names of<a name="line.4147"></a>
-<span class="sourceLineNo">4148</span> // Column-Families are same.<a
name="line.4148"></a>
-<span class="sourceLineNo">4149</span> int result =
peerHtd.getTableName().compareTo(localHtd.getTableName());<a
name="line.4149"></a>
-<span class="sourceLineNo">4150</span><a name="line.4150"></a>
-<span class="sourceLineNo">4151</span> if (result == 0) {<a
name="line.4151"></a>
-<span class="sourceLineNo">4152</span> Iterator<HColumnDescriptor>
remoteHCDIter = peerHtd.getFamilies().iterator();<a name="line.4152"></a>
-<span class="sourceLineNo">4153</span> Iterator<HColumnDescriptor>
localHCDIter = localHtd.getFamilies().iterator();<a name="line.4153"></a>
-<span class="sourceLineNo">4154</span><a name="line.4154"></a>
-<span class="sourceLineNo">4155</span> while (remoteHCDIter.hasNext()
&& localHCDIter.hasNext()) {<a name="line.4155"></a>
-<span class="sourceLineNo">4156</span> HColumnDescriptor remoteHCD =
remoteHCDIter.next();<a name="line.4156"></a>
-<span class="sourceLineNo">4157</span> HColumnDescriptor localHCD =
localHCDIter.next();<a name="line.4157"></a>
+<span class="sourceLineNo">4089</span> if (!cfs.isEmpty()) {<a
name="line.4089"></a>
+<span class="sourceLineNo">4090</span> replicatedTableCFs.add(new
TableCFs(table.getTableName(), cfs));<a name="line.4090"></a>
+<span class="sourceLineNo">4091</span> }<a name="line.4091"></a>
+<span class="sourceLineNo">4092</span> }<a name="line.4092"></a>
+<span class="sourceLineNo">4093</span> return replicatedTableCFs;<a
name="line.4093"></a>
+<span class="sourceLineNo">4094</span> }<a name="line.4094"></a>
+<span class="sourceLineNo">4095</span><a name="line.4095"></a>
+<span class="sourceLineNo">4096</span> @Override<a name="line.4096"></a>
+<span class="sourceLineNo">4097</span> public void
enableTableReplication(final TableName tableName) throws IOException {<a
name="line.4097"></a>
+<span class="sourceLineNo">4098</span> if (tableName == null) {<a
name="line.4098"></a>
+<span class="sourceLineNo">4099</span> throw new
IllegalArgumentException("Table name cannot be null");<a name="line.4099"></a>
+<span class="sourceLineNo">4100</span> }<a name="line.4100"></a>
+<span class="sourceLineNo">4101</span> if (!tableExists(tableName)) {<a
name="line.4101"></a>
+<span class="sourceLineNo">4102</span> throw new
TableNotFoundException("Table '" + tableName.getNameAsString()<a
name="line.4102"></a>
+<span class="sourceLineNo">4103</span> + "' does not exists.");<a
name="line.4103"></a>
+<span class="sourceLineNo">4104</span> }<a name="line.4104"></a>
+<span class="sourceLineNo">4105</span> byte[][] splits =
getTableSplits(tableName);<a name="line.4105"></a>
+<span class="sourceLineNo">4106</span>
checkAndSyncTableDescToPeers(tableName, splits);<a name="line.4106"></a>
+<span class="sourceLineNo">4107</span> setTableRep(tableName, true);<a
name="line.4107"></a>
+<span class="sourceLineNo">4108</span> }<a name="line.4108"></a>
+<span class="sourceLineNo">4109</span><a name="line.4109"></a>
+<span class="sourceLineNo">4110</span> @Override<a name="line.4110"></a>
+<span class="sourceLineNo">4111</span> public void
disableTableReplication(final TableName tableName) throws IOException {<a
name="line.4111"></a>
+<span class="sourceLineNo">4112</span> if (tableName == null) {<a
name="line.4112"></a>
+<span class="sourceLineNo">4113</span> throw new
IllegalArgumentException("Table name is null");<a name="line.4113"></a>
+<span class="sourceLineNo">4114</span> }<a name="line.4114"></a>
+<span class="sourceLineNo">4115</span> if (!tableExists(tableName)) {<a
name="line.4115"></a>
+<span class="sourceLineNo">4116</span> throw new
TableNotFoundException("Table '" + tableName.getNamespaceAsString()<a
name="line.4116"></a>
+<span class="sourceLineNo">4117</span> + "' does not exists.");<a
name="line.4117"></a>
+<span class="sourceLineNo">4118</span> }<a name="line.4118"></a>
+<span class="sourceLineNo">4119</span> setTableRep(tableName, false);<a
name="line.4119"></a>
+<span class="sourceLineNo">4120</span> }<a name="line.4120"></a>
+<span class="sourceLineNo">4121</span><a name="line.4121"></a>
+<span class="sourceLineNo">4122</span> /**<a name="line.4122"></a>
+<span class="sourceLineNo">4123</span> * Copies the REPLICATION_SCOPE of
table descriptor passed as an argument. Before copy, the method<a
name="line.4123"></a>
+<span class="sourceLineNo">4124</span> * ensures that the name of table and
column-families should match.<a name="line.4124"></a>
+<span class="sourceLineNo">4125</span> * @param peerHtd descriptor on peer
cluster<a name="line.4125"></a>
+<span class="sourceLineNo">4126</span> * @param localHtd - The
HTableDescriptor of table from source cluster.<a name="line.4126"></a>
+<span class="sourceLineNo">4127</span> * @return true If the name of table
and column families match and REPLICATION_SCOPE copied<a name="line.4127"></a>
+<span class="sourceLineNo">4128</span> * successfully. false If
there is any mismatch in the names.<a name="line.4128"></a>
+<span class="sourceLineNo">4129</span> */<a name="line.4129"></a>
+<span class="sourceLineNo">4130</span> private boolean
copyReplicationScope(final HTableDescriptor peerHtd,<a name="line.4130"></a>
+<span class="sourceLineNo">4131</span> final HTableDescriptor localHtd)
{<a name="line.4131"></a>
+<span class="sourceLineNo">4132</span> // Copy the REPLICATION_SCOPE only
when table names and the names of<a name="line.4132"></a>
+<span class="sourceLineNo">4133</span> // Column-Families are same.<a
name="line.4133"></a>
+<span class="sourceLineNo">4134</span> int result =
peerHtd.getTableName().compareTo(localHtd.getTableName());<a
name="line.4134"></a>
+<span class="sourceLineNo">4135</span><a name="line.4135"></a>
+<span class="sourceLineNo">4136</span> if (result == 0) {<a
name="line.4136"></a>
+<span class="sourceLineNo">4137</span> Iterator<HColumnDescriptor>
remoteHCDIter = peerHtd.getFamilies().iterator();<a name="line.4137"></a>
+<span class="sourceLineNo">4138</span> Iterator<HColumnDescriptor>
localHCDIter = localHtd.getFamilies().iterator();<a name="line.4138"></a>
+<span class="sourceLineNo">4139</span><a name="line.4139"></a>
+<span class="sourceLineNo">4140</span> while (remoteHCDIter.hasNext()
&& localHCDIter.hasNext()) {<a name="line.4140"></a>
+<span class="sourceLineNo">4141</span> HColumnDescriptor remoteHCD =
remoteHCDIter.next();<a name="line.4141"></a>
+<span class="sourceLineNo">4142</span> HColumnDescriptor localHCD =
localHCDIter.next();<a name="line.4142"></a>
+<span class="sourceLineNo">4143</span><a name="line.4143"></a>
+<span class="sourceLineNo">4144</span> String remoteHCDName =
remoteHCD.getNameAsString();<a name="line.4144"></a>
+<span class="sourceLineNo">4145</span> String localHCDName =
localHCD.getNameAsString();<a name="line.4145"></a>
+<span class="sourceLineNo">4146</span><a name="line.4146"></a>
+<span class="sourceLineNo">4147</span> if
(remoteHCDName.equals(localHCDName)) {<a name="line.4147"></a>
+<span class="sourceLineNo">4148</span>
remoteHCD.setScope(localHCD.getScope());<a name="line.4148"></a>
+<span class="sourceLineNo">4149</span> } else {<a name="line.4149"></a>
+<span class="sourceLineNo">4150</span> result = -1;<a
name="line.4150"></a>
+<span class="sourceLineNo">4151</span> break;<a name="line.4151"></a>
+<span class="sourceLineNo">4152</span> }<a name="line.4152"></a>
+<span class="sourceLineNo">4153</span> }<a name="line.4153"></a>
+<span class="sourceLineNo">4154</span> if (remoteHCDIter.hasNext() ||
localHCDIter.hasNext()) {<a name="line.4154"></a>
+<span class="sourceLineNo">4155</span> return false;<a
name="line.4155"></a>
+<span class="sourceLineNo">4156</span> }<a name="line.4156"></a>
+<span class="sourceLineNo">4157</span> }<a name="line.4157"></a>
<span class="sourceLineNo">4158</span><a name="line.4158"></a>
-<span class="sourceLineNo">4159</span> String remoteHCDName =
remoteHCD.getNameAsString();<a name="line.4159"></a>
-<span class="sourceLineNo">4160</span> String localHCDName =
localHCD.getNameAsString();<a name="line.4160"></a>
+<span class="sourceLineNo">4159</span> return result == 0;<a
name="line.4159"></a>
+<span class="sourceLineNo">4160</span> }<a name="line.4160"></a>
<span class="sourceLineNo">4161</span><a name="line.4161"></a>
-<span class="sourceLineNo">4162</span> if
(remoteHCDName.equals(localHCDName)) {<a name="line.4162"></a>
-<span class="sourceLineNo">4163</span>
remoteHCD.setScope(localHCD.getScope());<a name="line.4163"></a>
-<span class="sourceLineNo">4164</span> } else {<a name="line.4164"></a>
-<span class="sourceLineNo">4165</span> result = -1;<a
name="line.4165"></a>
-<span class="sourceLineNo">4166</span> break;<a name="line.4166"></a>
-<span class="sourceLineNo">4167</span> }<a name="line.4167"></a>
-<span class="sourceLineNo">4168</span> }<a name="line.4168"></a>
-<span class="sourceLineNo">4169</span> if (remoteHCDIter.hasNext() ||
localHCDIter.hasNext()) {<a name="line.4169"></a>
-<span class="sourceLineNo">4170</span> return false;<a
name="line.4170"></a>
-<span class="sourceLineNo">4171</span> }<a name="line.4171"></a>
-<span class="sourceLineNo">4172</span> }<a name="line.4172"></a>
-<span class="sourceLineNo">4173</span><a name="line.4173"></a>
-<span class="sourceLineNo">4174</span> return result == 0;<a
name="line.4174"></a>
-<span class="sourceLineNo">4175</span> }<a name="line.4175"></a>
-<span class="sourceLineNo">4176</span><a name="line.4176"></a>
-<span class="sourceLineNo">4177</span> /**<a name="line.4177"></a>
-<span class="sourceLineNo">4178</span> * Compare the contents of the
descriptor with another one passed as a parameter for replication<a
name="line.4178"></a>
-<span class="sourceLineNo">4179</span> * purpose. The REPLICATION_SCOPE
field is ignored during comparison.<a name="line.4179"></a>
-<span class="sourceLineNo">4180</span> * @param peerHtd descriptor on peer
cluster<a name="line.4180"></a>
-<span class="sourceLineNo">4181</span> * @param localHtd descriptor on
source cluster which needs to be replicated.<a name="line.4181"></a>
-<span class="sourceLineNo">4182</span> * @return true if the contents of the
two descriptors match (ignoring just REPLICATION_SCOPE).<a name="line.4182"></a>
-<span class="sourceLineNo">4183</span> * @see
java.lang.Object#equals(java.lang.Object)<a name="line.4183"></a>
-<span class="sourceLineNo">4184</span> */<a name="line.4184"></a>
-<span class="sourceLineNo">4185</span> private boolean
compareForReplication(HTableDescriptor peerHtd, HTableDescriptor localHtd) {<a
name="line.4185"></a>
-<span class="sourceLineNo">4186</span> if (peerHtd == localHtd) {<a
name="line.4186"></a>
-<span class="sourceLineNo">4187</span> return true;<a
name="line.4187"></a>
+<span class="sourceLineNo">4162</span> /**<a name="line.4162"></a>
+<span class="sourceLineNo">4163</span> * Compare the contents of the
descriptor with another one passed as a parameter for replication<a
name="line.4163"></a>
+<span class="sourceLineNo">4164</span> * purpose. The REPLICATION_SCOPE
field is ignored during comparison.<a name="line.4164"></a>
+<span class="sourceLineNo">4165</span> * @param peerHtd descriptor on peer
cluster<a name="line.4165"></a>
+<span class="sourceLineNo">4166</span> * @param localHtd descriptor on
source cluster which needs to be replicated.<a name="line.4166"></a>
+<span class="sourceLineNo">4167</span> * @return true if the contents of the
two descriptors match (ignoring just REPLICATION_SCOPE).<a name="line.4167"></a>
+<span class="sourceLineNo">4168</span> * @see
java.lang.Object#equals(java.lang.Object)<a name="line.4168"></a>
+<span class="sourceLineNo">4169</span> */<a name="line.4169"></a>
+<span class="sourceLineNo">4170</span> private boolean
compareForReplication(HTableDescriptor peerHtd, HTableDescriptor localHtd) {<a
name="line.4170"></a>
+<span class="sourceLineNo">4171</span> if (peerHtd == localHtd) {<a
name="line.4171"></a>
+<span class="sourceLineNo">4172</span> return true;<a
name="line.4172"></a>
+<span class="sourceLineNo">4173</span> }<a name="line.4173"></a>
+<span class="sourceLineNo">4174</span> if (peerHtd == null) {<a
name="line.4174"></a>
+<span class="sourceLineNo">4175</span> return false;<a
name="line.4175"></a>
+<span class="sourceLineNo">4176</span> }<a name="line.4176"></a>
+<span class="sourceLineNo">4177</span> boolean result = false;<a
name="line.4177"></a>
+<span class="sourceLineNo">4178</span><a name="line.4178"></a>
+<span class="sourceLineNo">4179</span> // Create a copy of peer HTD as we
need to change its replication<a name="line.4179"></a>
+<span class="sourceLineNo">4180</span> // scope to match with the local
HTD.<a name="line.4180"></a>
+<span class="sourceLineNo">4181</span> HTableDescriptor peerHtdCopy = new
HTableDescriptor(peerHtd);<a name="line.4181"></a>
+<span class="sourceLineNo">4182</span><a name="line.4182"></a>
+<span class="sourceLineNo">4183</span> result =
copyReplicationScope(peerHtdCopy, localHtd);<a name="line.4183"></a>
+<span class="sourceLineNo">4184</span><a name="line.4184"></a>
+<span class="sourceLineNo">4185</span> // If copy was successful, compare
the two tables now.<a name="line.4185"></a>
+<span class="sourceLineNo">4186</span> if (result) {<a name="line.4186"></a>
+<span class="sourceLineNo">4187</span> result =
(peerHtdCopy.compareTo(localHtd) == 0);<a name="line.4187"></a>
<span class="sourceLineNo">4188</span> }<a name="line.4188"></a>
-<span class="sourceLineNo">4189</span> if (peerHtd == null) {<a
name="line.4189"></a>
-<span class="sourceLineNo">4190</span> return false;<a
name="line.4190"></a>
-<span class="sourceLineNo">4191</span> }<a name="line.4191"></a>
-<span class="sourceLineNo">4192</span> boolean result = false;<a
name="line.4192"></a>
-<span class="sourceLineNo">4193</span><a name="line.4193"></a>
-<span class="sourceLineNo">4194</span> // Create a copy of peer HTD as we
need to change its replication<a name="line.4194"></a>
-<span class="sourceLineNo">4195</span> // scope to match with the local
HTD.<a name="line.4195"></a>
-<span class="sourceLineNo">4196</span> HTableDescriptor peerHtdCopy = new
HTableDescriptor(peerHtd);<a name="line.4196"></a>
-<span class="sourceLineNo">4197</span><a name="line.4197"></a>
-<span class="sourceLineNo">4198</span> result =
copyReplicationScope(peerHtdCopy, localHtd);<a name="line.4198"></a>
-<span class="sourceLineNo">4199</span><a name="line.4199"></a>
-<span class="sourceLineNo">4200</span> // If copy was successful, compare
the two tables now.<a name="line.4200"></a>
-<span class="sourceLineNo">4201</span> if (result) {<a name="line.4201"></a>
-<span class="sourceLineNo">4202</span> result =
(peerHtdCopy.compareTo(localHtd) == 0);<a name="line.4202"></a>
-<span class="sourceLineNo">4203</span> }<a name="line.4203"></a>
-<span class="sourceLineNo">4204</span><a name="line.4204"></a>
-<span class="sourceLineNo">4205</span> return result;<a
name="line.4205"></a>
-<span class="sourceLineNo">4206</span> }<a name="line.4206"></a>
-<span class="sourceLineNo">4207</span><a name="line.4207"></a>
-<span class="sourceLineNo">4208</span> /**<a name="line.4208"></a>
-<span class="sourceLineNo">4209</span> * Connect to peer and check the table
descriptor on peer:<a name="line.4209"></a>
-<span class="sourceLineNo">4210</span> * <ol><a name="line.4210"></a>
-<span class="sourceLineNo">4211</span> * <li>Create the same table on
peer when not exist.</li><a name="line.4211"></a>
-<span class="sourceLineNo">4212</span> * <li>Throw an exception if the
table already has replication enabled on any of the column<a
name="line.4212"></a>
-<span class="sourceLineNo">4213</span> * families.</li><a
name="line.4213"></a>
-<span class="sourceLineNo">4214</span> * <li>Throw an exception if the
table exists on peer cluster but descriptors are not same.</li><a
name="line.4214"></a>
-<span class="sourceLineNo">4215</span> * </ol><a name="line.4215"></a>
-<span class="sourceLineNo">4216</span> * @param tableName name of the table
to sync to the peer<a name="line.4216"></a>
-<span class="sourceLineNo">4217</span> * @param splits table split keys<a
name="line.4217"></a>
-<span class="sourceLineNo">4218</span> * @throws IOException<a
name="line.4218"></a>
-<span class="sourceLineNo">4219</span> */<a name="line.4219"></a>
-<span class="sourceLineNo">4220</span> private void
checkAndSyncTableDescToPeers(final TableName tableName, final byte[][]
splits)<a name="line.4220"></a>
-<span class="sourceLineNo">4221</span> throws IOException {<a
name="line.4221"></a>
-<span class="sourceLineNo">4222</span>
List<ReplicationPeerDescription> peers = listReplicationPeers();<a
name="line.4222"></a>
-<span class="sourceLineNo">4223</span> if (peers == null || peers.size()
<= 0) {<a name="line.4223"></a>
-<span class="sourceLineNo">4224</span> throw new
IllegalArgumentException("Found no peer cluster for replication.");<a
name="line.4224"></a>
-<span class="sourceLineNo">4225</span> }<a name="line.4225"></a>
-<span class="sourceLineNo">4226</span><a name="line.4226"></a>
-<span class="sourceLineNo">4227</span> for (ReplicationPeerDescription
peerDesc : peers) {<a name="line.4227"></a>
-<span class="sourceLineNo">4228</span> if (needToReplicate(tableName,
peerDesc)) {<a name="line.4228"></a>
-<span class="sourceLineNo">4229</span> Configuration peerConf =
getPeerClusterConfiguration(peerDesc);<a name="line.4229"></a>
-<span class="sourceLineNo">4230</span> try (Connection conn =
ConnectionFactory.createConnection(peerConf);<a name="line.4230"></a>
-<span class="sourceLineNo">4231</span> Admin repHBaseAdmin =
conn.getAdmin()) {<a name="line.4231"></a>
-<span class="sourceLineNo">4232</span> HTableDescriptor localHtd =
getTableDescriptor(tableName);<a name="line.4232"></a>
-<span class="sourceLineNo">4233</span> HTableDescriptor peerHtd =
null;<a name="line.4233"></a>
-<span class="sourceLineNo">4234</span> if
(!repHBaseAdmin.tableExists(tableName)) {<a name="line.4234"></a>
-<span class="sourceLineNo">4235</span>
repHBaseAdmin.createTable(localHtd, splits);<a name="line.4235"></a>
-<span class="sourceLineNo">4236</span> } else {<a
name="line.4236"></a>
-<span class="sourceLineNo">4237</span> peerHtd =
repHBaseAdmin.getTableDescriptor(tableName);<a name="line.4237"></a>
-<span class="sourceLineNo">4238</span> if (peerHtd == null) {<a
name="line.4238"></a>
-<span class="sourceLineNo">4239</span> throw new
IllegalArgumentException("Failed to get table descriptor for table "<a
name="line.4239"></a>
-<span class="sourceLineNo">4240</span> +
tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId());<a
name="line.4240"></a>
-<span class="sourceLineNo">4241</span> }<a name="line.4241"></a>
-<span class="sourceLineNo">4242</span> if
(!compareForReplication(peerHtd, localHtd)) {<a name="line.4242"></a>
-<span class="sourceLineNo">4243</span> throw new
IllegalArgumentException("Table " + tableName.getNameAsString()<a
name="line.4243"></a>
-<span class="sourceLineNo">4244</span> + " exists in peer
cluster " + peerDesc.getPeerId()<a name="line.4244"></a>
-<span class="sourceLineNo">4245</span> + ", but the table
descriptors are not same when compared with source cluster."<a
name="line.4245"></a>
-<span class="sourceLineNo">4246</span> + " Thus can not
enable the table's replication switch.");<a name="line.4246"></a>
-<span class="sourceLineNo">4247</span> }<a name="line.4247"></a>
-<span class="sourceLineNo">4248</span> }<a name="line.4248"></a>
-<span class="sourceLineNo">4249</span> }<a name="line.4249"></a>
-<span class="sourceLineNo">4250</span> }<a name="line.4250"></a>
-<span class="sourceLineNo">4251</span> }<a name="line.4251"></a>
-<span class="sourceLineNo">4252</span> }<a name="line.4252"></a>
-<span class="sourceLineNo">4253</span><a name="line.4253"></a>
-<span class="sourceLineNo">4254</span> /**<a name="line.4254"></a>
-<span class="sourceLineNo">4255</span> * Decide whether the table need
replicate to the peer cluster according to the peer config<a
name="line.4255"></a>
-<span class="sourceLineNo">4256</span> * @param table name of the table<a
name="line.4256"></a>
-<span class="sourceLineNo">4257</span> * @param peer config for the peer<a
name="line.4257"></a>
-<span class="sourceLineNo">4258</span> * @return true if the table need
replicate to the peer cluster<a name="line.4258"></a>
-<span class="sourceLineNo">4259</span> */<a name="line.4259"></a>
-<span class="sourceLineNo">4260</span> private boolean
needToReplicate(TableName table, ReplicationPeerDescription peer) {<a
name="line.4260"></a>
-<span class="sourceLineNo">4261</span> ReplicationPeerConfig peerConfig =
peer.getPeerConfig();<a name="line.4261"></a>
-<span class="sourceLineNo">4262</span> Set<String> namespaces =
peerConfig.getNamespaces();<a name="line.4262"></a>
-<span class="sourceLineNo">4263</span> Map<TableName,
List<String>> tableCFsMap = peerConfig.getTableCFsMap();<a
name="line.4263"></a>
-<span class="sourceLineNo">4264</span> // If null means user has explicitly
not configured any namespaces and table CFs<a name="line.4264"></a>
-<span class="sourceLineNo">4265</span> // so all the tables data are
applicable for replication<a name="line.4265"></a>
-<span class="sourceLineNo">4266</span> if (namespaces == null &&
tableCFsMap == null) {<a name="line.4266"></a>
-<span class="sourceLineNo">4267</span> return true;<a
name="line.4267"></a>
-<span class="sourceLineNo">4268</span> }<a name="line.4268"></a>
-<span class="sourceLineNo">4269</span> if (namespaces != null &&
namespaces.contains(table.getNamespaceAsString())) {<a name="line.4269"></a>
-<span class="sourceLineNo">4270</span> return true;<a
name="line.4270"></a>
-<span class="sourceLineNo">4271</span> }<a name="line.4271"></a>
-<span class="sourceLineNo">4272</span> if (tableCFsMap != null &&
tableCFsMap.containsKey(table)) {<a name="line.4272"></a>
-<span class="sourceLineNo">4273</span> return true;<a
name="line.4273"></a>
-<span class="sourceLineNo">4274</span> }<a name="line.4274"></a>
-<span class="sourceLineNo">4275</span> LOG.debug("Table " +
table.getNameAsString()<a name="line.4275"></a>
-<span class="sourceLineNo">4276</span> + " doesn't need replicate to
peer cluster, peerId=" + peer.getPeerId() + ", clusterKey="<a
name="line.4276"></a>
-<span class="sourceLineNo">4277</span> + peerConfig.getClusterKey());<a
name="line.4277"></a>
-<span class="sourceLineNo">4278</span> return false;<a name="line.4278"></a>
-<span class="sourceLineNo">4279</span> }<a name="line.4279"></a>
-<span class="sourceLineNo">4280</span><a name="line.4280"></a>
-<span class="sourceLineNo">4281</span> /**<a name="line.4281"></a>
-<span class="sourceLineNo">4282</span> * Set the table's replication switch
if the table's replication switch is already not set.<a name="line.4282"></a>
-<span class="sourceLineNo">4283</span> * @param tableName name of the
table<a name="line.4283"></a>
-<span class="sourceLineNo">4284</span> * @param enableRep is replication
switch enable or disable<a name="line.4284"></a>
-<span class="sourceLineNo">4285</span> * @throws IOException if a remote or
network exception occurs<a name="line.4285"></a>
-<span class="sourceLineNo">4286</span> */<a name="line.4286"></a>
-<span class="sourceLineNo">4287</span> private void setTableRep(final
TableName tableName, boolean enableRep) throws IOException {<a
name="line.4287"></a>
-<span class="sourceLineNo">4288</span> HTableDescriptor htd = new
HTableDescriptor(getTableDescriptor(tableName));<a name="line.4288"></a>
-<span class="sourceLineNo">4289</span> ReplicationState
currentReplicationState = getTableReplicationState(htd);<a name="line.4289"></a>
-<span class="sourceLineNo">4290</span> if (enableRep &&
currentReplicationState != ReplicationState.ENABLED<a name="line.4290"></a>
-<span class="sourceLineNo">4291</span> || !enableRep &&
currentReplicationState != ReplicationState.DISABLED) {<a name="line.4291"></a>
-<span class="sourceLineNo">4292</span> for (HColumnDescriptor hcd :
htd.getFamilies()) {<a name="line.4292"></a>
-<span class="sourceLineNo">4293</span> hcd.setScope(enableRep ?
HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.4293"></a>
-<span class="sourceLineNo">4294</span> :
HConstants.REPLICATION_SCOPE_LOCAL);<a name="line.4294"></a>
-<span class="sourceLineNo">4295</span> }<a name="line.4295"></a>
-<span class="sourceLineNo">4296</span> modifyTable(tableName, htd);<a
name="line.4296"></a>
-<span class="sourceLineNo">4297</span> }<a name="line.4297"></a>
-<span class="sourceLineNo">4298</span> }<a name="line.4298"></a>
-<span class="sourceLineNo">4299</span><a name="line.4299"></a>
-<span class="sourceLineNo">4300</span> /**<a name="line.4300"></a>
-<span class="sourceLineNo">4301</span> * This enum indicates the current
state of the replication for a given table.<a name="line.4301"></a>
-<span class="sourceLineNo">4302</span> */<a name="line.4302"></a>
-<span class="sourceLineNo">4303</span> private enum ReplicationState {<a
name="line.4303"></a>
-<span class="sourceLineNo">4304</span> ENABLED, // all column families
enabled<a name="line.4304"></a>
-<span class="sourceLineNo">4305</span> MIXED, // some column families
enabled, some disabled<a name="line.4305"></a>
-<span class="sourceLineNo">4306</span> DISABLED // all column families
disabled<a name="line.4306"></a>
-<span class="sourceLineNo">4307</span> }<a name="line.4307"></a>
-<span class="sourceLineNo">4308</span><a name="line.4308"></a>
-<span class="sourceLineNo">4309</span> /**<a name="line.4309"></a>
-<span class="sourceLineNo">4310</span> * @param htd table descriptor details
for the table to check<a name="line.4310"></a>
-<span class="sourceLineNo">4311</span> * @return ReplicationState the
current state of the table.<a name="line.4311"></a>
-<span class="sourceLineNo">4312</span> */<a name="line.4312"></a>
-<span class="sourceLineNo">4313</span> private ReplicationState
getTableReplicationState(HTableDescriptor htd) {<a name="line.4313"></a>
-<span class="sourceLineNo">4314</span> boolean hasEnabled = false;<a
name="line.4314"></a>
-<span class="sourceLineNo">4315</span> boolean hasDisabled = false;<a
name="line.4315"></a>
-<span class="sourceLineNo">4316</span><a name="line.4316"></a>
-<span class="sourceLineNo">4317</span> for (HColumnDescriptor hcd :
htd.getFamilies()) {<a name="line.4317"></a>
-<span class="sourceLineNo">4318</span> if (hcd.getScope() !=
HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.4318"></a>
-<span class="sourceLineNo">4319</span> && hcd.getScope() !=
HConstants.REPLICATION_SCOPE_SERIAL) {<a name="line.4319"></a>
-<span class="sourceLineNo">4320</span> hasDisabled = true;<a
name="line.4320"></a>
-<span class="sourceLineNo">4321</span> } else {<a name="line.4321"></a>
-<span class="sourceLineNo">4322</span> hasEnabled = true;<a
name="line.4322"></a>
-<span class="sourceLineNo">4323</span> }<a name="line.4323"></a>
-<span class="sourceLineNo">4324</span> }<a name="line.4324"></a>
-<span class="sourceLineNo">4325</span><a name="line.4325"></a>
-<span class="sourceLineNo">4326</span> if (hasEnabled &&
hasDisabled) return ReplicationState.MIXED;<a name="line.4326"></a>
-<span class="sourceLineNo">4327</span> if (hasEnabled) return
ReplicationState.ENABLED;<a name="line.4327"></a>
-<span class="sourceLineNo">4328</span> return ReplicationState.DISABLED;<a
name="line.4328"></a>
-<span class="sourceLineNo">4329</span> }<a name="line.4329"></a>
-<span class="sourceLineNo">4330</span><a name="line.4330"></a>
-<span class="sourceLineNo">4331</span> /**<a name="line.4331"></a>
-<span class="sourceLineNo">4332</span> * Returns the configuration needed to
talk to the remote slave cluster.<a name="line.4332"></a>
-<span class="sourceLineNo">4333</span> * @param peer the description of
replication peer<a name="line.4333"></a>
-<span class="sourceLineNo">4334</span> * @return the configuration for the
peer cluster, null if it was unable to get the configuration<a
name="line.4334"></a>
-<span class="sourceLineNo">4335</span> * @throws IOException<a
name="line.4335"></a>
-<span class="sourceLineNo">4336</span> */<a name="line.4336"></a>
-<span class="sourceLineNo">4337</span> private Configuration
getPeerClusterConfiguration(ReplicationPeerDescription peer)<a
name="line.4337"></a>
-<span class="sourceLineNo">4338</span> throws IOException {<a
name="line.4338"></a>
-<span class="sourceLineNo">4339</span> ReplicationPeerConfig peerConfig =
peer.getPeerConfig();<a name="line.4339"></a>
-<span class="sourceLineNo">4340</span> Configuration otherConf;<a
name="line.4340"></a>
-<span class="sourceLineNo">4341</span> try {<a name="line.4341"></a>
-<span class="sourceLineNo">4342</span> otherConf =
HBaseConfiguration.createClusterConf(this.conf, peerConfig.getClusterKey());<a
name="line.4342"></a>
-<span class="sourceLineNo">4343</span> } catch (IOException e) {<a
name="line.4343"></a>
-<span class="sourceLineNo">4344</span> throw new IOException("Can't get
peer configuration for peerId=" + peer.getPeerId(), e);<a name="line.4344"></a>
-<span class="sourceLineNo">4345</span> }<a name="line.4345"></a>
-<span class="sourceLineNo">4346</span><a name="line.4346"></a>
-<span class="sourceLineNo">4347</span> if
(!peerConfig.getConfiguration().isEmpty()) {<a name="line.4347"></a>
-<span class="sourceLineNo">4348</span> CompoundConfiguration compound =
new CompoundConfiguration();<a name="line.4348"></a>
-<span class="sourceLineNo">4349</span> compound.add(otherConf);<a
name="line.4349"></a>
-<span class="sourceLineNo">4350</span>
compound.addStringMap(peerConfig.getConfiguration());<a name="line.4350"></a>
-<span class="sourceLineNo">4351</span> return compound;<a
name="line.4351"></a>
-<span class="sourceLineNo">4352</span> }<a name="line.4352"></a>
-<span class="sourceLineNo">4353</span><a name="line.4353"></a>
-<span class="sourceLineNo">4354</span> return otherConf;<a
name="line.4354"></a>
-<span class="sourceLineNo">4355</span> }<a name="line.4355"></a>
-<span class="sourceLineNo">4356</span><a name="line.4356"></a>
-<span class="sourceLineNo">4357</span> @Override<a name="line.4357"></a>
-<span class="sourceLineNo">4358</span> public void
clearCompactionQueues(final ServerName sn, final Set<String> queues)<a
name="line.4358"></a>
-<span class="sourceLineNo">4359</span> throws IOException,
InterruptedException {<a name="line.4359"></a>
-<span class="sourceLineNo">4360</span> if (queues == null || queues.size()
== 0) {<a name="line.4360"></a>
-<span class="sourceLineNo">4361</span> throw new
IllegalArgumentException("queues cannot be null or empty");<a
name="line.4361"></a>
-<span class="sourceLineNo">4362</span> }<a name="line.4362"></a>
-<span class="sourceLineNo">4363</span> final AdminService.BlockingInterface
admin = this.connection.getAdmin(sn);<a name="line.4363"></a>
-<span class="sourceLineNo">4364</span> Callable<Void> callable = new
Callable<Void>() {<a name="line.4364"></a>
-<span class="sourceLineNo">4365</span> @Override<a name="line.4365"></a>
-<span class="sourceLineNo">4366</span> public Void call() throws
Exception {<a name="line.4366"></a>
-<span class="sourceLineNo">4367</span> // TODO: There is no timeout on
this controller. Set one!<a name="line.4367"></a>
-<span class="sourceLineNo">4368</span> HBaseRpcController controller =
rpcControllerFactory.newController();<a name="line.4368"></a>
-<span class="sourceLineNo">4369</span> ClearCompactionQueuesRequest
request =<a name="line.4369"></a>
-<span class="sourceLineNo">4370</span>
RequestConverter.buildClearCompactionQueuesRequest(queues);<a
name="line.4370"></a>
-<span class="sourceLineNo">4371</span>
admin.clearCompactionQueues(controller, request);<a name="line.4371"></a>
-<span class="sourceLineNo">4372</span> return null;<a
name="line.4372"></a>
-<span class="sourceLineNo">4373</span> }<a name="line.4373"></a>
-<span class="sourceLineNo">4374</span> };<a name="line.4374"></a>
-<span class="sourceLineNo">4375</span> ProtobufUtil.call(callable);<a
name="line.4375"></a>
-<span class="sourceLineNo">4376</span> }<a name="line.4376"></a>
-<span class="sourceLineNo">4377</span>}<a name="line.4377"></a>
+<span class="sourceLineNo">4189</span><a name="line.4189"></a>
+<span class="sourceLineNo">4190</span> return result;<a
name="line.4190"></a>
+<span class="sourceLineNo">4191</span> }<a name="line.4191"></a>
+<span class="sourceLineNo">4192</span><a name="line.4192"></a>
+<span class="sourceLineNo">4193</span> /**<a name="line.4193"></a>
+<span class="sourceLineNo">4194</span> * Connect to peer and check the table
descriptor on peer:<a name="line.4194"></a>
+<span class="sourceLineNo">4195</span> * <ol><a name="line.4195"></a>
+<span class="sourceLineNo">4196</span> * <li>Create the same table on
peer when not exist.</li><a name="line.4196"></a>
+<span class="sourceLineNo">4197</span> * <li>Throw an exception if the
table already has replication enabled on any of the column<a
name="line.4197"></a>
+<span class="sourceLineNo">4198</span> * families.</li><a
name="line.4198"></a>
+<span class="sourceLineNo">4199</span> * <li>Throw an exception if the
table exists on peer cluster but descriptors are not same.</li><a
name="line.4199"></a>
+<span class="sourceLineNo">4200</span> * </ol><a name="line.4200"></a>
+<span class="sourceLineNo">4201</span> * @param tableName name of the table
to sync to the peer<a name="line.4201"></a>
+<span class="sourceLineNo">4202</span> * @param splits table split keys<a
name="line.4202"></a>
+<span class="sourceLineNo">4203</span> * @throws IOException<a
name="line.4203"></a>
+<span class="sourceLineNo">4204</span> */<a name="line.4204"></a>
+<span class="sourceLineNo">4205</span> private void
checkAndSyncTableDescToPeers(final TableName tableName, final byte[][]
splits)<a name="line.4205"></a>
+<span class="sourceLineNo">4206</span> throws IOException {<a
name="line.4206"></a>
+<span class="sourceLineNo">4207</span>
List<ReplicationPeerDescription> peers = listReplicationPeers();<a
name="line.4207"></a>
+<span class="sourceLineNo">4208</span> if (peers == null || peers.size()
<= 0) {<a name="line.4208"></a>
+<span class="sourceLineNo">4209</span> throw new
IllegalArgumentException("Found no peer cluster for replication.");<a
name="line.4209"></a>
+<span class="sourceLineNo">4210</span> }<a name="line.4210"></a>
+<span class="sourceLineNo">4211</span><a name="line.4211"></a>
+<span class="sourceLineNo">4212</span> for (ReplicationPeerDescription
peerDesc : peers) {<a name="line.4212"></a>
+<span class="sourceLineNo">4213</span> if (needToReplicate(tableName,
peerDesc)) {<a name="line.4213"></a>
+<span class="sourceLineNo">4214</span> Configuration peerConf =
getPeerClusterConfiguration(peerDesc);<a name="line.4214"></a>
+<span class="sourceLineNo">4215</span> try (Connection conn =
ConnectionFactory.createConnection(peerConf);<a name="line.4215"></a>
+<span class="sourceLineNo">4216</span> Admin repHBaseAdmin =
conn.getAdmin()) {<a name="line.4216"></a>
+<span class="sourceLineNo">4217</span> HTableDescriptor localHtd =
getTableDescriptor(tableName);<a name="line.4217"></a>
+<span class="sourceLineNo">4218</span> HTableDescriptor peerHtd =
null;<a name="line.4218"></a>
+<span class="sourceLineNo">4219</span> if
(!repHBaseAdmin.tableExists(tableName)) {<a name="line.4219"></a>
+<span class="sourceLineNo">4220</span>
repHBaseAdmin.createTable(localHtd, splits);<a name="line.4220"></a>
+<span class="sourceLineNo">4221</span> } else {<a
name="line.4221"></a>
+<span class="sourceLineNo">4222</span> peerHtd =
repHBaseAdmin.getTableDescriptor(tableName);<a name="line.4222"></a>
+<span class="sourceLineNo">4223</span> if (peerHtd == null) {<a
name="line.4223"></a>
+<span class="sourceLineNo">4224</span> throw new
IllegalArgumentException("Failed to get table descriptor for table "<a
name="line.4224"></a>
+<span class="sourceLineNo">4225</span> +
tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId());<a
name="line.4225"></a>
+<span class="sourceLineNo">4226</span> }<a name="line.4226"></a>
+<span class="sourceLineNo">4227</span> if
(!compareForReplication(peerHtd, localHtd)) {<a name="line.4227"></a>
+<span class="sourceLineNo">4228</span> throw new
IllegalArgumentException("Table " + tableName.getNameAsString()<a
name="line.4228"></a>
+<span class="sourceLineNo">4229</span> + " exists in peer
cluster " + peerDesc.getPeerId()<a name="line.4229"></a>
+<span class="sourceLineNo">4230</span> + ", but the table
descriptors are not same when compared with source cluster."<a
name="line.4230"></a>
+<span class="sourceLineNo">4231</span> + " Thus can not
enable the table's replication switch.");<a name="line.4231"></a>
+<span class="sourceLineNo">4232</span> }<a name="line.4232"></a>
+<span class="sourceLineNo">4233</span> }<a name="line.4233"></a>
+<span class="sourceLineNo">4234</span> }<a name="line.4234"></a>
+<span class="sourceLineNo">4235</span> }<a name="line.4235"></a>
+<span class="sourceLineNo">4236</span> }<a name="line.4236"></a>
+<span class="sourceLineNo">4237</span> }<a name="line.4237"></a>
+<span class="sourceLineNo">4238</span><a name="line.4238"></a>
+<span class="sourceLineNo">4239</span> /**<a name="line.4239"></a>
+<span class="sourceLineNo">4240</span> * Decide whether the table need
replicate to the peer cluster according to the peer config<a
name="line.4240"></a>
+<span class="sourceLineNo">4241</span> * @param table name of the table<a
name="line.4241"></a>
+<span class="sourceLineNo">4242</span> * @param peer config for the peer<a
name="line.4242"></a>
+<span class="sourceLineNo">4243</span> * @return true if the table need
replicate to the peer cluster<a name="line.4243"></a>
+<span class="sourceLineNo">4244</span> */<a name="line.4244"></a>
+<span class="sourceLineNo">4245</span> private boolean
needToReplicate(TableName table, ReplicationPeerDescription peer) {<a
name="line.4245"></a>
+<span class="sourceLineNo">4246</span> ReplicationPeerConfig peerConfig =
peer.getPeerConfig();<a name="line.4246"></a>
+<span class="sourceLineNo">4247</span> Set<String> namespaces =
peerConfig.getNamespaces();<a name="line.4247"></a>
+<span class="sourceLineNo">4248</span> Map<TableName,
List<String>> tableCFsMap = peerConfig.getTableCFsMap();<a
name="line.4248"></a>
+<span class="sourceLineNo">4249</span> // If null means user has explicitly
not configured any namespaces and table CFs<a name="line.4249"></a>
+<span class="sourceLineNo">4250</span> // so all the tables data are
applicable for replication<a name="line.4250"></a>
+<span class="sourceLineNo">4251</span> if (namespaces == null &&
tableCFsMap == null) {<a name="line.4251"></a>
+<span class="sourceLineNo">4252</span> return true;<a
name="line.4252"></a>
+<span class="sourceLineNo">4253</span> }<a name="line.4253"></a>
+<span class="sourceLineNo">4254</span> if (namespaces != null &&
namespaces.contains(table.getNamespaceAsString())) {<a name="line.4254"></a>
+<span class="sourceLineNo">4255</span> return true;<a
name="line.4255"></a>
+<span class="sourceLineNo">4256</span> }<a name="line.4256"></a>
+<span class="sourceLineNo">4257</span> if (tableCFsMap != null &&
tableCFsMap.containsKey(table)) {<a name="line.4257"></a>
+<span class="sourceLineNo">4258</span> return true;<a
name="line.4258"></a>
+<span class="sourceLineNo">4259</span> }<a name="line.4259"></a>
+<span class="sourceLineNo">4260</span> LOG.debug("Table " +
table.getNameAsString()<a name="line.4260"></a>
+<span class="sourceLineNo">4261</span> + " doesn't need replicate to
peer cluster, peerId=" + peer.getPeerId() + ", clusterKey="<a
name="line.4261"></a>
+<span class="sourceLineNo">4262</span> + peerConfig.getClusterKey());<a
name="line.4262"></a>
+<span class="sourceLineNo">4263</span> return false;<a name="line.4263"></a>
+<span class="sourceLineNo">4264</span> }<a name="line.4264"></a>
+<span class="sourceLineNo">4265</span><a name="line.4265"></a>
+<span class="sourceLineNo">4266</span> /**<a name="line.4266"></a>
+<span class="sourceLineNo">4267</span> * Set the table's replication switch
if the table's replication switch is already not set.<a name="line.4267"></a>
+<span class="sourceLineNo">4268</span> * @param tableName name of the
table<a name="line.4268"></a>
+<span class="sourceLineNo">4269</span> * @param enableRep is replication
switch enable or disable<a name="line.4269"></a>
+<span class="sourceLineNo">4270</span> * @throws IOException if a remote or
network exception occurs<a name="line.4270"></a>
+<span class="sourceLineNo">4271</span> */<a name="line.4271"></a>
+<span class="sourceLineNo">4272</span> private void setTableRep(final
TableName tableName, boolean enableRep) throws IOException {<a
name="line.4272"></a>
+<span class="sourceLineNo">4273</span> HTableDescriptor htd = new
HTableDescriptor(getTableDescriptor(tableName));<a name="line.4273"></a>
+<span class="sourceLineNo">4274</span> ReplicationState
currentReplicationState = getTableReplicationState(htd);<a name="line.4274"></a>
+<span class="sourceLineNo">4275</span> if (enableRep &&
currentReplicationState != ReplicationState.ENABLED<a name="line.4275"></a>
+<span class="sourceLineNo">4276</span> || !enableRep &&
currentReplicationState != ReplicationState.DISABLED) {<a name="line.4276"></a>
+<span class="sourceLineNo">4277</span> for (HColumnDescriptor hcd :
htd.getFamilies()) {<a name="line.4277"></a>
+<span class="sourceLineNo">4278</span> hcd.setScope(enableRep ?
HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.4278"></a>
+<span class="sourceLineNo">4279</span> :
HConstants.REPLICATION_SCOPE_LOCAL);<a name="line.4279"></a>
+<span class="sourceLineNo">4280</span> }<a name="line.4280"></a>
+<span class="sourceLineNo">4281</span> modifyTable(tableName, htd);<a
name="line.4281"></a>
+<span class="sourceLineNo">4282</span> }<a name="line.4282"></a>
+<span class="sourceLineNo">4283</span> }<a name="line.4283"></a>
+<span class="sourceLineNo">4284</span><a name="line.4284"></a>
+<span class="sourceLineNo">4285</span> /**<a name="line.4285"></a>
+<span class="sourceLineNo">4286</span> * This enum indicates the current
state of the replication for a given table.<a name="line.4286"></a>
+<span class="sourceLineNo">4287</span> */<a name="line.4287"></a>
+<span class="sourceLineNo">4288</span> private enum ReplicationState {<a
name="line.4288"></a>
+<span class="sourceLineNo">4289</span> ENABLED, // all column families
enabled<a name="line.4289"></a>
+<span class="sourceLineNo">4290</span> MIXED, // some column families
enabled, some disabled<a name="line.4290"></a>
+<span class="sourceLineNo">4291</span> DISABLED // all column families
disabled<a name="line.4291"></a>
+<span class="sourceLineNo">4292</span> }<a name="line.4292"></a>
+<span class="sourceLineNo">4293</span><a name="line.4293"></a>
+<span class="sourceLineNo">4294</span> /**<a name="line.4294"></a>
+<span class="sourceLineNo">4295</span> * @param htd table descriptor details
for the table to check<a name="line.4295"></a>
+<span class="sourceLineNo">4296</span> * @return ReplicationState the
current state of the table.<a name="line.4296"></a>
+<span class="sourceLineNo">4297</span> */<a name="line.4297"></a>
+<span class="sourceLineNo">4298</span> private ReplicationState
getTableReplicationState(HTableDescriptor htd) {<a name="line.4298"></a>
+<span class="sourceLineNo">4299</span> boolean hasEnabled = false;<a
name="line.4299"></a>
+<span class="sourceLineNo">4300</span> boolean hasDisabled = false;<a
name="line.4300"></a>
+<span class="sourceLineNo">4301</span><a name="line.4301"></a>
+<span class="sourceLineNo">4302</span> for (HColumnDescriptor hcd :
htd.getFamilies()) {<a name="line.4302"></a>
+<span class="sourceLineNo">4303</span> if (hcd.getScope() !=
HConstants.REPLICATION_SCOPE_GLOBAL<a name="line.4303"></a>
+<span class="sourceLineNo">4304</span> && hcd.getScope() !=
HConstants.REPLICATION_SCOPE_SERIAL) {<a name="line.4304"></a>
+<span class="sourceLineNo">4305</span> hasDisabled = true;<a
name="line.4305"></a>
+<span class="sourceLineNo">4306</span> } else {<a name="line.4306"></a>
+<span class="sourceLineNo">4307</span> hasEnabled = true;<a
name="line.4307"></a>
+<span class="sourceLineNo">4308</span> }<a name="line.4308"></a>
+<span class="sourceLineNo">4309</span> }<a name="line.4309"></a>
+<span class="sourceLineNo">4310</span><a name="line.4310"></a>
+<span class="sourceLineNo">4311</span> if (hasEnabled &&
hasDisabled) return ReplicationState.MIXED;<a name="line.4311"></a>
+<span class="sourceLineNo">4312</span> if (hasEnabled) return
ReplicationState.ENABLED;<a name="line.4312"></a>
+<span class="sourceLineNo">4313</span> return ReplicationState.DISABLED;<a
name="line.4313"></a>
+<span class="sourceLineNo">4314</span> }<a name="line.4314"></a>
+<span class="sourceLineNo">4315</span><a name="line.4315"></a>
+<span class="sourceLineNo">4316</span> /**<a name="line.4316"></a>
+<span class="sourceLineNo">4317</span> * Returns the configuration needed to
talk to the remote slave cluster.<a name="line.4317"></a>
+<span class="sourceLineNo">4318</span> * @param peer the description of
replication peer<a name="line.4318"></a>
+<span class="sourceLineNo">4319</span> * @return the configuration for the
peer cluster, null if it was unable to get the configuration<a
name="line.4319"></a>
+<span class="sourceLineNo">4320</span> * @throws IOException<a
name="line.4320"></a>
+<span class="sourceLineNo">4321</span> */<a name="line.4321"></a>
+<span class="sourceLineNo">4322</span> private Configuration
getPeerClusterConfiguration(ReplicationPeerDescription peer)<a
name="line.4322"></a>
+<span class="sourceLineNo">4323</span> throws IOException {<a
name="line.4323"></a>
+<span class="sourceLineNo">4324</span> ReplicationPeerConfig peerConfig =
peer.getPeerConfig();<a name="line.4324"></a>
+<span class="sourceLineNo">4325</span> Configuration otherConf;<a
name="line.4325"></a>
+<span class="sourceLineNo">4326</span> try {<a name="line.4326"></a>
+<span class="sourceLineNo">4327</span> otherConf =
HBaseConfiguration.createClusterConf(this.conf, peerConfig.getClusterKey());<a
name="line.4327"></a>
+<span class="sourceLineNo">4328</span> } catch (IOException e) {<a
name="line.4328"></a>
+<span class="sourceLineNo">4329</span> throw new IOException("Can't get
peer configuration for peerId=" + peer.getPeerId(), e);<a name="line.4329"></a>
+<span class="sourceLineNo">4330</span> }<a name="line.4330"></a>
+<span class="sourceLineNo">4331</span><a name="line.4331"></a>
+<span class="sourceLineNo">4332</span> if
(!peerConfig.getConfiguration().isEmpty()) {<a name="line.4332"></a>
+<span class="sourceLineNo">4333</span> CompoundConfiguration compound =
new CompoundConfiguration();<a name="line.4333"></a>
+<span class="sourceLineNo">4334</span> compound.add(otherConf);<a
name="line.4334"></a>
+<span class="sourceLineNo">4335</span>
compound.addStringMap(peerConfig.getConfiguration());<a name="line.4335"></a>
+<span class="sourceLineNo">4336</span> return compound;<a
name="line.4336"></a>
+<span class="sourceLineNo">4337</span> }<a name="line.4337"></a>
+<span class="sourceLineNo">4338</span><a name="line.4338"></a>
+<span class="sourceLineNo">4339</span> return otherConf;<a
name="line.4339"></a>
+<span class="sourceLineNo">4340</span> }<a name="line.4340"></a>
+<span class="sourceLineNo">4341</span><a name="line.4341"></a>
+<span class="sourceLineNo">4342</span> @Override<a name="line.4342"></a>
+<span class="sourceLineNo">4343</span> public void
clearCompactionQueues(final ServerName sn, final Set<String> queues)<a
name="line.4343"></a>
+<span class="sourceLineNo">4344</span> throws IOException,
InterruptedException {<a name="line.4344"></a>
+<span class="sourceLineNo">4345</span> if (queues == null || queues.size()
== 0) {<a name="line.4345"></a>
+<span class="sourceLineNo">4346</span> throw new
IllegalArgumentException("queues cannot be null or empty");<a
name="line.4346"></a>
+<span class="sourceLineNo">4347</span> }<a name="line.4347"></a>
+<span class="sourceLineNo">4348</span> final AdminService.BlockingInterface
admin = this.connection.getAdmin(sn);<a name="line.4348"></a>
+<span class="sourceLineNo">4349</span> Callable<Void> callable = new
Callable<Void>() {<a name="line.4349"></a>
+<span class="sourceLineNo">4350</span> @Override<a name="line.4350"></a>
+<span class="sourceLineNo">4351</span> public Void call() throws
Exception {<a name="line.4351"></a>
+<span class="sourceLineNo">4352</span> // TODO: There is no timeout on
this controller. Set one!<a name="line.4352"></a>
+<span class="sourceLineNo">4353</span> HBaseRpcController controller =
rpcControllerFactory.newController();<a name="line.4353"></a>
+<span class="sourceLineNo">4354</span> ClearCompactionQueuesRequest
request =<a name="line.4354"></a>
+<span class="sourceLineNo">4355</span>
RequestConverter.buildClearCompactionQueuesRequest(queues);<a
name="line.4355"></a>
+<span class="sourceLineNo">4356</span>
admin.clearCompactionQueues(controller, request);<a name="line.4356"></a>
+<span class="sourceLineNo">4357</span> return null;<a
name="line.4357"></a>
+<span class="sourceLineNo">4358</span> }<a name="line.4358"></a>
+<span class="sourceLineNo">4359</span> };<a name="line.4359"></a>
+<span class="sourceLineNo">4360</span> ProtobufUtil.call(callable);<a
name="line.4360"></a>
+<span class="sourceLineNo">4361</span> }<a name="line.4361"></a>
+<span class="sourceLineNo">4362</span>}<a name="line.4362"></a>