diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java index 39b18f2074..7784992472 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java @@ -396,6 +396,13 @@ public interface ActiveMQServerControl { @Attribute(desc = "uptime of this server in milliseconds") long getUptimeMillis(); + /** + * Returns whether the initial replication synchronization process with the backup server is complete; applicable for + * either the live or backup server. + */ + @Attribute(desc = "whether the initial replication synchronization process with the backup server is complete") + boolean isReplicaSync(); + // Operations ---------------------------------------------------- /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index 6e7f4dc156..df84c48c0a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -669,6 +669,19 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } + @Override + public boolean isReplicaSync() { + checkStarted(); + + clearIO(); + try { + return server.isReplicaSync(); + } + finally { + blockOnIO(); + } + } + @Override public String[] getAddressNames() { checkStarted(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java index 4de94b971a..dfcfed2c88 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java @@ -371,4 +371,7 @@ public interface ActiveMQMessageBundle { @Message(id = 119117, value = "Replicator is null. Replication was likely terminated.") ActiveMQIllegalStateException replicatorIsNull(); + + @Message(id = 119118, value = "Management method not applicable for current server configuration") + IllegalStateException methodNotApplicable(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java index 0c6fe11ac6..d5786e60a9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java @@ -210,6 +210,12 @@ public interface ActiveMQServer extends ActiveMQComponent { */ QueueDeleter getJMSQueueDeleter(); + /** + * Returns whether the initial replication synchronization process with the backup server is complete; applicable for + * either the live or backup server. + */ + boolean isReplicaSync(); + /** * Wait for server initialization. * diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 641ceddb09..60235defa0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -674,6 +674,26 @@ public class ActiveMQServerImpl implements ActiveMQServer { this.jmsQueueDeleter = jmsQueueDeleter; } + @Override + public boolean isReplicaSync() { + if (activation instanceof SharedNothingLiveActivation) { + ReplicationManager replicationManager = getReplicationManager(); + + if (replicationManager == null) { + return false; + } + else { + return !replicationManager.isSynchronizing(); + } + } + else if (activation instanceof SharedNothingBackupActivation) { + return ((SharedNothingBackupActivation) activation).isRemoteBackupUpToDate(); + } + else { + throw ActiveMQMessageBundle.BUNDLE.methodNotApplicable(); + } + } + /** * Stops the server * diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java index e8fd9ef9f9..ee002298f6 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java @@ -1319,7 +1319,7 @@ public abstract class ActiveMQTestBase extends Assert { boolean isRemoteUpToDate = true; if (isReplicated) { if (activation instanceof SharedNothingBackupActivation) { - isRemoteUpToDate = ((SharedNothingBackupActivation) activation).isRemoteBackupUpToDate(); + isRemoteUpToDate = backup.isReplicaSync(); } else { //we may have already failed over and changed the Activation diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index e760b01739..7519fef9e4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -238,6 +238,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes return 0; } + @Override + public boolean isReplicaSync() { + return false; + } + @Override public int getIDCacheSize() { return (Integer) proxy.retrieveAttributeValue("IDCacheSize");