Skip to content

Commit

Permalink
0003025: Update the heartbeat (sym_node_host) immediately on an
Browse files Browse the repository at this point in the history
re-opened registration
  • Loading branch information
chenson42 committed Mar 27, 2017
1 parent cf8bac7 commit 27f5e24
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -555,6 +555,10 @@ protected boolean checkRegistrationSuccessful(boolean registered, int maxNumberO
* @see IRegistrationService#reOpenRegistration(String)
*/
public synchronized void reOpenRegistration(String nodeId) {
reOpenRegistration(nodeId, null, null);
}

protected synchronized void reOpenRegistration(String nodeId, String remoteHost, String remoteAddress) {
Node node = nodeService.findNode(nodeId);
NodeSecurity security = nodeService.findNodeSecurity(nodeId);
String password = null;
Expand All @@ -572,13 +576,22 @@ public synchronized void reOpenRegistration(String nodeId) {
// node table, but not in node security.
// lets go ahead and try to insert into node security.
sqlTemplate.update(getSql("openRegistrationNodeSecuritySql"), new Object[] {
nodeId, password, nodeService.findNode(nodeId).getNodeId() });
nodeId, password, nodeService.findNode(nodeId).getNodeId() });
log.info("Registration was opened for {}", nodeId);
} else if (updateCount == 0) {
log.warn("Registration was already enabled for {}. No need to reenable it", nodeId);
} else {
log.info("Registration was reopened for {}", nodeId);
}

if (isNotBlank(remoteHost)) {
NodeHost nodeHost = new NodeHost(node.getNodeId());
nodeHost.setHeartbeatTime(new Date());
nodeHost.setIpAddress(remoteAddress);
nodeHost.setHostName(remoteHost);
nodeService.updateNodeHost(nodeHost);
}

nodeService.flushNodeAuthorizedCache();
} else {
log.warn("There was no row with a node id of {} to 'reopen' registration for", nodeId);
Expand Down Expand Up @@ -644,7 +657,7 @@ protected String openRegistration(Node node, String remoteHost, String remoteAdd
"Just opened registration for external id of {} and a node group of {} and a node id of {}",
new Object[] { node.getExternalId(), node.getNodeGroupId(), nodeId });
} else {
reOpenRegistration(nodeId);
reOpenRegistration(nodeId, remoteHost, remoteAddress);
}
return nodeId;
} else {
Expand Down

0 comments on commit 27f5e24

Please sign in to comment.