Reorganises the list of read servers based on current master / write server and list of available servers.
330684
protected synchronized void refreshServers() {
        StringBuilder refreshResult = new StringBuilder();
        Set<Server> availableReadServers = new HashSet<>();
        Server[] newReadServers;

        if (writeServer == null || !writeServer.isAvailable()) {
            logger.debug("[refreshServers] write server is null or not available");

            for (Server server : SERVERS) {
                if (server.isAvailable() && server.isMaster()) {
                    writeServer = server;
                    logger.debug("[refreshServers] new writeServer: id = {}, uri = {}", writeServer.getId(), writeServer.getManagementUri());
                }
            }

            if (writeServer == null) {
                readServers = new Server[0];
                return;
            }
        }

        for (Server server : SERVERS) {
            logger.debug("[refreshServers] server: id = {}, isAvailable = {}", server.getId(), server.isAvailable());

            if (!server.getId().equals(writeServer.getId()) && server.isAvailable()) {
                logger.debug("[refreshServers] add read server");
                availableReadServers.add(server);
            }
        }

        if (availableReadServers.size() == 0) {
            logger.debug("[refreshServers] available read servers = 0");

            newReadServers = new Server[1];
            newReadServers[0] = writeServer;

            refreshResult
                    .append("refreshServers: read servers = ")
                    .append(writeServer.getId())
                    .append("=>")
                    .append(writeServer.getManagementUri())
                    .append(", write servers = ")
                    .append(writeServer.getId())
                    .append("=>")
                    .append(writeServer.getManagementUri());
        }
        else {
            logger.debug("[refreshServers] available read servers = {}", availableReadServers.size());

            newReadServers = new Server[availableReadServers.size()];
            int i = 0;

            refreshResult.append("refreshServers: read servers = [");

            for (Server server : availableReadServers) {
                newReadServers[i++] = server;

                refreshResult
                        .append(server.getId())
                        .append("=>")
                        .append(server.getManagementUri())
                        .append(" ");
            }

            refreshResult
                    .append(", write servers = ")
                    .append(writeServer.getId())
                    .append("=>")
                    .append(writeServer.getManagementUri())
                    .append("]");
        }

        readServers = newReadServers;

        logger.debug("[refreshServers] {}", refreshResult.toString());
    }
1336412
private void replaceWithFinishedReaders(List<SSTableReader> finished)
    {
        if (isOffline)
        {
            for (SSTableReader reader : discard)
            {
                if (reader.getCurrentReplacement() == reader)
                    reader.markObsolete();
                reader.selfRef().release();
            }
        }
        else
        {
            dataTracker.replaceEarlyOpenedFiles(discard, finished);
            dataTracker.unmarkCompacting(discard);
        }
        discard.clear();
    }
757535
def cli(env, sortby, datacenter):
    """"""
    block_manager = SoftLayer.BlockStorageManager(env.client)
    mask = "mask[serviceResource[datacenter[name]],"\
           "replicationPartners[serviceResource[datacenter[name]]]]"
    block_volumes = block_manager.list_block_volumes(datacenter=datacenter,
                                                     mask=mask)

    # cycle through all block volumes and count datacenter occurences.
    datacenters = dict()
    for volume in block_volumes:
        service_resource = volume['serviceResource']
        if 'datacenter' in service_resource:
            datacenter_name = service_resource['datacenter']['name']
            if datacenter_name not in datacenters.keys():
                datacenters[datacenter_name] = 1
            else:
                datacenters[datacenter_name] += 1

    table = formatting.KeyValueTable(DEFAULT_COLUMNS)
    table.sortby = sortby
    for datacenter_name in datacenters:
        table.add_row([datacenter_name, datacenters[datacenter_name]])
    env.fout(table)
259344
public void setServers(java.util.Collection<ListedServer> servers) {
        if (servers == null) {
            this.servers = null;
            return;
        }

        this.servers = new java.util.ArrayList<ListedServer>(servers);
    }
