HBASE-17460 enable_table_replication can not perform cyclic replication of a table - addendum removes replication check (Janos Gub)

This commit is contained in:
tedyu 2017-03-07 19:42:26 -08:00
parent ee1549cc97
commit c42a0665b9
2 changed files with 6 additions and 42 deletions

View File

@ -1038,31 +1038,6 @@ public class HTableDescriptor implements Comparable<HTableDescriptor> {
return compareTo((HTableDescriptor)obj) == 0;
}
/**
* Detects whether replication has been already enabled on any of the column families of this
* table descriptor.
* @return true if any of the column families has replication enabled.
*/
public boolean isReplicationEnabled() {
// Go through each Column-Family descriptor and check if the
// Replication has been enabled already.
// Return 'true' if replication has been enabled on any CF,
// otherwise return 'false'.
//
boolean result = false;
Iterator<HColumnDescriptor> it = this.families.values().iterator();
while (it.hasNext()) {
HColumnDescriptor tempHcd = it.next();
if (tempHcd.getScope() != HConstants.REPLICATION_SCOPE_LOCAL) {
result = true;
break;
}
}
return result;
}
/**
* @see java.lang.Object#hashCode()
*/

View File

@ -4185,23 +4185,12 @@ public class HBaseAdmin implements Admin {
if (peerHtd == null) {
throw new IllegalArgumentException("Failed to get table descriptor for table "
+ tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId());
} else {
// To support cyclic replication (HBASE-17460), we need to match the
// REPLICATION_SCOPE of table on both the clusters. We should do this
// only when the replication is not already enabled on local HTD (local
// table on this cluster).
//
if (localHtd.isReplicationEnabled()) {
throw new IllegalArgumentException("Table " + tableName.getNameAsString()
+ " has replication already enabled for at least one Column Family.");
} else {
if (!compareForReplication(peerHtd, localHtd)) {
throw new IllegalArgumentException("Table " + tableName.getNameAsString()
+ " exists in peer cluster " + peerDesc.getPeerId()
+ ", but the table descriptors are not same when compared with source cluster."
+ " Thus can not enable the table's replication switch.");
}
}
}
if (!compareForReplication(peerHtd, localHtd)) {
throw new IllegalArgumentException("Table " + tableName.getNameAsString()
+ " exists in peer cluster " + peerDesc.getPeerId()
+ ", but the table descriptors are not same when compared with source cluster."
+ " Thus can not enable the table's replication switch.");
}
}
}