@Override public void waitForObservers() { try { Scanner scanner = env.getConnector().createScanner(env.getTable(), env.getAuthorizations()); Notification.configureScanner(scanner); while (isProcessing(scanner)) { Thread.sleep(100); } } catch (Exception e) { throw new RuntimeException(e); } } }
@VisibleForTesting public long countNotifications(Environment env) { Scanner scanner = null; try { scanner = env.getConnector().createScanner(env.getTable(), env.getAuthorizations()); } catch (TableNotFoundException e) { log.error("An exception was thrown -", e); throw new FluoException(e); } Notification.configureScanner(scanner); long count = 0; for (Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator(); iterator.hasNext(); iterator .next()) { count++; } return count; }
private int scan(ModulusParams lmp, Range range) throws TableNotFoundException { Scanner scanner = env.getConnector().createScanner(env.getTable(), env.getAuthorizations()); scanner.setRange(range); Notification.configureScanner(scanner); IteratorSetting iterCfg = new IteratorSetting(30, "nhf", NotificationHashFilter.class); NotificationHashFilter.setModulusParams(iterCfg, lmp.divisor, lmp.remainder); scanner.addScanIterator(iterCfg); int count = 0; for (Entry<Key, Value> entry : scanner) { if (lmp.update != hwf.getModulusParams().update) { throw new HashNotificationFinder.ModParamsChangedException(); } if (stopped.get()) { return count; } if (hwf.getWorkerQueue().addNotification(hwf, Notification.from(entry.getKey()))) { count++; } } return count; }