+ public ListenableFuture<Void> stopClusterServices() {
+ if (CONTEXT_STATE.TERMINATION.equals(this.state)) {
+ return Futures.immediateCancelledFuture();
+ }
+
+ return Futures.transform(Futures.immediateFuture(null), new Function<Object, Void>() {
+ @Nullable
+ @Override
+ public Void apply(@Nullable Object input) {
+ for (final Iterator<Entry<Class<?>, RoutedRpcRegistration<?>>> iterator = Iterators
+ .consumingIterator(rpcRegistrations.entrySet().iterator()); iterator.hasNext(); ) {
+ final RoutedRpcRegistration<?> rpcRegistration = iterator.next().getValue();
+ rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier);
+ rpcRegistration.close();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Closing RPC Registration of service {} for device {}.", rpcRegistration.getServiceType().getSimpleName(),
+ nodeInstanceIdentifier.getKey().getId().getValue());
+ }
+ }
+
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public boolean onContextInstantiateService(final MastershipChangeListener mastershipChangeListener) {
+