ARTEMIS-517 API to check sync with backup

This commit is contained in:
jbertram 2016-05-06 14:53:55 -05:00
parent 9a9968c35c
commit 04c9564d77
7 changed files with 55 additions and 1 deletions

View File

@ -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 ----------------------------------------------------
/**

View File

@ -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();

View File

@ -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();
}

View File

@ -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.
*

View File

@ -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
*

View File

@ -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

View File

@ -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");