opendj-server-legacy/src/main/java/org/opends/admin/ads/ReplicaDescriptor.java
@@ -36,7 +36,7 @@ private final Set<HostPort> replicationServers = new HashSet<>(); /** @see InstallerHelper#addNewReplicationId(Set) */ private int serverId = -1; private int missingChanges = -1; private long missingChanges = -1; private long ageOfOldestMissingChange = -1; private String backendId; private Set<String> objectClasses; @@ -187,7 +187,7 @@ * Returns the number of missing changes. * @return the number of missing changes. */ public int getMissingChanges() public long getMissingChanges() { return missingChanges; } @@ -196,7 +196,7 @@ * Sets the number of missing changes. * @param missingChanges the number of missing changes. */ public void setMissingChanges(int missingChanges) public void setMissingChanges(long missingChanges) { this.missingChanges = missingChanges; } opendj-server-legacy/src/main/java/org/opends/admin/ads/TopologyCache.java
@@ -13,6 +13,7 @@ * * Copyright 2008-2010 Sun Microsystems, Inc. * Portions Copyright 2011-2016 ForgeRock AS. * Portions Copyright 2026 3A Systems, LLC. */ package org.opends.admin.ads; @@ -492,18 +493,10 @@ private void setMissingChanges(ReplicaDescriptor replica, SearchResultEntry sr) { Integer value = sr.parseAttribute("missing-changes").asInteger(); Long value = sr.parseAttribute("missing-changes").asLong(); if (value != null) { try { replica.setMissingChanges(value); } catch (Throwable t) { logger.warn(LocalizableMessage.raw( "Unexpected error reading missing changes: " + t, t)); } replica.setMissingChanges(value); } } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java
@@ -13,6 +13,7 @@ * * Copyright 2008-2011 Sun Microsystems, Inc. * Portions Copyright 2011-2016 ForgeRock AS. * Portions Copyright 2026 3A Systems, LLC. */ package org.opends.guitools.controlpanel.datamodel; @@ -39,7 +40,7 @@ private BackendDescriptor backend; private Type type; private int nEntries; private int missingChanges; private long missingChanges; private long ageOfOldestMissingChange; private int replicaID = -1; @@ -55,7 +56,7 @@ * @param missingChanges the number of missing changes. */ public BaseDNDescriptor(Type type, DN baseDn, BackendDescriptor backend, int nEntries, long ageOfOldestMissingChange, int missingChanges) int nEntries, long ageOfOldestMissingChange, long missingChanges) { this.baseDn = baseDn; this.backend = backend; @@ -159,7 +160,7 @@ * @return the number of missing changes in the replication topology for * this base DN. */ public int getMissingChanges() public long getMissingChanges() { return missingChanges; } @@ -169,7 +170,7 @@ * this base DN. * @param missingChanges the missing changes. */ public void setMissingChanges(int missingChanges) public void setMissingChanges(long missingChanges) { this.missingChanges = missingChanges; recalculateHashCode(); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNTableModel.java
@@ -450,7 +450,7 @@ private int compareMissingChanges(BaseDNDescriptor desc1, BaseDNDescriptor desc2) { return compareIntegers(desc1.getMissingChanges(), return compareLongs(desc1.getMissingChanges(), desc2.getMissingChanges()); } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -39,6 +39,7 @@ import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.LdapException; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.admin.ads.util.ApplicationTrustManager; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.guitools.controlpanel.browser.IconPool; @@ -526,18 +527,27 @@ desc.setRootMonitor(rCtx.getRootMonitor()); desc.setEntryCachesMonitor(rCtx.getEntryCaches()); desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage()); desc.setSystemInformationMonitor(rCtx.getSystemInformation()); SearchResultEntry systemInformation = rCtx.getSystemInformation(); desc.setSystemInformationMonitor(systemInformation); desc.setWorkQueueMonitor(rCtx.getWorkQueue()); desc.setOpenDJVersion(rCtx.getVersionMonitor().parseAttribute("fullVersion").asString()); String installPath = rCtx.getSystemInformation().parseAttribute("installPath").asString(); if (installPath != null) SearchResultEntry versionMonitor = rCtx.getVersionMonitor(); String version = versionMonitor == null ? null : versionMonitor.parseAttribute("fullVersion").asString(); if (version != null) { desc.setInstallPath(installPath); desc.setOpenDJVersion(version); } String instancePath = rCtx.getSystemInformation().parseAttribute("instancePath").asString(); if (instancePath != null) if (systemInformation != null) { desc.setInstancePath(instancePath); String installPath = systemInformation.parseAttribute("installPath").asString(); if (installPath != null) { desc.setInstallPath(installPath); } String instancePath = systemInformation.parseAttribute("instancePath").asString(); if (instancePath != null) { desc.setInstancePath(instancePath); } } } } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromConnection.java
@@ -693,7 +693,7 @@ DN suffixDn = sr.parseAttribute("domain-name").asDN(); Integer replicaId = sr.parseAttribute("server-id").asInteger(); Integer missingChanges = sr.parseAttribute("missing-changes").asInteger(); Long missingChanges = sr.parseAttribute("missing-changes").asLong(); if (suffixDn != null && replicaId != null && missingChanges != null) { @@ -705,9 +705,12 @@ { if (baseDN.getDn().equals(suffixDn) && Objects.equals(baseDN.getReplicaID(), replicaId)) { baseDN.setAgeOfOldestMissingChange( sr.parseAttribute("approx-older-change-not-synchronized-millis").asLong()); baseDN.setMissingChanges(missingChanges); Long oldestChange = sr.parseAttribute("approx-older-change-not-synchronized-millis").asLong(); if (oldestChange != null) { baseDN.setAgeOfOldestMissingChange(oldestChange); } } } catch (Throwable ignored) opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -5780,7 +5780,7 @@ // Server port tableBuilder.appendCell(fromObject(getHostPort2(replicaServer, cnx))); // Number of entries tableBuilder.appendCell(fromPositiveInt(replica.getEntries())); tableBuilder.appendCell(fromNonNegative(replica.getEntries())); if (!replica.isReplicated()) { @@ -5816,7 +5816,7 @@ } // Missing changes tableBuilder.appendCell(fromPositiveInt(replica.getMissingChanges())); tableBuilder.appendCell(fromNonNegative(replica.getMissingChanges())); // Age of oldest missing change tableBuilder.appendCell(fromDate(replica.getAgeOfOldestMissingChange())); @@ -5863,7 +5863,7 @@ tableBuilder.appendCell(fromInt(server.getReplicationServerId())); // Replication port tableBuilder.appendCell(fromPositiveInt(server.getReplicationServerPort())); tableBuilder.appendCell(fromNonNegative(server.getReplicationServerPort())); // Missing changes tableBuilder.appendCell(EMPTY_MSG); @@ -5932,9 +5932,9 @@ return LocalizableMessage.raw(Integer.toString(value)); } private LocalizableMessage fromPositiveInt(int value) private LocalizableMessage fromNonNegative(long value) { return value >= 0 ? LocalizableMessage.raw(Integer.toString(value)) : EMPTY_MSG; return value >= 0 ? LocalizableMessage.raw(Long.toString(value)) : EMPTY_MSG; } private boolean isRepServerNotInDomain(Set<ReplicaDescriptor> replicas, ServerDescriptor server) @@ -5982,7 +5982,7 @@ // Server host+port tableBuilder.appendCell(fromObject(getHostPort2(server, cnx))); // Replication port tableBuilder.appendCell(fromPositiveInt(server.getReplicationServerPort())); tableBuilder.appendCell(fromNonNegative(server.getReplicationServerPort())); // Secure tableBuilder.appendCell(fromBoolean(server.isReplicationSecure())); } opendj-server-legacy/src/test/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfoTest.java
New file @@ -0,0 +1,116 @@ /* * The contents of this file are subject to the terms of the Common Development and * Distribution License (the License). You may not use this file except in compliance with the * License. * * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the * specific language governing permission and limitations under the License. * * When distributing Covered Software, include this CDDL Header Notice in each file and include * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions copyright [year] [name of copyright owner]". * * Copyright 2026 3A Systems, LLC. */ package org.opends.guitools.controlpanel.datamodel; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.AdditionalAnswers.delegatesTo; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Set; import org.forgerock.opendj.ldap.Connection; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.Responses; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldif.ConnectionEntryReader; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.admin.ads.util.PreferredConnection; import org.opends.guitools.controlpanel.util.ConfigFromConnection; import org.opends.guitools.controlpanel.util.ConfigReader; import org.opends.server.DirectoryServerTestCase; import org.opends.server.TestCaseUtils; import org.opends.server.types.HostPort; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class ControlPanelInfoTest extends DirectoryServerTestCase { @BeforeClass public void startServer() throws Exception { TestCaseUtils.startServer(); } @Test public void readsMissingChangesAboveTheIntegerRangeWithoutAnOldestChange() throws Exception { final DN suffixDN = DN.valueOf("dc=example,dc=com"); final BaseDNDescriptor replica = new BaseDNDescriptor(BaseDNDescriptor.Type.REPLICATED, suffixDN, null, -1, -1, -1); final BackendDescriptor backend = new BackendDescriptor("userRoot", Set.of(replica), Set.of(), Set.of(), -1, true, BackendDescriptor.Type.PLUGGABLE); replica.setReplicaID(1); final ConfigFromConnection reader = new ConfigFromConnection(); final Field backends = ConfigReader.class.getDeclaredField("backends"); backends.setAccessible(true); backends.set(reader, Set.of(backend)); final SearchResultEntry monitor = Responses.newSearchResultEntry("cn=replica,cn=monitor"); monitor.addAttribute("domain-name", suffixDN.toString()); monitor.addAttribute("server-id", "1"); monitor.addAttribute("missing-changes", "6442450929"); final Method handleEntry = ConfigFromConnection.class.getDeclaredMethod( "handleMonitoringSearchResult", SearchResultEntry.class); handleEntry.setAccessible(true); handleEntry.invoke(reader, monitor); assertThat(replica.getMissingChanges()).isEqualTo(6442450929L); assertThat(replica.getAgeOfOldestMissingChange()).isEqualTo(-1L); } @Test public void reportsStatusWhenVersionAndSystemInformationMonitorsAreMissing() throws Exception { final ServerDescriptor status = regenerateWithMonitor(mock(ConnectionEntryReader.class)); assertThat(status.isAuthenticated()).isTrue(); assertThat(status.getStatus()).isEqualTo(ServerDescriptor.ServerStatus.STARTED); } private ServerDescriptor regenerateWithMonitor(ConnectionEntryReader monitor) throws Exception { final HostPort hostPort = new HostPort("127.0.0.1", TestCaseUtils.getServerLdapPort()); try (ConnectionWrapper realConnection = new ConnectionWrapper(hostPort, PreferredConnection.Type.LDAP, DN.valueOf("cn=Directory Manager"), "password", 5000, null)) { final Connection ldap = realConnection.getConnection(); final Connection connection = mock(Connection.class, delegatesTo(ldap)); doAnswer(invocation -> { final SearchRequest request = (SearchRequest) invocation.getArguments()[0]; return request.getName().equals(DN.valueOf("cn=monitor")) ? monitor : ldap.search(request); }).when(connection).search(any(SearchRequest.class)); final ConnectionWrapper wrapper = spy(realConnection); doReturn(connection).when(wrapper).getConnection(); final Constructor<ControlPanelInfo> constructor = ControlPanelInfo.class.getDeclaredConstructor(); constructor.setAccessible(true); final ControlPanelInfo panel = constructor.newInstance(); panel.setIsLocal(false); panel.setConnection(wrapper); panel.regenerateDescriptor(); return panel.getServerDescriptor(); } } } opendj-server-legacy/src/test/java/org/opends/server/tools/dsreplication/ReplicationCliMainTest.java
@@ -19,14 +19,25 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.responses.Responses; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.admin.ads.ADSContext; import org.opends.admin.ads.ReplicaDescriptor; import org.opends.admin.ads.ServerDescriptor; import org.opends.admin.ads.SuffixDescriptor; import org.opends.admin.ads.TopologyCache; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.server.DirectoryServerTestCase; import org.testng.annotations.Test; @@ -56,6 +67,38 @@ .containsOnly(4243, 2); } @Test public void statusDisplaysMissingChangesAboveTheIntegerRange() throws Exception { final ReplicaDescriptor replica = replica(1); final DN suffixDN = DN.valueOf("dc=example,dc=com"); replica.setSuffix(new SuffixDescriptor(suffixDN, replica)); final ServerDescriptor server = server(null, replica); server.getServerProperties().put(ServerDescriptor.ServerProperty.HOST_NAME, "localhost"); server.getServerProperties().put(ServerDescriptor.ServerProperty.ADMIN_ENABLED, List.of(true)); server.getServerProperties().put(ServerDescriptor.ServerProperty.ADMIN_PORT, List.of(4444)); replica.setServer(server); final SearchResultEntry monitor = Responses.newSearchResultEntry("cn=replica,cn=monitor"); monitor.addAttribute("missing-changes", "6442450929"); final TopologyCache cache = new TopologyCache(new ADSContext(mock(ConnectionWrapper.class)), null, 0); final Method readCount = TopologyCache.class.getDeclaredMethod( "setMissingChanges", ReplicaDescriptor.class, SearchResultEntry.class); readCount.setAccessible(true); readCount.invoke(cache, replica, monitor); final ByteArrayOutputStream output = new ByteArrayOutputStream(); final ReplicationCliMain cli = new ReplicationCliMain(new PrintStream(output, true, StandardCharsets.UTF_8), System.err); final Method display = ReplicationCliMain.class.getDeclaredMethod("displayReplicaStatuses", List.class, boolean.class, Set.class, Set.class, Set.class, Set.class); display.setAccessible(true); display.invoke(cli, List.of(Set.of(replica)), true, Set.of(), Set.of(server), new HashSet<>(), new HashSet<>()); assertThat(output.toString(StandardCharsets.UTF_8).strip().split("\t", -1)) .hasSize(8).endsWith("6442450929"); } private static TopologyCache topology(ServerDescriptor... servers) { final TopologyCache topology = mock(TopologyCache.class);