/** * Registers a ZooKeeper watcher for the specified table's layout. * * <p> Retries on ZooKeeper failure (no deadline, no limit). </p> * <p> Dies whenever an exception pops up while running a handler. </p> */ private void registerWatcher() { try { final byte[] layoutUpdate = mZKClient.getData(mTableLayoutFile, mWatcher, mLayoutStat); if (!Arrays.equals(mLatestLayout, layoutUpdate)) { // Layout update may not be changed in the case where this was triggered by a ZooKeeper // connection state change. LOG.debug("Received layout update for table {}: {}.", mTableURI, Bytes.toStringBinary(layoutUpdate)); mLatestLayout = layoutUpdate; // This assumes handlers do not let exceptions pop up: mHandler.update(layoutUpdate); } } catch (KeeperException.NoNodeException nne) { LOG.info("Tracked table layout node for table {} has been removed. Tracking will cease.", mTableURI); } catch (KeeperException ke) { LOG.error("Unrecoverable ZooKeeper error: {}", ke.getMessage()); } }