@Override public void stop() { try { notificationFinder.stop(); np.close(); appIdCache.close(); reporters.close(); env.close(); } catch (Exception e) { throw new FluoException(e); } }
@Override public void alreadyAcknowledged() { notificationFinder.failedToProcess(notification, TxResult.AACKED); notificationProcessor.notificationProcessed(notification); }
@Override public void run() { try { // Its possible that while the notification was in the queue the situation changed and it // should no longer be processed by this worker. So ask as late as possible if this // notification should be processed. if (notificationFinder.shouldProcess(notification)) { workTask.run(); } else { notificationProcessed(notification); } } catch (Exception e) { log.error("Failed to process work " + Hex.encNonAscii(notification), e); } }
@Test public void testMultipleFinders() { try (Environment env = new Environment(config)) { NotificationFinder nf1 = new PartitionNotificationFinder(); nf1.init(env, ((MiniFluoImpl) miniFluo).getNotificationProcessor()); nf1.start(); NotificationFinder nf2 = new PartitionNotificationFinder(); nf2.init(env, ((MiniFluoImpl) miniFluo).getNotificationProcessor()); nf2.start(); for (int i = 0; i < 10; i++) { addLink("N0003", "N00" + i + "0"); } miniFluo.waitForObservers(); try (Snapshot snap = client.newSnapshot()) { Assert.assertEquals("10", snap.gets("N0003", DEGREE)); Assert.assertEquals("", snap.gets("IDEG10", new Column("node", "N0003"))); } nf2.stop(); for (int i = 1; i < 10; i++) { addLink("N0003", "N0" + i + "00"); } miniFluo.waitForObservers(); try (Snapshot snap = client.newSnapshot()) { Assert.assertEquals("19", snap.gets("N0003", DEGREE)); Assert.assertEquals("", snap.gets("IDEG19", new Column("node", "N0003"))); Assert.assertNull(snap.gets("IDEG10", new Column("node", "N0003"))); } nf1.stop(); } }
@Override public void start() { try { env = new Environment(config); reporters = ReporterUtil.setupReporters(env); appIdCache = CuratorUtil.startAppIdWatcher(env); log.info("Starting Worker for Fluo '{}' application with the following configuration:", config.getApplicationName()); env.getConfiguration().print(); np = new NotificationProcessor(env); notificationFinder = NotificationFinderFactory.newNotificationFinder(env.getConfiguration()); notificationFinder.init(env, np); notificationFinder.start(); } catch (Exception e) { throw new FluoException(e); } }
@Override public void start() { try { env = new Environment(config); reporters = ReporterUtil.setupReporters(env); appIdCache = CuratorUtil.startAppIdWatcher(env); log.info("Starting Worker for Fluo '{}' application with the following configuration:", config.getApplicationName()); env.getConfiguration().print(); np = new NotificationProcessor(env); notificationFinder = NotificationFinderFactory.newNotificationFinder(env.getConfiguration()); notificationFinder.init(env, np); notificationFinder.start(); } catch (Exception e) { throw new FluoException(e); } }
public MiniFluoImpl(FluoConfiguration fluoConfig) { if (!fluoConfig.hasRequiredMiniFluoProps()) { throw new IllegalArgumentException("MiniFluo configuration is not valid"); } config = fluoConfig; try { if (config.getMiniStartAccumulo()) { startMiniAccumulo(); } config.setProperty(FluoConfigurationImpl.NTFY_FINDER_MIN_SLEEP_TIME_PROP, 50); config.setProperty(FluoConfigurationImpl.NTFY_FINDER_MAX_SLEEP_TIME_PROP, 100); env = new Environment(config); reporter = FluoClientImpl.setupReporters(env, "mini", reporterCounter); oserver = new OracleServer(env); oserver.start(); mnp = new NotificationProcessor(env); notificationFinder = NotificationFinderFactory.newNotificationFinder(env.getConfiguration()); notificationFinder.init(env, mnp); notificationFinder.start(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void stop() { try { notificationFinder.stop(); np.close(); appIdCache.close(); reporters.close(); env.close(); } catch (Exception e) { throw new FluoException(e); } }
@Override public void alreadyAcknowledged() { notificationFinder.failedToProcess(notification, TxResult.AACKED); notificationProcessor.notificationProcessed(notification); }
@Override public void run() { try { // Its possible that while the notification was in the queue the situation changed and it // should no longer be processed by this worker. So ask as late as possible if this // notification should be processed. if (notificationFinder.shouldProcess(notification)) { workTask.run(); } else { notificationProcessed(notification); } } catch (Exception e) { log.error("Failed to process work " + Hex.encNonAscii(notification), e); } }
public MiniFluoImpl(FluoConfiguration fluoConfig) { if (!fluoConfig.hasRequiredMiniFluoProps()) { throw new IllegalArgumentException("MiniFluo configuration is not valid"); } config = fluoConfig; try { if (config.getMiniStartAccumulo()) { startMiniAccumulo(); } config.setProperty(FluoConfigurationImpl.NTFY_FINDER_MIN_SLEEP_TIME_PROP, 50); config.setProperty(FluoConfigurationImpl.NTFY_FINDER_MAX_SLEEP_TIME_PROP, 100); env = new Environment(config); reporter = FluoClientImpl.setupReporters(env, "mini", reporterCounter); oserver = new OracleServer(env); oserver.start(); mnp = new NotificationProcessor(env); notificationFinder = NotificationFinderFactory.newNotificationFinder(env.getConfiguration()); notificationFinder.init(env, mnp); notificationFinder.start(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void close() { try { if (oserver != null) { notificationFinder.stop(); mnp.close(); oserver.stop(); env.close(); reporter.close(); if (cluster != null) { cluster.stop(); } } } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void failed(Throwable t) { notificationFinder.failedToProcess(notification, TxResult.ERROR); notificationProcessor.notificationProcessed(notification); log.error("Failed to process work " + Hex.encNonAscii(notification), t); }
@Override public void close() { try { if (oserver != null) { notificationFinder.stop(); mnp.close(); oserver.stop(); env.close(); reporter.close(); if (cluster != null) { cluster.stop(); } } } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void failed(Throwable t) { notificationFinder.failedToProcess(notification, TxResult.ERROR); notificationProcessor.notificationProcessed(notification); log.error("Failed to process work " + Hex.encNonAscii(notification), t); }
@Override public void run() { Observer observer = observers.getObserver(notification.getColumn()); String observerId = observers.getObserverId(notification.getColumn()); try { AsyncTransaction atx = new TransactionImpl(env, notification); if (TracingTransaction.isTracingEnabled()) { atx = new TracingTransaction(atx, notification, observer.getClass(), observerId); } try { observer.process(atx, notification.getRow(), notification.getColumn()); } catch (Exception e) { notificationFinder.failedToProcess(notification, TxResult.ERROR); notificationProcessor.notificationProcessed(notification); throw e; } CommitManager commitManager = env.getSharedResources().getCommitManager(); commitManager.beginCommit(atx, observerId, new WorkTaskCommitObserver()); } catch (Exception e) { log.error("Failed to process work " + Hex.encNonAscii(notification), e); } finally { observers.returnObserver(observer); } } }
@Override public void run() { Observer observer = observers.getObserver(notification.getColumn()); String observerId = observers.getObserverId(notification.getColumn()); try { AsyncTransaction atx = new TransactionImpl(env, notification); if (TracingTransaction.isTracingEnabled()) { atx = new TracingTransaction(atx, notification, observer.getClass(), observerId); } try { observer.process(atx, notification.getRow(), notification.getColumn()); } catch (Exception e) { notificationFinder.failedToProcess(notification, TxResult.ERROR); notificationProcessor.notificationProcessed(notification); throw e; } CommitManager commitManager = env.getSharedResources().getCommitManager(); commitManager.beginCommit(atx, observerId, new WorkTaskCommitObserver()); } catch (Exception e) { log.error("Failed to process work " + Hex.encNonAscii(notification), e); } finally { observers.returnObserver(observer); } } }