/** * Initializes a new layout tracker with the given update handler on the specified table. * * @param tableURI Tracks the table with this URI. * @param handler Handler to process table layout updates. */ private LayoutTracker(FijiURI tableURI, LayoutUpdateHandler handler) { this.mTableURI = tableURI; this.mTableLayoutFile = getTableLayoutFile(tableURI); this.mHandler = handler; final State oldState = mState.getAndSet(State.INITIALIZED); Preconditions.checkState(oldState == State.UNINITIALIZED, "Cannot create LayoutTracker instance in state %s.", oldState); }
/** * Notifies the users of a table of a new layout. * * <p> * The caller must ensure proper locking of table layout update operations through * {@link #newTableLayoutUpdateLock(FijiURI)}. * </p> * * @param tableURI Notify the users of the table with this URI. * @param layout Encoded layout update for the table with the specified URI. * @param version of the current table layout. * @throws KeeperException on unrecoverable ZooKeeper error. */ public void notifyNewTableLayout(FijiURI tableURI, byte[] layout, int version) throws KeeperException { final File layoutPath = getTableLayoutFile(tableURI); this.mZKClient.createNodeRecursively(layoutPath); // This should not be needed if we add a lock for layout updates. final Stat updateStat = this.mZKClient.setData(layoutPath, layout, version); LOG.debug("Updated layout for table {}. Layout version is {}.", tableURI, updateStat.getVersion()); }