83567
protected Map<String, AbstractServer> createServices(ServerSetup[] config, Managers mgr) {
        Map<String, AbstractServer> srvc = new HashMap<>();
        for (ServerSetup setup : config) {
            if (srvc.containsKey(setup.getProtocol())) {
                throw new IllegalArgumentException("Server '" + setup.getProtocol() + "' was found at least twice in the array");
            }
            final String protocol = setup.getProtocol();
            if (protocol.startsWith(ServerSetup.PROTOCOL_SMTP)) {
                srvc.put(protocol, new SmtpServer(setup, mgr));
            } else if (protocol.startsWith(ServerSetup.PROTOCOL_POP3)) {
                srvc.put(protocol, new Pop3Server(setup, mgr));
            } else if (protocol.startsWith(ServerSetup.PROTOCOL_IMAP)) {
                srvc.put(protocol, new ImapServer(setup, mgr));
            }
        }
        return srvc;
    }
157005
private void clean(ArtifactoryCollector collector, List<ArtifactoryRepo> existingRepos) {
        // find the server url's to collect from
        Set<String> serversToBeCollected = new HashSet<>();
        serversToBeCollected.addAll(collector.getArtifactoryServers());

        // find the repos to collect from each server url above
        List<Set<String>> repoNamesToBeCollected = new ArrayList<Set<String>>();
        List<String[]> allRepos = new ArrayList<>();
        artifactorySettings.getServers().forEach(serverSetting -> {
            allRepos.add((String[]) getRepoAndPatternsForServ(serverSetting.getRepoAndPatterns()).keySet().toArray());
        });
        for (int i = 0; i < allRepos.size(); i++) {
            Set<String> reposSet = new HashSet<>();
            if (allRepos.get(i) != null) {
                reposSet.addAll(Arrays.asList(allRepos.get(i)));
            }
            repoNamesToBeCollected.add(reposSet);
        }

        assert (serversToBeCollected.size() == repoNamesToBeCollected.size());

        List<ArtifactoryRepo> stateChangeRepoList = new ArrayList<>();
        for (ArtifactoryRepo repo : existingRepos) {
            if (isRepoEnabledAndNotCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo) ||  // if it was enabled but not to be collected
                    isRepoDisabledAndToBeCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo)) { // OR it was disabled and now is to be collected
                repo.setEnabled(isRepoCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo));
                stateChangeRepoList.add(repo);
            }
        }
        if (!CollectionUtils.isEmpty(stateChangeRepoList)) {
            artifactoryRepoRepository.save(stateChangeRepoList);
        }
    }
491088
def reset(self):
        """"""
        # Need to use self.server_map, in case no Servers are left running.
        for member_id in self.server_map:
            host = self.member_id_to_host(member_id)
            server_id = self._servers.host_to_server_id(host)
            # Reset each member.
            self._servers.command(server_id, 'reset')
        # Wait for all members to have a state of 1, 2, or 7.
        # Note that this also waits for a primary to become available.
        self.waiting_member_state()
        # Wait for Server states to match the config from the primary.
        self.waiting_config_state()
        return self.info()
188727
public void refreshIndexList() throws IOException
   {
      synchronized (updateMonitor)
      {
         // release reader if any
         releaseMultiReader();
         // prepare added/removed sets
         Set<String> newList = new HashSet<String>(indexNames.getNames());

         // remove removed indexes
         Iterator<PersistentIndex> iterator = indexes.iterator();
         while (iterator.hasNext())
         {
            PersistentIndex index = iterator.next();
            String name = index.getName();
            // if current index not in new list, close it, cause it is deleted.
            if (!newList.contains(name))
            {
               index.close();
               iterator.remove();
            }
            else
            {
               // remove from list, cause this segment of index still present and indexes list contains
               // PersistentIndex instance related to this index..
               newList.remove(name);
               // Release everything to make sure that we see the
               // latest changes
               index.releaseWriterAndReaders();
            }
         }
         // now newList contains ONLY new, added indexes, deleted indexes, are removed from list.
         for (String name : newList)
         {
            // only open if it still exists
            // it is possible that indexNames still contains a name for
            // an index that has been deleted, but indexNames has not been
            // written to disk.
            if (!directoryManager.hasDirectory(name))
            {
               LOG.debug("index does not exist anymore: " + name);
               // move on to next index
               continue;
            }
            PersistentIndex index =
               new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
                  modeHandler);
            index.setMaxFieldLength(handler.getMaxFieldLength());
            index.setUseCompoundFile(handler.getUseCompoundFile());
            index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
            indexes.add(index);
         }
          // Reset the volatile index to be exactly like the master
          resetVolatileIndex();
      }
   }
