lock.lock();
try {
final NavigableMap<Long, KijiTableLayout> layoutMap =
metaTable.getTimedTableLayoutVersions(mTableURI.getTable(), Integer.MAX_VALUE);
final KijiTableLayout currentLayout = layoutMap.lastEntry().getValue();
final TableLayoutDesc update = mLayoutUpdate.apply(currentLayout);
if (!Objects.equal(currentLayout.getDesc().getLayoutId(), update.getReferenceLayout())) {
throw new InvalidLayoutException(String.format(
"Reference layout ID %s does not match current layout ID %s.",
update.getReferenceLayout(), currentLayout.getDesc().getLayoutId()));
}
final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(mKiji);
validator.validate(
currentLayout,
KijiTableLayout.createUpdatedLayout(update , currentLayout));
final TableLayoutTracker layoutTracker =
new TableLayoutTracker(mZKClient, mTableURI, mLayoutUpdateHandler);
try {
layoutTracker.start();
final UsersTracker usersTracker =
ZooKeeperUtils
.newTableUsersTracker(mZKClient, mTableURI)
.registerUpdateHandler(mUsersUpdateHandler);
try {
usersTracker.start();
final String currentLayoutId = mLayoutUpdateHandler.getCurrentLayoutId();
LOG.info("Table {} has current layout ID {}.", mTableURI, currentLayoutId);
if (!Objects.equal(currentLayoutId, currentLayout.getDesc().getLayoutId())) {
throw new InternalKijiError(String.format(
"Inconsistency between meta-table and ZooKeeper: "
+ "meta-table layout has ID %s while ZooKeeper has layout ID %s.",
currentLayout.getDesc().getLayoutId(), currentLayoutId));
}
final String consistentLayoutId = waitForConsistentView();
if ((consistentLayoutId != null) && !Objects.equal(consistentLayoutId, currentLayoutId)) {
throw new InternalKijiError(String.format(