@Test public void closeServiceInstance() throws Exception { Mockito.when(dataBroker.registerDataTreeChangeListener(SxpClusterRouteManager.ROUTING_DEFINITION_DT_IDENTIFIER, manager)).thenReturn(listenerRegistration); manager.init(); Assert.assertEquals(RouteListenerState.STOPPED, manager.getState()); manager.instantiateServiceInstance(); Assert.assertEquals(RouteListenerState.BEFORE_FIRST, manager.getState()); manager.closeServiceInstance(); Mockito.verify(cssProvider).registerClusterSingletonService(manager); Mockito.verify(dataBroker) .registerDataTreeChangeListener(SxpClusterRouteManager.ROUTING_DEFINITION_DT_IDENTIFIER, manager); Mockito.verify(listenerRegistration).close(); Mockito.verify(routeReactor).wipeRouting(); Assert.assertEquals(RouteListenerState.STOPPED, manager.getState()); }
@Override public ListenableFuture<Void> closeServiceInstance() { LOG.info("Clustering provider closed service for {}", this.getClass().getSimpleName()); final FluentFuture<? extends CommitInfo> routingOutcome; synchronized (stateLock) { state = RouteListenerState.STOPPED; routingDefinitionListenerRegistration.close(); routingOutcome = routeReactor.wipeRouting(); Futures.addCallback(routingOutcome, LOGGING_CALLBACK); } final SettableFuture<Void> outputFuture = SettableFuture.create(); Futures.addCallback(routingOutcome, new FutureCallback<CommitInfo>() { @Override public void onSuccess(CommitInfo result) { outputFuture.set(null); } @Override public void onFailure(Throwable t) { outputFuture.setException(t); } }); return outputFuture; }
SxpClusterRouteManager implements ClusteredDataTreeChangeListener<SxpClusterRoute>, ClusterSingletonService, AutoCloseable { @Override public ListenableFuture<Void> closeServiceInstance() { LOG.info("Clustering provider closed service for {}", this.getClass().getSimpleName()); final FluentFuture<? extends CommitInfo> routingOutcome; synchronized (stateLock) { state = RouteListenerState.STOPPED; routingDefinitionListenerRegistration.close(); routingOutcome = routeReactor.wipeRouting(); Futures.addCallback(routingOutcome, LOGGING_CALLBACK); } final SettableFuture<Void> outputFuture = SettableFuture.create(); Futures.addCallback(routingOutcome, new FutureCallback<CommitInfo>() { @Override public void onSuccess(CommitInfo result) { outputFuture.set(null); } @Override public void onFailure(Throwable t) { outputFuture.setException(t); } }); return outputFuture; } }
SxpClusterRouteManager implements ClusteredDataTreeChangeListener<SxpClusterRoute>, ClusterSingletonService, AutoCloseable { @Override public ListenableFuture<Void> closeServiceInstance() { LOG.info("Clustering provider closed service for {}", this.getClass().getSimpleName()); final FluentFuture<? extends CommitInfo> routingOutcome; synchronized (stateLock) { state = RouteListenerState.STOPPED; routingDefinitionListenerRegistration.close(); routingOutcome = routeReactor.wipeRouting(); Futures.addCallback(routingOutcome, LOGGING_CALLBACK); } final SettableFuture<Void> outputFuture = SettableFuture.create(); Futures.addCallback(routingOutcome, new FutureCallback<CommitInfo>() { @Override public void onSuccess(CommitInfo result) { outputFuture.set(null); } @Override public void onFailure(Throwable t) { outputFuture.setException(t); } }); return outputFuture; } SxpClusterRouteManager(final DataBroker dataBroker, final ClusterSingletonServiceProvider cssProvider,
            final RouteReactor routeReactor); }
SxpClusterRouteManager implements ClusteredDataTreeChangeListener<SxpClusterRoute>, ClusterSingletonService, AutoCloseable { @Override public ListenableFuture<Void> closeServiceInstance() { LOG.info("Clustering provider closed service for {}", this.getClass().getSimpleName()); final FluentFuture<? extends CommitInfo> routingOutcome; synchronized (stateLock) { state = RouteListenerState.STOPPED; routingDefinitionListenerRegistration.close(); routingOutcome = routeReactor.wipeRouting(); Futures.addCallback(routingOutcome, LOGGING_CALLBACK); } final SettableFuture<Void> outputFuture = SettableFuture.create(); Futures.addCallback(routingOutcome, new FutureCallback<CommitInfo>() { @Override public void onSuccess(CommitInfo result) { outputFuture.set(null); } @Override public void onFailure(Throwable t) { outputFuture.setException(t); } }); return outputFuture; } SxpClusterRouteManager(final DataBroker dataBroker, final ClusterSingletonServiceProvider cssProvider,
            final RouteReactor routeReactor); void init(); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<SxpClusterRoute>> changes); @Override ServiceGroupIdentifier getIdentifier(); @Override void instantiateServiceInstance(); @Override ListenableFuture<Void> closeServiceInstance(); @Override void close(); }
SxpClusterRouteManager implements ClusteredDataTreeChangeListener<SxpClusterRoute>, ClusterSingletonService, AutoCloseable { @Override public ListenableFuture<Void> closeServiceInstance() { LOG.info("Clustering provider closed service for {}", this.getClass().getSimpleName()); final FluentFuture<? extends CommitInfo> routingOutcome; synchronized (stateLock) { state = RouteListenerState.STOPPED; routingDefinitionListenerRegistration.close(); routingOutcome = routeReactor.wipeRouting(); Futures.addCallback(routingOutcome, LOGGING_CALLBACK); } final SettableFuture<Void> outputFuture = SettableFuture.create(); Futures.addCallback(routingOutcome, new FutureCallback<CommitInfo>() { @Override public void onSuccess(CommitInfo result) { outputFuture.set(null); } @Override public void onFailure(Throwable t) { outputFuture.setException(t); } }); return outputFuture; } SxpClusterRouteManager(final DataBroker dataBroker, final ClusterSingletonServiceProvider cssProvider,
            final RouteReactor routeReactor); void init(); @Override void onDataTreeChanged(@Nonnull Collection<DataTreeModification<SxpClusterRoute>> changes); @Override ServiceGroupIdentifier getIdentifier(); @Override void instantiateServiceInstance(); @Override ListenableFuture<Void> closeServiceInstance(); @Override void close();  }