/** * Creates the singleton instance, if not yet present, and returns the same. * @param watcher * @param conf * @return Singleton instance of VisibilityLabelsCache * @throws IOException */ public synchronized static VisibilityLabelsCache createAndGet(ZKWatcher watcher, Configuration conf) throws IOException { // VisibilityLabelService#init() for different regions (in same RS) passes same instance of // watcher as all get the instance from RS. // watcher != instance.zkVisibilityWatcher.getWatcher() - This check is needed only in UTs with // RS restart. It will be same JVM in which RS restarts and instance will be not null. But the // watcher associated with existing instance will be stale as the restarted RS will have new // watcher with it. if (instance == null || watcher != instance.zkVisibilityWatcher.getWatcher()) { instance = new VisibilityLabelsCache(watcher, conf); } return instance; }
/** * Creates the singleton instance, if not yet present, and returns the same. * @param watcher * @param conf * @return Singleton instance of VisibilityLabelsCache * @throws IOException */ public synchronized static VisibilityLabelsCache createAndGet(ZooKeeperWatcher watcher, Configuration conf) throws IOException { // VisibilityLabelService#init() for different regions (in same RS) passes same instance of // watcher as all get the instance from RS. // watcher != instance.zkVisibilityWatcher.getWatcher() - This check is needed only in UTs with // RS restart. It will be same JVM in which RS restarts and instance will be not null. But the // watcher associated with existing instance will be stale as the restarted RS will have new // watcher with it. if (instance == null || watcher != instance.zkVisibilityWatcher.getWatcher()) { instance = new VisibilityLabelsCache(watcher, conf); } return instance; }