@Test public void testOnDataTreeChanged_noop() throws Exception { Mockito.when(dataModification.getDataAfter()).thenReturn(null); Mockito.when(treeModification.getRootNode()).thenReturn(dataModification); listener.onDataTreeChanged(Collections.singleton(treeModification)); Mockito.verifyNoMoreInteractions(harvester, dataBroker); }
@Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection) { for (DataTreeModification<IseSourceConfig> modification : collection) { final IseSourceConfig iseSourceConfig = modification.getRootNode().getDataAfter(); final IseContext iseContext = new IseContext(iseSourceConfig); templateProviderFacade.assignIseContext(iseContext); if (iseSourceConfig != null) { final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig()); LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(), connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a"))); pool.submit(() -> { final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext); Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() { @Override public void onSuccess(@Nullable final Collection<SgtInfo> result) { final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0); LOG.debug("ise harvest finished, outcome: {}", counter); storeOutcome(true, counter, null); } @Override public void onFailure(final Throwable t) { LOG.debug("ise harvest failed", t); storeOutcome(false, 0, t.getMessage()); } }, MoreExecutors.directExecutor()); try { harvestResult.get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.debug("failed to finish ise-sgt-harvest task properly on time", e); } }); } else { LOG.debug("Ise-source config removed"); } } }
GbpIseConfigListenerImpl implements GbpIseConfigListener { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection) { for (DataTreeModification<IseSourceConfig> modification : collection) { final IseSourceConfig iseSourceConfig = modification.getRootNode().getDataAfter(); final IseContext iseContext = new IseContext(iseSourceConfig); templateProviderFacade.assignIseContext(iseContext); if (iseSourceConfig != null) { final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig()); LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(), connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a"))); pool.submit(() -> { final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext); Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() { @Override public void onSuccess(@Nullable final Collection<SgtInfo> result) { final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0); LOG.debug("ise harvest finished, outcome: {}", counter); storeOutcome(true, counter, null); } @Override public void onFailure(final Throwable t) { LOG.debug("ise harvest failed", t); storeOutcome(false, 0, t.getMessage()); } }, MoreExecutors.directExecutor()); try { harvestResult.get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.debug("failed to finish ise-sgt-harvest task properly on time", e); } }); } else { LOG.debug("Ise-source config removed"); } } } }
GbpIseConfigListenerImpl implements GbpIseConfigListener { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection) { for (DataTreeModification<IseSourceConfig> modification : collection) { final IseSourceConfig iseSourceConfig = modification.getRootNode().getDataAfter(); final IseContext iseContext = new IseContext(iseSourceConfig); templateProviderFacade.assignIseContext(iseContext); if (iseSourceConfig != null) { final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig()); LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(), connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a"))); pool.submit(() -> { final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext); Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() { @Override public void onSuccess(@Nullable final Collection<SgtInfo> result) { final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0); LOG.debug("ise harvest finished, outcome: {}", counter); storeOutcome(true, counter, null); } @Override public void onFailure(final Throwable t) { LOG.debug("ise harvest failed", t); storeOutcome(false, 0, t.getMessage()); } }, MoreExecutors.directExecutor()); try { harvestResult.get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.debug("failed to finish ise-sgt-harvest task properly on time", e); } }); } else { LOG.debug("Ise-source config removed"); } } } GbpIseConfigListenerImpl(@Nonnull final DataBroker dataBroker, @Nonnull final GbpIseSgtHarvester gbpIseSgtHarvester,
                                    @Nonnull final EPPolicyTemplateProviderFacade templateProviderFacade); }
GbpIseConfigListenerImpl implements GbpIseConfigListener { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection) { for (DataTreeModification<IseSourceConfig> modification : collection) { final IseSourceConfig iseSourceConfig = modification.getRootNode().getDataAfter(); final IseContext iseContext = new IseContext(iseSourceConfig); templateProviderFacade.assignIseContext(iseContext); if (iseSourceConfig != null) { final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig()); LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(), connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a"))); pool.submit(() -> { final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext); Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() { @Override public void onSuccess(@Nullable final Collection<SgtInfo> result) { final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0); LOG.debug("ise harvest finished, outcome: {}", counter); storeOutcome(true, counter, null); } @Override public void onFailure(final Throwable t) { LOG.debug("ise harvest failed", t); storeOutcome(false, 0, t.getMessage()); } }, MoreExecutors.directExecutor()); try { harvestResult.get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.debug("failed to finish ise-sgt-harvest task properly on time", e); } }); } else { LOG.debug("Ise-source config removed"); } } } GbpIseConfigListenerImpl(@Nonnull final DataBroker dataBroker, @Nonnull final GbpIseSgtHarvester gbpIseSgtHarvester,
                                    @Nonnull final EPPolicyTemplateProviderFacade templateProviderFacade); @Override void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection); @Override void close(); }
GbpIseConfigListenerImpl implements GbpIseConfigListener { @Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection) { for (DataTreeModification<IseSourceConfig> modification : collection) { final IseSourceConfig iseSourceConfig = modification.getRootNode().getDataAfter(); final IseContext iseContext = new IseContext(iseSourceConfig); templateProviderFacade.assignIseContext(iseContext); if (iseSourceConfig != null) { final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig()); LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(), connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a"))); pool.submit(() -> { final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext); Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() { @Override public void onSuccess(@Nullable final Collection<SgtInfo> result) { final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0); LOG.debug("ise harvest finished, outcome: {}", counter); storeOutcome(true, counter, null); } @Override public void onFailure(final Throwable t) { LOG.debug("ise harvest failed", t); storeOutcome(false, 0, t.getMessage()); } }, MoreExecutors.directExecutor()); try { harvestResult.get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.debug("failed to finish ise-sgt-harvest task properly on time", e); } }); } else { LOG.debug("Ise-source config removed"); } } } GbpIseConfigListenerImpl(@Nonnull final DataBroker dataBroker, @Nonnull final GbpIseSgtHarvester gbpIseSgtHarvester,
                                    @Nonnull final EPPolicyTemplateProviderFacade templateProviderFacade); @Override void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<IseSourceConfig>> collection); @Override void close();  }