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) {
//pass
}
bw1 = mtbw.getBatchWriter(newTable1);
bw2 = mtbw.getBatchWriter(newTable2);
Mutation m2 = new Mutation("bar");
m2.put("col1", "", "val1");
m2.put("col2", "", "val2");
bw1.addMutation(m2);
bw2.addMutation(m2);
mtbw.close();
Map<Entry<String,String>,String> expectations = new HashMap<Entry<String,String>,String>();