| | |
| | | if (replica != null) |
| | | { |
| | | final String backendNameKey = getOrAddBackend(hmBackendSuffix, replica.getBackendName()); |
| | | hmBackendSuffix.get(backendNameKey).add(suffix.getDN()); |
| | | hmBackendSuffix.get(backendNameKey).add(suffix.getDN().toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * as the set of ADS suffix replicas (all instances hosting the replication |
| | | * server also replicate ADS). |
| | | */ |
| | | Map<String, Set<String>> replicationServers = new HashMap<>(); |
| | | Map<DN, Set<String>> replicationServers = new HashMap<>(); |
| | | Set<String> adsServers = new HashSet<>(); |
| | | |
| | | if (getUserData().getReplicationOptions().getType() == DataReplicationOptions.Type.FIRST_IN_TOPOLOGY) |
| | |
| | | Set<String> h = new HashSet<>(); |
| | | h.add(getLocalReplicationServer()); |
| | | adsServers.add(getLocalReplicationServer()); |
| | | for (String dn : baseDns) |
| | | for (String dnStr : baseDns) |
| | | { |
| | | replicationServers.put(dn, h); |
| | | replicationServers.put(DN.valueOf(dnStr), h); |
| | | } |
| | | } |
| | | else |
| | |
| | | logger.warn(LocalizableMessage.raw("Could not find replication port for: " + getHostPort(server))); |
| | | } |
| | | } |
| | | Set<String> dns = new HashSet<>(); |
| | | Set<DN> dns = new HashSet<>(); |
| | | for (ReplicaDescriptor replica : hm.get(server)) |
| | | { |
| | | dns.add(replica.getSuffix().getDN()); |
| | | } |
| | | dns.add(ADSContext.getAdministrationSuffixDN()); |
| | | dns.add(Constants.SCHEMA_DN); |
| | | Map<String, Set<String>> remoteReplicationServers = new HashMap<>(); |
| | | for (String dn : dns) |
| | | Map<DN, Set<String>> remoteReplicationServers = new HashMap<>(); |
| | | for (DN dn : dns) |
| | | { |
| | | Set<String> repServer = replicationServers.get(dn); |
| | | if (repServer == null) |
| | | { |
| | | // Do the comparison manually |
| | | for (String dn1 : replicationServers.keySet()) |
| | | for (DN dn1 : replicationServers.keySet()) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (dn.equals(dn1)) |
| | | { |
| | | repServer = replicationServers.get(dn1); |
| | | dn = dn1; |
| | |
| | | } |
| | | |
| | | Set<SuffixDescriptor> suffixes = getUserData().getSuffixesToReplicateOptions().getSuffixes(); |
| | | DN adminSuffixDn = ADSContext.getAdministrationSuffixDN(); |
| | | DN schemaDn = Constants.SCHEMA_DN; |
| | | |
| | | /* Initialize local ADS and schema contents using any replica. */ |
| | | { |
| | |
| | | { |
| | | TopologyCacheFilter filter = new TopologyCacheFilter(); |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.addBaseDNToSearch(ADSContext.getAdministrationSuffixDN()); |
| | | filter.addBaseDNToSearch(Constants.SCHEMA_DN); |
| | | filter.addBaseDNToSearch(adminSuffixDn.toString()); |
| | | filter.addBaseDNToSearch(schemaDn.toString()); |
| | | ServerDescriptor s = createStandalone(remoteConn, filter); |
| | | for (ReplicaDescriptor replica : s.getReplicas()) |
| | | { |
| | | String dn = replica.getSuffix().getDN(); |
| | | if (areDnsEqual(dn, ADSContext.getAdministrationSuffixDN())) |
| | | DN dn = replica.getSuffix().getDN(); |
| | | if (dn.equals(adminSuffixDn)) |
| | | { |
| | | suffixes.add(replica.getSuffix()); |
| | | } |
| | | else if (areDnsEqual(dn, Constants.SCHEMA_DN)) |
| | | else if (dn.equals(schemaDn)) |
| | | { |
| | | suffixes.add(replica.getSuffix()); |
| | | } |
| | |
| | | |
| | | for (SuffixDescriptor suffix : suffixes) |
| | | { |
| | | String dn = suffix.getDN(); |
| | | DN dn = suffix.getDN(); |
| | | |
| | | ReplicaDescriptor replica = suffix.getReplicas().iterator().next(); |
| | | ServerDescriptor server = replica.getServer(); |
| | | HostPort hostPort = getHostPort(server); |
| | | |
| | | boolean isADS = areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()); |
| | | boolean isSchema = areDnsEqual(dn, Constants.SCHEMA_DN); |
| | | boolean isADS = dn.equals(adminSuffixDn); |
| | | boolean isSchema = dn.equals(schemaDn); |
| | | if (isADS) |
| | | { |
| | | if (isVerbose()) |
| | |
| | | { |
| | | TopologyCacheFilter filter = new TopologyCacheFilter(); |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.addBaseDNToSearch(dn); |
| | | filter.addBaseDNToSearch(dn.toString()); |
| | | ServerDescriptor s = createStandalone(remoteConn, filter); |
| | | for (ReplicaDescriptor r : s.getReplicas()) |
| | | { |
| | | if (areDnsEqual(r.getSuffix().getDN(), dn)) |
| | | if (r.getSuffix().getDN().equals(dn)) |
| | | { |
| | | replicationId = r.getReplicationId(); |
| | | } |
| | |
| | | cause = e.getTrustManager().getLastRefusedCause(); |
| | | } |
| | | logger.info(LocalizableMessage.raw("Certificate exception cause: " + cause)); |
| | | if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED) |
| | | { |
| | | excType = UserDataCertificateException.Type.NOT_TRUSTED; |
| | | } |
| | | else if (cause == ApplicationTrustManager.Cause.HOST_NAME_MISMATCH) |
| | | { |
| | | excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH; |
| | | } |
| | | else |
| | | { |
| | | excType = null; |
| | | } |
| | | excType = toUserDataCertificateExceptionType(cause); |
| | | if (excType != null) |
| | | { |
| | | String h; |
| | |
| | | UserDataCertificateException.Type excType; |
| | | ApplicationTrustManager.Cause cause = trustManager.getLastRefusedCause(); |
| | | logger.info(LocalizableMessage.raw("Certificate exception cause: " + cause)); |
| | | if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED) |
| | | { |
| | | excType = UserDataCertificateException.Type.NOT_TRUSTED; |
| | | } |
| | | else if (cause == ApplicationTrustManager.Cause.HOST_NAME_MISMATCH) |
| | | { |
| | | excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH; |
| | | } |
| | | else |
| | | { |
| | | excType = null; |
| | | } |
| | | |
| | | excType = toUserDataCertificateExceptionType(cause); |
| | | if (excType != null) |
| | | { |
| | | throw new UserDataCertificateException(Step.REPLICATION_OPTIONS, INFO_CERTIFICATE_EXCEPTION.get(host, port), |
| | |
| | | } |
| | | } |
| | | |
| | | private UserDataCertificateException.Type toUserDataCertificateExceptionType(ApplicationTrustManager.Cause cause) |
| | | { |
| | | switch (cause) |
| | | { |
| | | case NOT_TRUSTED: |
| | | return UserDataCertificateException.Type.NOT_TRUSTED; |
| | | case HOST_NAME_MISMATCH: |
| | | return UserDataCertificateException.Type.HOST_NAME_MISMATCH; |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private ConnectionWrapper newConnectionWrapper(String dn, String pwd, String[] effectiveDn, HostPort hostPort, |
| | | ApplicationTrustManager trustManager) throws Throwable |
| | | { |
| | |
| | | throw t; |
| | | } |
| | | // Try using a global administrator |
| | | dn = ADSContext.getAdministratorDN(dn); |
| | | dn = ADSContext.getAdministratorDN(dn).toString(); |
| | | effectiveDn[0] = dn; |
| | | return new ConnectionWrapper(hostPort, LDAPS, dn, pwd, getConnectTimeout(), trustManager); |
| | | } |
| | |
| | | * @throws PeerNotFoundException |
| | | * if the replication mechanism cannot find a peer. |
| | | */ |
| | | public void initializeSuffix(ConnectionWrapper conn, int replicaId, String suffixDn, boolean displayProgress, |
| | | public void initializeSuffix(ConnectionWrapper conn, int replicaId, DN suffixDn, boolean displayProgress, |
| | | HostPort sourceServerDisplay) throws ApplicationException, PeerNotFoundException |
| | | { |
| | | boolean taskCreated = false; |
| | |
| | | AddRequest addRequest = newAddRequest(dn) |
| | | .addAttribute("objectclass", "top", "ds-task", "ds-task-initialize-from-remote-replica") |
| | | .addAttribute("ds-task-class-name", "org.opends.server.tasks.InitializeTask") |
| | | .addAttribute("ds-task-initialize-domain-dn", suffixDn) |
| | | .addAttribute("ds-task-initialize-domain-dn", suffixDn.toString()) |
| | | .addAttribute("ds-task-initialize-replica-server-id", String.valueOf(replicaId)); |
| | | while (!taskCreated) |
| | | { |
| | |
| | | return getUserData().getHostName() + ":" + getUserData().getReplicationOptions().getReplicationPort(); |
| | | } |
| | | |
| | | private void resetGenerationId(ConnectionWrapper conn, String suffixDn, HostPort sourceServerDisplay) |
| | | private void resetGenerationId(ConnectionWrapper conn, DN suffixDn, HostPort sourceServerDisplay) |
| | | throws ApplicationException |
| | | { |
| | | boolean taskCreated = false; |
| | |
| | | AddRequest addRequest = newAddRequest(dn) |
| | | .addAttribute("objectclass", "top", "ds-task", "ds-task-reset-generation-id") |
| | | .addAttribute("ds-task-class-name", "org.opends.server.tasks.SetGenerationIdTask") |
| | | .addAttribute("ds-task-reset-generation-id-domain-base-dn", suffixDn); |
| | | .addAttribute("ds-task-reset-generation-id-domain-base-dn", suffixDn.toString()); |
| | | while (!taskCreated) |
| | | { |
| | | checkAbort(); |