| | |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | ReplicaDescriptor replica = new ReplicaDescriptor(); |
| | | replica.setReplicationId( |
| | | baseDN.getType() == BaseDNDescriptor.Type.REPLICATED ? baseDN.getReplicaID() : -1); |
| | | replica.setServerId(baseDN.getType() == BaseDNDescriptor.Type.REPLICATED ? baseDN.getReplicaID() : -1); |
| | | replica.setBackendId(backend.getBackendID()); |
| | | replica.setSuffix(new SuffixDescriptor(baseDN.getDn(), replica)); |
| | | |
| | |
| | | addToSets(serverDesc2, uData.getServer2(), conn2, twoReplServers, usedReplicationServerIds); |
| | | |
| | | final Map<DN, Set<HostPort>> hmRepServers = new HashMap<>(); |
| | | final Map<DN, Set<Integer>> hmUsedReplicationDomainIds = new HashMap<>(); |
| | | final Map<DN, Set<Integer>> hmUsedReplicaServerIds = new HashMap<>(); |
| | | for (DN baseDN : uData.getBaseDNs()) |
| | | { |
| | | Set<HostPort> repServersForBaseDN = new LinkedHashSet<>(); |
| | |
| | | repServersForBaseDN.addAll(twoReplServers); |
| | | hmRepServers.put(baseDN, repServersForBaseDN); |
| | | |
| | | Set<Integer> ids = new HashSet<>(); |
| | | addReplicationDomainIds(ids, serverDesc1, baseDN); |
| | | addReplicationDomainIds(ids, serverDesc2, baseDN); |
| | | Set<Integer> replicaServerIds = new HashSet<>(); |
| | | addReplicaServerIds(replicaServerIds, serverDesc1, baseDN); |
| | | addReplicaServerIds(replicaServerIds, serverDesc2, baseDN); |
| | | if (cache1 != null) |
| | | { |
| | | for (ServerDescriptor server : cache1.getServers()) |
| | | { |
| | | addReplicationDomainIds(ids, server, baseDN); |
| | | addReplicaServerIds(replicaServerIds, server, baseDN); |
| | | } |
| | | } |
| | | if (cache2 != null) |
| | | { |
| | | for (ServerDescriptor server : cache2.getServers()) |
| | | { |
| | | addReplicationDomainIds(ids, server, baseDN); |
| | | addReplicaServerIds(replicaServerIds, server, baseDN); |
| | | } |
| | | } |
| | | hmUsedReplicationDomainIds.put(baseDN, ids); |
| | | hmUsedReplicaServerIds.put(baseDN, replicaServerIds); |
| | | } |
| | | |
| | | final Set<HostPort> allRepServers = new LinkedHashSet<>(); |
| | |
| | | for (DN baseDN : uData.getBaseDNs()) |
| | | { |
| | | Set<HostPort> repServers = hmRepServers.get(baseDN); |
| | | Set<Integer> usedIds = hmUsedReplicationDomainIds.get(baseDN); |
| | | Set<Integer> usedIds = hmUsedReplicaServerIds.get(baseDN); |
| | | Set<String> alreadyConfiguredServers = new HashSet<>(); |
| | | |
| | | configureToReplicateBaseDN(uData.getServer1(), conn1, serverDesc1, cache1, baseDN, |
| | |
| | | } |
| | | } |
| | | |
| | | private void addReplicationDomainIds(Set<Integer> replicationIds, ServerDescriptor serverDesc1, DN baseDN) |
| | | private void addReplicaServerIds(Set<Integer> replicaServerIds, ServerDescriptor serverDesc1, DN baseDN) |
| | | { |
| | | ReplicaDescriptor replica = findReplicaForSuffixDN(serverDesc1.getReplicas(), baseDN); |
| | | if (replica != null && replica.isReplicated()) |
| | | { |
| | | replicationIds.add(replica.getReplicationId()); |
| | | replicaServerIds.add(replica.getServerId()); |
| | | } |
| | | } |
| | | |
| | |
| | | tableBuilder.appendCell(fromBoolean(replica.isReplicationEnabled())); |
| | | |
| | | // DS instance ID |
| | | tableBuilder.appendCell(fromInt(replica.getReplicationId())); |
| | | tableBuilder.appendCell(fromInt(replica.getServerId())); |
| | | |
| | | // RS ID and port. |
| | | if (replicaServer.isReplicationServer()) |
| | |
| | | * the base DN of the replication domain to configure. |
| | | * @param replicationServers |
| | | * the list of replication servers to which the replication domain will communicate with. |
| | | * @param usedReplicationDomainIds |
| | | * @param usedReplicaServerIds |
| | | * the set of replication domain IDs that are already in use. The set will be updated |
| | | * with the replication ID that will be used by the newly configured replication server. |
| | | * @throws OpenDsException |
| | |
| | | private void configureToReplicateBaseDN(ConnectionWrapper conn, |
| | | DN baseDN, |
| | | Set<HostPort> replicationServers, |
| | | Set<Integer> usedReplicationDomainIds) throws Exception |
| | | Set<Integer> usedReplicaServerIds) throws Exception |
| | | { |
| | | Set<String> replicationServersLC = toLowerCaseStrings(replicationServers); |
| | | |
| | |
| | | boolean mustCommit = false; |
| | | if (domain == null) |
| | | { |
| | | int domainId = InstallerHelper.getReplicationId(usedReplicationDomainIds); |
| | | usedReplicationDomainIds.add(domainId); |
| | | int replicaServerId = InstallerHelper.getReplicationId(usedReplicaServerIds); |
| | | usedReplicaServerIds.add(replicaServerId); |
| | | String domainName = InstallerHelper.getDomainName(domainNames, baseDN); |
| | | domain = sync.createReplicationDomain( |
| | | ReplicationDomainCfgDefn.getInstance(), domainName, |
| | | null); |
| | | domain.setServerId(domainId); |
| | | domain.setServerId(replicaServerId); |
| | | domain.setBaseDN(baseDN); |
| | | domain.setReplicationServer(replicationServersLC); |
| | | mustCommit = true; |
| | |
| | | ReplicaDescriptor replica = findReplicaForSuffixDN(source.getReplicas(), baseDN); |
| | | if (replica != null) |
| | | { |
| | | replicationId = replica.getReplicationId(); |
| | | replicationId = replica.getServerId(); |
| | | } |
| | | } |
| | | catch (IOException ne) |
| | |
| | | return false; |
| | | } |
| | | |
| | | int domain1Id = replica1.getReplicationId(); |
| | | int domain1Id = replica1.getServerId(); |
| | | for (ReplicaDescriptor replica2 : suffix2.getReplicas()) |
| | | { |
| | | if (replica2.isReplicated() |
| | | && domain1Id == replica2.getReplicationId()) |
| | | && domain1Id == replica2.getServerId()) |
| | | { |
| | | commonDomainIDErrors.add( |
| | | ERR_REPLICATION_ENABLE_COMMON_DOMAIN_ID_ARG.get(replica1.getServer().getHostPort(true), suffix1DN, |