// wait for master
UtilWaitThread.sleep(1000);
// create a backup
Process backup = exec(Master.class);
try {
ZooReaderWriter writer = new ZooReaderWriter(cluster.getZooKeepers(), 30*1000, "digest", "accumulo:DONTTELL".getBytes());
String root = "/accumulo/" + getConnector().getInstance().getInstanceID();
List<String> children = Collections.emptyList();
// wait for 2 lock entries
do {
UtilWaitThread.sleep(100);
children = writer.getChildren(root + "/masters/lock");
} while (children.size() != 2);
Collections.sort(children);
// wait for the backup master to learn to be the backup
UtilWaitThread.sleep(1000);
// generate a false zookeeper event
String lockPath = root + "/masters/lock/" + children.get(0);
byte data[] = writer.getData(lockPath, null);
writer.getZooKeeper().setData(lockPath, data, -1);
// let it propagate
UtilWaitThread.sleep(500);
// kill the master by removing its lock
writer.recursiveDelete(lockPath, NodeMissingPolicy.FAIL);
// ensure the backup becomes the master
getConnector().tableOperations().create(getUniqueNames(1)[0]);
} finally {
backup.destroy();
}