From 27f5e24fae68a1f00412bd5f603b0a018896dd98 Mon Sep 17 00:00:00 2001 From: Chris Henson Date: Mon, 27 Mar 2017 16:20:46 -0400 Subject: [PATCH] 0003025: Update the heartbeat (sym_node_host) immediately on an re-opened registration --- .../service/impl/RegistrationService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/RegistrationService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/RegistrationService.java index 6527796f05..fd73926358 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/RegistrationService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/RegistrationService.java @@ -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; @@ -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); @@ -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 {