try {
final String table1 = "testTableRenameNewWriters_table1", table2 = "testTableRenameNewWriters_table2";
final String newTable1 = "testTableRenameNewWriters_newTable1", newTable2 = "testTableRenameNewWriters_newTable2";
TableOperations tops = connector.tableOperations();
tops.create(table1);
tops.create(table2);
BatchWriter bw1 = mtbw.getBatchWriter(table1), bw2 = mtbw.getBatchWriter(table2);
Mutation m1 = new Mutation("foo");
m1.put("col1", "", "val1");
m1.put("col2", "", "val2");
bw1.addMutation(m1);
bw2.addMutation(m1);
tops.rename(table1, newTable1);
// MTBW is still caching this name to the correct table, but we should invalidate its cache
// after seeing the rename
try {
bw1 = mtbw.getBatchWriter(table1);
Assert.fail("Should not be able to find this table");
} catch (TableNotFoundException e) {
// pass
}
tops.rename(table2, newTable2);
try {
bw2 = mtbw.getBatchWriter(table2);
Assert.fail("Should not be able to find this table");
} catch (TableNotFoundException e) {