@Override
 public AtomicReference<T> getValueRef() {
   try {
     Map<Node, CommandResponse<AtomicReference<T>>> results = Collections.emptyMap();
     while (results.isEmpty()) {
       if (!SingletonService.this.started) {
         throw new IllegalStateException(
             ClusteringServerLogger.ROOT_LOGGER.notStarted(
                 SingletonService.this.singletonServiceName.getCanonicalName()));
       }
       results =
           SingletonService.this.dispatcher.executeOnCluster(new SingletonValueCommand<T>());
       Iterator<CommandResponse<AtomicReference<T>>> responses = results.values().iterator();
       while (responses.hasNext()) {
         if (responses.next().get() == null) {
           // Prune non-master results
           responses.remove();
         }
       }
       // We expect only 1 result
       int count = results.size();
       if (count > 1) {
         // This would mean there are multiple masters!
         throw ClusteringServerLogger.ROOT_LOGGER.unexpectedResponseCount(
             SingletonService.this.singletonServiceName.getCanonicalName(), count);
       }
       if (count == 0) {
         ClusteringServerLogger.ROOT_LOGGER.noResponseFromMaster(
             SingletonService.this.singletonServiceName.getCanonicalName());
         // Verify whether there is no master because a quorum was not reached during the last
         // election
         if (SingletonService.this.registration.getProviders().size()
             < SingletonService.this.quorum) {
           return new AtomicReference<>();
         }
         // Otherwise, we're in the midst of a new master election, so just try again
         Thread.yield();
       }
     }
     return results.values().iterator().next().get();
   } catch (Exception e) {
     throw new IllegalStateException(e);
   }
 }