Skip to content

Commit

Permalink
0006086: Improved watchdog job and enabled it by default
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-miller-jumpmind committed Nov 2, 2023
1 parent 437fa44 commit b893f9e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ protected void init() {
this.jobManager = createJobManager();
extensionService.addExtensionPoint(new DefaultOfflineServerListener(
statisticManager, nodeService, outgoingBatchService));
IOfflineClientListener defaultlistener = new DefaultOfflineClientListener(parameterService,
nodeService);
IOfflineClientListener defaultlistener = new DefaultOfflineClientListener(this);
extensionService.addExtensionPoint(defaultlistener);
if (registerEngine) {
registerHandleToEngine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
package org.jumpmind.symmetric.io;

import org.jumpmind.extension.IBuiltInExtensionPoint;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.IParameterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,13 +33,10 @@
*/
public class DefaultOfflineClientListener implements IOfflineClientListener, IBuiltInExtensionPoint {
protected final Logger log = LoggerFactory.getLogger(getClass());
protected IParameterService parameterService;
protected INodeService nodeService;
protected ISymmetricEngine engine;

public DefaultOfflineClientListener(IParameterService parameterService,
INodeService nodeService) {
this.parameterService = parameterService;
this.nodeService = nodeService;
public DefaultOfflineClientListener(ISymmetricEngine engine) {
this.engine = engine;
}

public void busy(Node remoteNode) {
Expand All @@ -55,11 +52,13 @@ public void offline(Node remoteNode) {
}

public void syncDisabled(Node remoteNode) {
INodeService nodeService = engine.getNodeService();
Node identity = nodeService.findIdentity();
if (identity != null && identity.getCreatedAtNodeId() != null
&& identity.getCreatedAtNodeId().equals(remoteNode.getNodeId())) {
log.warn("Removing identity because sync has been disabled");
nodeService.deleteIdentity();
if (identity != null && ((identity.getCreatedAtNodeId() != null
&& identity.getCreatedAtNodeId().equals(remoteNode.getNodeId()))
|| engine.getConfigurationService().isMasterToMaster())) {
log.warn("Uninstalling node because sync has been disabled");
engine.uninstall();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ public void checkForOfflineNodes() {
long offlineNodeDetectionMinutes = parameterService.getLong(ParameterConstants.OFFLINE_NODE_DETECTION_PERIOD_MINUTES);
List<IOfflineServerListener> offlineServerListeners = extensionService.getExtensionPointList(IOfflineServerListener.class);
// Only check for offline nodes if there is a listener and the
// offline detection period is a positive value. The default value
// of -1 disables the feature.
// offline detection period is a positive value. A negative value
// disables the feature.
if (offlineServerListeners != null && offlineNodeDetectionMinutes > 0) {
List<Node> list = findOfflineNodes();
if (list.size() > 0) {
Expand Down Expand Up @@ -1030,8 +1030,16 @@ protected void fireOffline(List<Node> offlineClientNodeList) {
Node myNode = findIdentity();
for (IOfflineServerListener listener : extensionService.getExtensionPointList(IOfflineServerListener.class)) {
for (Node node : offlineClientNodeList) {
if (myNode == null || !myNode.equals(node)) {
listener.clientNodeOffline(node);
if (myNode != null && !myNode.equals(node)) {
String myNodeId = myNode.getNodeId();
if (myNodeId.equals(node.getCreatedAtNodeId())) {
listener.clientNodeOffline(node);
} else {
NodeSecurity security = findNodeSecurity(node.getNodeId());
if (security != null && myNodeId.equals(security.getCreatedAtNodeId())) {
listener.clientNodeOffline(node);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ heartbeat.update.node.with.batch.status=false
# DatabaseOverridable: true
# Tags: other
# Type: integer
offline.node.detection.period.minutes=-1
offline.node.detection.period.minutes=43200

# This is the number of minutes after a node has been restarted that it will begin
# considering remote nodes as offline. This gives remote nodes a chance to send
Expand Down

0 comments on commit b893f9e

Please sign in to comment.