}
@Test(timeout=300000)
public void testPerTableCFReplication() throws Exception {
LOG.info("testPerTableCFReplication");
ReplicationAdmin admin1 = new ReplicationAdmin(conf1);
new HBaseAdmin(conf1).createTable(tabA);
new HBaseAdmin(conf1).createTable(tabB);
new HBaseAdmin(conf1).createTable(tabC);
new HBaseAdmin(conf2).createTable(tabA);
new HBaseAdmin(conf2).createTable(tabB);
new HBaseAdmin(conf2).createTable(tabC);
new HBaseAdmin(conf3).createTable(tabA);
new HBaseAdmin(conf3).createTable(tabB);
new HBaseAdmin(conf3).createTable(tabC);
Table htab1A = new HTable(conf1, tabAName);
Table htab2A = new HTable(conf2, tabAName);
Table htab3A = new HTable(conf3, tabAName);
Table htab1B = new HTable(conf1, tabBName);
Table htab2B = new HTable(conf2, tabBName);
Table htab3B = new HTable(conf3, tabBName);
Table htab1C = new HTable(conf1, tabCName);
Table htab2C = new HTable(conf2, tabCName);
Table htab3C = new HTable(conf3, tabCName);
// A. add cluster2/cluster3 as peers to cluster1
admin1.addPeer("2", utility2.getClusterKey(), "TC;TB:f1,f3");
admin1.addPeer("3", utility3.getClusterKey(), "TA;TB:f1,f2");
// A1. tableA can only replicated to cluster3
putAndWaitWithFamily(row1, f1Name, htab1A, htab3A);
ensureRowNotReplicated(row1, f1Name, htab2A);
deleteAndWaitWithFamily(row1, f1Name, htab1A, htab3A);
putAndWaitWithFamily(row1, f2Name, htab1A, htab3A);
ensureRowNotReplicated(row1, f2Name, htab2A);
deleteAndWaitWithFamily(row1, f2Name, htab1A, htab3A);
putAndWaitWithFamily(row1, f3Name, htab1A, htab3A);
ensureRowNotReplicated(row1, f3Name, htab2A);
deleteAndWaitWithFamily(row1, f3Name, htab1A, htab3A);
// A2. cf 'f1' of tableB can replicated to both cluster2 and cluster3
putAndWaitWithFamily(row1, f1Name, htab1B, htab2B, htab3B);
deleteAndWaitWithFamily(row1, f1Name, htab1B, htab2B, htab3B);
// cf 'f2' of tableB can only replicated to cluster3
putAndWaitWithFamily(row1, f2Name, htab1B, htab3B);
ensureRowNotReplicated(row1, f2Name, htab2B);
deleteAndWaitWithFamily(row1, f2Name, htab1B, htab3B);
// cf 'f3' of tableB can only replicated to cluster2
putAndWaitWithFamily(row1, f3Name, htab1B, htab2B);
ensureRowNotReplicated(row1, f3Name, htab3B);
deleteAndWaitWithFamily(row1, f3Name, htab1B, htab2B);
// A3. tableC can only replicated to cluster2
putAndWaitWithFamily(row1, f1Name, htab1C, htab2C);
ensureRowNotReplicated(row1, f1Name, htab3C);
deleteAndWaitWithFamily(row1, f1Name, htab1C, htab2C);
putAndWaitWithFamily(row1, f2Name, htab1C, htab2C);
ensureRowNotReplicated(row1, f2Name, htab3C);
deleteAndWaitWithFamily(row1, f2Name, htab1C, htab2C);
putAndWaitWithFamily(row1, f3Name, htab1C, htab2C);
ensureRowNotReplicated(row1, f3Name, htab3C);
deleteAndWaitWithFamily(row1, f3Name, htab1C, htab2C);
// B. change peers' replicable table-cf config
admin1.setPeerTableCFs("2", "TA:f1,f2; TC:f2,f3");
admin1.setPeerTableCFs("3", "TB; TC:f3");
// B1. cf 'f1' of tableA can only replicated to cluster2
putAndWaitWithFamily(row2, f1Name, htab1A, htab2A);
ensureRowNotReplicated(row2, f1Name, htab3A);
deleteAndWaitWithFamily(row2, f1Name, htab1A, htab2A);