Skip to content

Commit

Permalink
0004494: If node registers, immediate pull causes server to indicate
Browse files Browse the repository at this point in the history
that node is not registered
  • Loading branch information
philipmarzullo64 committed Aug 10, 2020
1 parent db87662 commit 5ce2ce9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Expand Up @@ -102,8 +102,10 @@ public interface IRegistrationService {
* registration server cannot be reach this method will continue to try with
* random sleep periods up to one minute up until the registration succeeds
* or the maximum number of attempts has been reached.
* Returns true if we had to register with server and was successful.
* Returns false if we did not have to register.
*/
public void registerWithServer();
public boolean registerWithServer();

/**
* Client method which attempts to register with the registration.url to
Expand Down
Expand Up @@ -85,8 +85,9 @@ synchronized public RemoteNodeStatuses pullData(boolean force) {
if (identity == null || identity.isSyncEnabled()) {
long minimumPeriodMs = parameterService.getLong(ParameterConstants.PULL_MINIMUM_PERIOD_MS, -1);
if (force || !clusterService.isInfiniteLocked(ClusterConstants.PULL)) {
// register if we haven't already been registered
registrationService.registerWithServer();
// register if we haven't already been registered
// Only pull if we did not have to register this time
if (!registrationService.registerWithServer()) {
identity = nodeService.findIdentity();
if (identity != null) {
List<NodeCommunication> nodes = nodeCommunicationService
Expand All @@ -108,6 +109,10 @@ synchronized public RemoteNodeStatuses pullData(boolean force) {
nodeCommunication.setBatchToSendCount(0);
}
}
} else {
identity = nodeService.findIdentity();
log.info("Node {}:{} just registered, not pulling yet", identity != null ? identity.getNodeGroupId() : "", identity != null ? identity.getNodeId() : "");
}
} else {
log.debug("Did not run the pull process because it has been stopped");
}
Expand Down
Expand Up @@ -469,8 +469,9 @@ public boolean isRegisteredWithServer() {
/**
* @see IRegistrationService#registerWithServer()
*/
public void registerWithServer() {
boolean registered = isRegisteredWithServer();
public boolean registerWithServer() {
boolean wasRegistered = isRegisteredWithServer();
boolean registered = wasRegistered;
int maxNumberOfAttempts = parameterService
.getInt(ParameterConstants.REGISTRATION_NUMBER_OF_ATTEMPTS);

Expand All @@ -490,6 +491,7 @@ public void registerWithServer() {
"Failed after trying to register %s times.",
parameterService.getString(ParameterConstants.REGISTRATION_NUMBER_OF_ATTEMPTS)));
}
return registered != wasRegistered;
}

public synchronized boolean attemptToRegisterWithServer(int maxNumberOfAttempts) {
Expand Down

0 comments on commit 5ce2ce9

Please sign in to comment.