Skip to content

Commit

Permalink
0005791: Allow registration of other nodes after registration and
Browse files Browse the repository at this point in the history
initial load is complete
  • Loading branch information
erilong committed Apr 17, 2023
1 parent df2e441 commit c648538
Showing 1 changed file with 10 additions and 8 deletions.
Expand Up @@ -158,7 +158,8 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
return processedNode;
}
Node identity = nodeService.findIdentity();
if (identity == null) {
NodeSecurity mySecurity = identity == null ? null : nodeService.findNodeSecurity(identity.getNodeId());
if (identity == null || (mySecurity != null && mySecurity.isRegistrationEnabled())) {
RegistrationRequest req = new RegistrationRequest(nodePriorToRegistration,
RegistrationStatus.ER, remoteHost, remoteAddress);
req.setErrorMessage("Cannot register a client node until this node is registered");
Expand All @@ -172,12 +173,11 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
* registration is not allowed until this node has an identity and an initial load
*/
boolean requiresInitialLoad = parameterService.is(ParameterConstants.REGISTRATION_REQUIRE_INITIAL_LOAD, true);
NodeSecurity security = nodeService.findNodeSecurity(identity.getNodeId());
if (requiresInitialLoad && (security == null || security.getInitialLoadTime() == null)) {
if (requiresInitialLoad && (mySecurity == null || mySecurity.getInitialLoadEndTime() == null)) {
RegistrationRequest req = new RegistrationRequest(nodePriorToRegistration,
RegistrationStatus.ER, remoteHost, remoteAddress);
req.setErrorMessage(
"Cannot register a client node until this node has an initial load (ie. node_security.initial_load_time is a non null value)");
"Cannot register a client node until this node has an initial load (ie. node_security.initial_load_end_time is a non null value)");
saveRegistrationRequest(req);
log.warn(req.getErrorMessage());
return processedNode;
Expand Down Expand Up @@ -268,7 +268,7 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
foundNode.setDatabaseName(nodePriorToRegistration.getDatabaseName());
foundNode.setConfigVersion(Version.version());
nodeService.save(foundNode);
log.info("Completed registration of node " + foundNode);
log.info("Registered node " + foundNode + " in my database, but pending acknowledgement");
/**
* Only send automatic initial load once or if the client is really re-registering
*/
Expand Down Expand Up @@ -320,10 +320,9 @@ public boolean registerNode(Node nodePriorToRegistration, String remoteHost,
Node processedNode = processRegistration(nodePriorToRegistration, remoteHost,
remoteAddress, userId, password, isRequestedRegistration);
if (processedNode.isSyncEnabled()) {
/*
* Mark all configuration batches as processed because we are about to reload the configuration for the node
*/
log.info("Preparing to send registration to node {} by clearing its outgoing config batches", processedNode);
outgoingBatchService.markAllConfigAsSentForNode(processedNode.getNodeId());
log.info("Sending registration batch to node {}", processedNode);
extractConfiguration(out, processedNode);
}
return processedNode.isSyncEnabled();
Expand Down Expand Up @@ -425,6 +424,7 @@ public void markNodeAsRegistered(String nodeId) {
for (INodeRegistrationListener l : registrationListeners) {
l.registrationSyncTriggers();
}
log.info("Completed registration of node {}", nodeId);
}

protected void markNodeAsRegistrationPending(String nodeId) {
Expand Down Expand Up @@ -623,7 +623,9 @@ public List<OutgoingBatch> registerWithClient(Node remote, IOutgoingWithResponse
batch.setBatchId(Constants.VIRTUAL_BATCH_FOR_REGISTRATION);
extractedBatches.add(batch);
try {
log.info("Preparing to send registration to node {} by clearing its outgoing config batches", remote);
outgoingBatchService.markAllConfigAsSentForNode(remote.getNodeId());
log.info("Sending registration batch to node {}", remote);
extractConfiguration(transport.openStream(), remote);
} catch (Exception e) {
if (log.isDebugEnabled()) {
Expand Down

0 comments on commit c648538

Please sign in to comment.