298489
private static void resetHostList(Listener listener, Deque<HostAddress> loopAddresses) {
    //if all servers have been connected without result
    //add back all servers
    List<HostAddress> servers = new ArrayList<>();
    servers.addAll(listener.getUrlParser().getHostAddresses());
    Collections.shuffle(servers);

    loopAddresses.clear();
    loopAddresses.addAll(servers);
  }
763204
public List<Server> getEligibleServers(List<Server> servers, Object loadBalancerKey) {
        if (loadBalancerKey == null) {
            return ImmutableList.copyOf(Iterables.filter(servers, this.getServerOnlyPredicate()));            
        } else {
            List<Server> results = Lists.newArrayList();
            for (Server server: servers) {
                if (this.apply(new PredicateKey(loadBalancerKey, server))) {
                    results.add(server);
                }
            }
            return results;            
        }
    }
298309
function(servers, options) {
  this.servers = servers;
  this.seq = 0;
  this.options = merge(options || {},
      {failoverTime: 60, retries: 2, retry_delay: 0.2, expires: 0, logger: console});
}
559840
public void add(Collection<Server> servers)
    {
        for(Server server : servers)
            this.servers.put(server.getId(), server);
    }
882906
def remove_server(self, name):
        """"""
        for i in self._server_list:
            if i['key'] == name:
                try:
                    self._server_list.remove(i)
                    logger.debug("Remove server %s from the list" % name)
                    logger.debug("Updated servers list (%s servers): %s" % (
                        len(self._server_list), self._server_list))
                except ValueError:
                    logger.error(
                        "Cannot remove server %s from the list" % name)
828288
public OperationFuture<List<Server>> revertToSnapshot(Server... servers) {
        List<Server> serverList = Arrays.asList(servers);

        List<JobFuture> futures = serverList.stream()
            .map(this::findByRef)
            .flatMap(metadata -> metadata.getDetails().getSnapshots().stream())
            .map(snapshot ->
                baseServerResponse(
                    client.revertToSnapshot(snapshot.getServerId(), snapshot.getId())
                )
                .jobFuture()
            )
            .collect(toList());

        return new OperationFuture<>(
            serverList,
            new ParallelJobsFuture(futures)
        );
    }
127515
def servers(self):
        """"""
        self.__init()
        items = []
        for k,v in self._json_dict.items():
            if k == "servers":
                for s in v:
                    if 'id' in s:
                        url = "%s/%s" % (self.root, s['id'])
                        items.append(
                            self.Server(url=url,
                                        securityHandler=self._securityHandler,
                                        proxy_url=self._proxy_url,
                                        proxy_port=self._proxy_port))
            del k,v
        return items
439770
def sort_available_networks(available_networks)
      available_networks.sort_by { |nwrk| nwrk.network.address.split(".").map(&:to_i) }
    end
919640
public void setServerGroupReplicationConfigurations(java.util.Collection<ServerGroupReplicationConfiguration> serverGroupReplicationConfigurations) {
        if (serverGroupReplicationConfigurations == null) {
            this.serverGroupReplicationConfigurations = null;
            return;
        }

        this.serverGroupReplicationConfigurations = new java.util.ArrayList<ServerGroupReplicationConfiguration>(serverGroupReplicationConfigurations);
    }