opendj-server-legacy/src/main/java/org/opends/admin/ads/ReplicaDescriptor.java
@@ -33,8 +33,8 @@ private int nbEntries = -1; private ServerDescriptor server; private final Set<HostPort> replicationServers = new HashSet<>(); /** This corresponds to the server-id of this replica. */ private int replicationId = -1; /** @see InstallerHelper#getReplicationId(Set) */ private int serverId = -1; private int missingChanges = -1; private long ageOfOldestMissingChange = -1; private String backendId; @@ -51,18 +51,16 @@ /** * Returns whether this replica is replicated or not. * @return <CODE>true</CODE> if the replica is replicated and * <CODE>false</CODE> otherwise. * @return {@code true} if the replica is replicated, {@code false} otherwise. */ public boolean isReplicated() { return replicationId != -1; return serverId != -1; } /** * Returns whether replication is replicated on this server or not. * @return <CODE>true</CODE> if replication is enabled and * <CODE>false</CODE> otherwise. * @return {@code true} if replication is enabled, {@code false} otherwise. */ public boolean isReplicationEnabled() { @@ -146,25 +144,24 @@ } /** * Returns the replication id for the replication domain associated * with this replica. * @return the replication id for the replication domain associated * with this replica. * Returns the server id for the replication domain associated with this replica. * * @return the server id for the replication domain associated with this replica. */ public int getReplicationId() public int getServerId() { return replicationId; return serverId; } /** * Sets the replication id for the replication domain associated * with this replica. * @param replicationId the replication id for the replication domain * associated with this replica. * Sets the server id for the replication domain associated with this replica. * * @param serverId * the server id for the replication domain associated with this replica. */ public void setReplicationId(int replicationId) public void setServerId(int serverId) { this.replicationId = replicationId; this.serverId = serverId; } /** @@ -247,7 +244,7 @@ { return getClass().getSimpleName() + "(domain-name=" + suffix.getDN() + ", server-id=" + replicationId + ", server-id=" + serverId + ", host-name=" + server.getReplicationServerHostPort() + ", nb-entries=" + nbEntries + ", rs-port=" + server.getReplicationServerPort() opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java
@@ -50,7 +50,7 @@ import org.opends.server.types.HostPort; /** * The object of this class represent an OpenDS server instance. * The object of this class represent an OpenDJ server instance. * <p> * It can represent either a DS-only, a RS-only or a combined DS-RS. */ @@ -874,7 +874,7 @@ { SearchResultEntry sr = entryReader.readEntry(); int id = asInteger(sr, "ds-cfg-server-id"); int serverId = asInteger(sr, "ds-cfg-server-id"); Set<HostPort> replicationServers = toHostPorts(asSetOfString(sr, "ds-cfg-replication-server")); Set<DN> dns = asSetOfDN(sr, "ds-cfg-base-dn"); for (DN dn : dns) @@ -883,7 +883,7 @@ { if (replica.getSuffix().getDN().equals(dn)) { replica.setReplicationId(id); replica.setServerId(serverId); replica.setReplicationServers(replicationServers); allReplicationServers.addAll(replicationServers); } opendj-server-legacy/src/main/java/org/opends/admin/ads/TopologyCache.java
@@ -473,7 +473,7 @@ { if (replica.isReplicated() && dn.equals(replica.getSuffix().getDN()) && replica.getReplicationId() == replicaId) && replica.getServerId() == replicaId) { // This statistic is optional. setAgeOfOldestMissingChange(replica, sr); @@ -561,7 +561,7 @@ .append(server.getHostPort(true)).append(",") .append(replica.getEntries()).append(",") .append(isReplEnabled).append(",") .append(replica.getReplicationId()).append(",") .append(replica.getServerId()).append(",") .append(orBlank(server.getReplicationServerId())).append(",") .append(orBlank(server.getReplicationServerPort())).append(",") .append(replica.getMissingChanges()).append(",") opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
@@ -1965,7 +1965,7 @@ notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CONFIGURING_REPLICATION.get())); InstallerHelper helper = new InstallerHelper(); Set<Integer> knownServerIds = new HashSet<>(); Set<Integer> knownReplicaServerIds = new HashSet<>(); Set<Integer> knownReplicationServerIds = new HashSet<>(); if (lastLoadedCache != null) { @@ -1973,7 +1973,7 @@ { for (ReplicaDescriptor replica : suffix.getReplicas()) { knownServerIds.add(replica.getReplicationId()); knownReplicaServerIds.add(replica.getServerId()); } } for (ServerDescriptor server : lastLoadedCache.getServers()) @@ -1992,7 +1992,7 @@ { for (ReplicaDescriptor replica : suffix.getReplicas()) { knownServerIds.add(replica.getReplicationId()); knownReplicaServerIds.add(replica.getServerId()); Object v = replica.getServer().getServerProperties().get(REPLICATION_SERVER_ID); if (v != null) { @@ -2058,7 +2058,7 @@ getUserData().getReplicationOptions().getReplicationPort(), getUserData().getReplicationOptions().useSecureReplication(), knownReplicationServerIds, knownServerIds); knownReplicaServerIds); localTimeMeasureTime = System.currentTimeMillis(); localTime = Utils.getServerClock(conn); localServerDisplay = conn.getHostPort(); @@ -2151,7 +2151,7 @@ { ConfiguredReplication repl = helper.configureReplication( conn, remoteReplicationServers, replicationPort, enableSecureReplication, knownReplicationServerIds, knownServerIds); knownReplicationServerIds, knownReplicaServerIds); long remoteTimeMeasureTime = System.currentTimeMillis(); long remoteTime = Utils.getServerClock(conn); if (localTime != -1 @@ -2525,8 +2525,8 @@ } try { int replicationId = replica.getReplicationId(); if (replicationId == -1) int replicaServerId = replica.getServerId(); if (replicaServerId == -1) { // This occurs if the remote server had not replication configured. try (ConnectionWrapper remoteConn = getRemoteConnection(server)) @@ -2539,7 +2539,7 @@ { if (r.getSuffix().getDN().equals(dn)) { replicationId = r.getReplicationId(); replicaServerId = r.getServerId(); } } } @@ -2549,7 +2549,7 @@ throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, msg, e); } } if (replicationId == -1) if (replicaServerId == -1) { throw new ApplicationException(ReturnCode.APPLICATION_ERROR, ERR_COULD_NOT_FIND_REPLICATIONID.get(dn), null); } @@ -2562,8 +2562,8 @@ { logger.info(LocalizableMessage.raw("Calling initializeSuffix with base DN: " + dn)); logger.info(LocalizableMessage.raw("Try number: " + (6 - nTries))); logger.info(LocalizableMessage.raw("replicationId of source replica: " + replicationId)); initializeSuffix(conn, replicationId, dn, !isADS && !isSchema, hostPort); logger.info(LocalizableMessage.raw("serverId of source replica: " + replicaServerId)); initializeSuffix(conn, replicaServerId, dn, !isADS && !isSchema, hostPort); initDone = true; } catch (PeerNotFoundException pnfe) @@ -4118,8 +4118,8 @@ * * @param conn * the connection to the server whose suffix we want to initialize. * @param replicaId * the replication ID of the replica we want to use to initialize the * @param replicaServerId * the server ID of the replica we want to use to initialize the * contents of the suffix. * @param suffixDn * the dn of the suffix. @@ -4133,7 +4133,7 @@ * @throws PeerNotFoundException * if the replication mechanism cannot find a peer. */ public void initializeSuffix(ConnectionWrapper conn, int replicaId, DN suffixDn, boolean displayProgress, public void initializeSuffix(ConnectionWrapper conn, int replicaServerId, DN suffixDn, boolean displayProgress, HostPort sourceServerDisplay) throws ApplicationException, PeerNotFoundException { boolean taskCreated = false; @@ -4144,7 +4144,7 @@ .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.toString()) .addAttribute("ds-task-initialize-replica-server-id", String.valueOf(replicaId)); .addAttribute("ds-task-initialize-replica-server-id", String.valueOf(replicaServerId)); while (!taskCreated) { checkAbort(); opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
@@ -367,15 +367,15 @@ * replication port or not. * @param usedReplicationServerIds the list of replication server ids that * are already used. * @param usedServerIds the list of server ids (domain ids) that * are already used. * @param usedReplicaServerIds the list of server ids (domain ids) that * are already used by replicas. * @throws ApplicationException if something goes wrong. * @return a ConfiguredReplication object describing what has been configured. */ public ConfiguredReplication configureReplication( ConnectionWrapper conn, Map<DN, Set<HostPort>> replicationServers, int replicationPort, boolean useSecureReplication, Set<Integer> usedReplicationServerIds, Set<Integer> usedServerIds) Set<Integer> usedReplicaServerIds) throws ApplicationException { boolean synchProviderCreated; @@ -518,13 +518,13 @@ } if (domain == null) { int domainId = getReplicationId(usedServerIds); usedServerIds.add(domainId); int replicaServerId = getReplicationId(usedReplicaServerIds); usedReplicaServerIds.add(replicaServerId); domainName = getDomainName(domainNames, dn); domain = sync.createReplicationDomain( ReplicationDomainCfgDefn.getInstance(), domainName, new ArrayList<PropertyException>()); domain.setServerId(domainId); domain.setServerId(replicaServerId); domain.setBaseDN(dn); isCreated = true; } @@ -539,7 +539,7 @@ } servers = toLowerCaseStrings(replicationServers.get(dn)); domain.setReplicationServer(servers); usedServerIds.add(domain.getServerId()); usedReplicaServerIds.add(domain.getServerId()); domain.commit(); Set<String> addedServers = intersect(servers, oldServers); @@ -678,8 +678,8 @@ * * @param logMsg * the log message. * @return <CODE>true</CODE> if the log message corresponds to a peers not * found error during initialization and <CODE>false</CODE> otherwise. * @return {@code true} if the log message corresponds to a peers not * found error during initialization, {@code false} otherwise. */ public boolean isPeersNotFoundError(String logMsg) { @@ -1011,7 +1011,7 @@ * If the log message is of type "[03/Apr/2008:21:25:43 +0200] category=JEB * severity=NOTICE msgID=8847454 Processed 1 entries, imported 0, skipped 1, * rejected 0 and migrated 0 in 1 seconds (average rate 0.0/sec)" returns the * message part. Returns <CODE>null</CODE> otherwise. * message part. Returns {@code null} otherwise. * * @param msg * the message to be parsed. opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -1673,8 +1673,7 @@ 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)); @@ -4799,7 +4798,7 @@ 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<>(); @@ -4808,24 +4807,24 @@ 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<>(); @@ -4845,7 +4844,7 @@ 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, @@ -5023,12 +5022,12 @@ } } 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()); } } @@ -5814,7 +5813,7 @@ 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()) @@ -6315,7 +6314,7 @@ * 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 @@ -6324,7 +6323,7 @@ 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); @@ -6357,13 +6356,13 @@ 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; @@ -6544,7 +6543,7 @@ ReplicaDescriptor replica = findReplicaForSuffixDN(source.getReplicas(), baseDN); if (replica != null) { replicationId = replica.getReplicationId(); replicationId = replica.getServerId(); } } catch (IOException ne) @@ -8921,11 +8920,11 @@ 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, opendj-server-legacy/src/main/java/org/opends/server/types/HostPort.java
@@ -46,7 +46,6 @@ mayInvoke=true) public final class HostPort implements Comparable<HostPort> { /** The tracer object for the debug logger. */ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); @@ -152,10 +151,18 @@ return localAddresses; } public static Set<String> toLowerCaseStrings(Set<HostPort> hps) /** * Converts a set of {@link HostPort}s to a new set where each host/port is converted to a * lowercase string. * * @param hostPorts * the set of host ports to convert * @return a new set of strings containing the lowercased string representation of the hostports */ public static Set<String> toLowerCaseStrings(Set<HostPort> hostPorts) { final Set<String> results = new HashSet<>(); for (HostPort hp : hps) for (HostPort hp : hostPorts) { results.add(hp.toString().toLowerCase(Locale.ROOT)); }