| | |
| | | */ |
| | | package org.opends.admin.ads; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages |
| | | .INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER; |
| | | import static org.opends.messages.QuickSetupMessages |
| | | .INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | import org.opends.admin.ads.util.ServerLoader; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * This class allows to read the configuration of the different servers that are |
| | | * registered in a given ADS server. It provides a read only view of the |
| | |
| | | */ |
| | | private void readReplicationMonitoring() |
| | | { |
| | | Set<ReplicaDescriptor> replicasToUpdate = new HashSet<ReplicaDescriptor>(); |
| | | for (ServerDescriptor server : getServers()) |
| | | { |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (replica.isReplicated()) |
| | | { |
| | | replicasToUpdate.add(replica); |
| | | } |
| | | } |
| | | } |
| | | Set<ReplicaDescriptor> replicasToUpdate = getReplicasToUpdate(); |
| | | for (ServerDescriptor server : getServers()) |
| | | { |
| | | if (server.isReplicationServer()) |
| | |
| | | // If is replication server, then at least we were able to read the |
| | | // configuration, so assume that we might be able to read monitoring |
| | | // (even if an exception occurred before). |
| | | Set<ReplicaDescriptor> candidateReplicas = |
| | | new HashSet<ReplicaDescriptor>(); |
| | | // It contains replication information: analyze it. |
| | | String repServer = server.getReplicationServerHostPort(); |
| | | for (SuffixDescriptor suffix : getSuffixes()) |
| | | { |
| | | Set<String> repServers = suffix.getReplicationServers(); |
| | | for (String r : repServers) |
| | | { |
| | | if (r.equalsIgnoreCase(repServer)) |
| | | { |
| | | candidateReplicas.addAll(suffix.getReplicas()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | Set<ReplicaDescriptor> candidateReplicas = getCandidateReplicas(server); |
| | | if (!candidateReplicas.isEmpty()) |
| | | { |
| | | Set<ReplicaDescriptor> updatedReplicas = |
| | | new HashSet<ReplicaDescriptor>(); |
| | | Set<ReplicaDescriptor> updatedReplicas = new HashSet<ReplicaDescriptor>(); |
| | | try |
| | | { |
| | | updateReplicas(server, candidateReplicas, updatedReplicas); |
| | |
| | | } |
| | | } |
| | | |
| | | private Set<ReplicaDescriptor> getReplicasToUpdate() |
| | | { |
| | | Set<ReplicaDescriptor> replicasToUpdate = new HashSet<ReplicaDescriptor>(); |
| | | for (ServerDescriptor server : getServers()) |
| | | { |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (replica.isReplicated()) |
| | | { |
| | | replicasToUpdate.add(replica); |
| | | } |
| | | } |
| | | } |
| | | return replicasToUpdate; |
| | | } |
| | | |
| | | private Set<ReplicaDescriptor> getCandidateReplicas(ServerDescriptor server) |
| | | { |
| | | Set<ReplicaDescriptor> candidateReplicas = new HashSet<ReplicaDescriptor>(); |
| | | // It contains replication information: analyze it. |
| | | String repServer = server.getReplicationServerHostPort(); |
| | | for (SuffixDescriptor suffix : getSuffixes()) |
| | | { |
| | | if (containsIgnoreCase(suffix.getReplicationServers(), repServer)) |
| | | { |
| | | candidateReplicas.addAll(suffix.getReplicas()); |
| | | } |
| | | } |
| | | return candidateReplicas; |
| | | } |
| | | |
| | | private boolean containsIgnoreCase(Set<String> col, String toFind) |
| | | { |
| | | for (String s : col) |
| | | { |
| | | if (s.equalsIgnoreCase(toFind)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Sets the list of LDAP URLs and connection type that are preferred to be |
| | | * used to connect to the servers. When we have a server to which we can |
| | |
| | | */ |
| | | public Set<ServerDescriptor> getServers() |
| | | { |
| | | HashSet<ServerDescriptor> copy = new HashSet<ServerDescriptor>(); |
| | | copy.addAll(servers); |
| | | return copy; |
| | | return new HashSet<ServerDescriptor>(servers); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public Set<SuffixDescriptor> getSuffixes() |
| | | { |
| | | HashSet<SuffixDescriptor> copy = new HashSet<SuffixDescriptor>(); |
| | | copy.addAll(suffixes); |
| | | return copy; |
| | | return new HashSet<SuffixDescriptor>(suffixes); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | break; |
| | | case GENERIC_CREATING_CONNECTION: |
| | | if ((e.getCause() != null) |
| | | && Utils.isCertificateException(e.getCause())) |
| | | if (Utils.isCertificateException(e.getCause())) |
| | | { |
| | | exceptionMsgs.add( |
| | | INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get( |
| | |
| | | { |
| | | try |
| | | { |
| | | replica.setMissingChanges(new Integer(s)); |
| | | replica.setMissingChanges(Integer.valueOf(s)); |
| | | } |
| | | catch (Throwable t) |
| | | { |