/** * Initializes a new table layout monitor. * * @param zkClient ZooKeeper client. * @throws KeeperException on unrecoverable ZooKeeper error. */ public ZooKeeperMonitor(ZooKeeperClient zkClient) throws KeeperException { this.mZKClient = zkClient; this.mZKClient.createNodeRecursively(ROOT_ZOOKEEPER_PATH); // ZooKeeperClient.retain() should be the last line of the constructor. this.mZKClient.retain(); }
/** * Closes the monitor. * @throws IOException in case of an error closing the underlying ZooKeeper connection. */ public void close() throws IOException { this.mZKClient.release(); }
/** * {@inheritDoc} * * If you need both the table layout and a column name translator within a single short lived * operation, you should create the column name translator from this layout to ensure consistency. */ @Override public FijiTableLayout getLayout() { return mLayoutMonitor.getLayout(); }
/** {@inheritDoc} */ @Override public Registration registerLayoutConsumer(LayoutConsumer consumer) throws IOException { return mTableLayoutMonitor.registerLayoutConsumer(consumer); }
/** * Update this TableUserRegistration with the supplied layout ID. * * @param layoutID id of layout being used by registered table user. * @throws IOException on unrecoverable ZooKeeper error. */ public void updateRegisteredLayout(String layoutID) throws IOException { synchronized (mMonitor) { unregister(); register(layoutID); } }
/** * Reports the path of the ZooKeeper node for permissions changes locking. * * @param instanceURI URI of the instance for which to get a lock for permissions changes. * @return the path of the ZooKeeper node used as a lock for permissions changes. */ public static File getInstancePermissionsLock(FijiURI instanceURI) { return new File(getInstanceDir(instanceURI), "permissions_lock"); }
/** * Creates a registration for a table user. * * <p> The registration must be started and closed. </p> * * @param userID of user to be registered. * @param tableURI of table the user is using. * @return a new table user registration for the user and table. */ public TableUserRegistration newTableUserRegistration(String userID, FijiURI tableURI) { return new TableUserRegistration(userID, tableURI); }
/** {@inheritDoc} */ @Override public void updateLayoutConsumers(FijiTableLayout layout) throws IOException { mTableLayoutMonitor.updateLayoutConsumers(layout); } }
/** * Creates a tracker for the users of a table. * * <p> The tracker must be opened and closed. </p> * * @param tableURI Tracks the users of the table with this URI. * @param handler Handler invoked to process updates to the users list of the specified table. * @return a new tracker for the users of the specified table. */ public UsersTracker newTableUsersTracker(FijiURI tableURI, UsersUpdateHandler handler) { return new UsersTracker(tableURI, handler); }
/** * Reports the ZooKeeper session client. * * <p> This may potentially wait forever: no timeout. </p> * * @return the ZooKeeper session client. */ public ZooKeeper getZKClient() { return getZKClient(0.0); }
/** {@inheritDoc} */ @Override public Set<LayoutConsumer> getLayoutConsumers() { return mTableLayoutMonitor.getLayoutConsumers(); }
/** * Creates a tracker for a table layout. * * <p> The tracker must be opened and closed. </p> * * @param tableURI Tracks the layout of the table with this URI. * @param handler Handler invoked to process table layout updates. * @return a new layout tracker for the specified table. */ public LayoutTracker newTableLayoutTracker(FijiURI tableURI, LayoutUpdateHandler handler) { return new LayoutTracker(tableURI, handler); }
/** * Creates a registration for an instance user. * * <p> The registration must be started and closed. </p> * * @param userID of user to be registered. * @param systemVersion of user to be registered. * @param instanceURI of instance the user is using. * @return a new table user registration for the user and table. */ public InstanceUserRegistration newInstanceUserRegistration( String userID, String systemVersion, FijiURI instanceURI) { return new InstanceUserRegistration(userID, systemVersion, instanceURI); }
/** {@inheritDoc} */ @Override public void close() throws IOException { LOG.debug("Closing TableUserRegistration {}.", this); unregister(); }
/** * Reports the path of the ZooKeeper node where users of a table register themselves. * * @param tableURI Reports the path of the ZooKeeper node where users of the Fiji table with this * URI register themselves. * @return the path of the ZooKeeper node where users of a table register. */ public static File getTableUsersDir(FijiURI tableURI) { return new File(getTableDir(tableURI), "users"); }
/** {@inheritDoc} */ @Override public ZooKeeperClient getZooKeeperClient(final FijiURI uri) { return ZooKeeperClient.getZooKeeperClient(getZooKeeperEnsemble(uri)); }
/** {@inheritDoc} */ @Override public int hashCode() { return getId(); } }
/** {@inheritDoc} */ @Override public FijiTableLayout getLayout() { return mTableLayoutMonitor.getLayout(); }
/** * Reports the ZooKeeper root path containing all tables in a Fiji instance. * * @param fijiURI URI of a Fiji instance to report the ZooKeeper node path for. * @return the ZooKeeper node path that contains all the tables in the specified Fiji instance. */ public static File getInstanceTablesDir(FijiURI fijiURI) { return new File(getInstanceDir(fijiURI), "tables"); }