Skip to content

Commit

Permalink
0002930: Add node offline monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Dec 4, 2016
1 parent 8b4c48c commit 0232b2b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
2 changes: 2 additions & 0 deletions symmetric-assemble/src/asciidoc/configuration/monitors.ad
Expand Up @@ -36,6 +36,8 @@ be compared to a threshold value.

|dataGaps|Number of active data gaps that are being checked during routing for data to commit.

|nodesOffline|The number of nodes that are offline based on the last heartbeat time. The console.report.as.offline.minutes parameter controls how many minutes before a node is considered offline.

|===

Threshold:: When this threshold value is reached or exceeded, an event is recorded.
Expand Down
Expand Up @@ -39,6 +39,8 @@ final public class ParameterConstants {

private static Map<String, ParameterMetaData> parameterMetaData = new DefaultParameterParser("/symmetric-default.properties").parse();

public final static String MINUTES_BEFORE_NODE_REPORTED_AS_OFFLINE = "console.report.as.offline.minutes";

private ParameterConstants() {
}

Expand Down
@@ -0,0 +1,60 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.monitor;

import org.jumpmind.extension.IBuiltInExtensionPoint;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.ext.ISymmetricEngineAware;
import org.jumpmind.symmetric.model.Monitor;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.IParameterService;

public class MonitorTypeOfflineNodes implements IMonitorType, ISymmetricEngineAware, IBuiltInExtensionPoint {

protected INodeService nodeService;

protected IParameterService parameterService;

@Override
public String getName() {
return "offlineNodes";
}

@Override
public long check(Monitor monitor) {
int minutesBeforeNodeIsOffline = parameterService.getInt(
ParameterConstants.MINUTES_BEFORE_NODE_REPORTED_AS_OFFLINE, 24 * 60);
return nodeService.findOfflineNodeIds(minutesBeforeNodeIsOffline).size();
}

@Override
public boolean requiresClusterLock() {
return true;
}

@Override
public void setSymmetricEngine(ISymmetricEngine engine) {
nodeService = engine.getNodeService();
parameterService = engine.getParameterService();
}

}
Expand Up @@ -36,6 +36,7 @@
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.Notification;
import org.jumpmind.symmetric.monitor.IMonitorType;
import org.jumpmind.symmetric.monitor.MonitorTypeOfflineNodes;
import org.jumpmind.symmetric.monitor.MonitorTypeBatchError;
import org.jumpmind.symmetric.monitor.MonitorTypeBatchUnsent;
import org.jumpmind.symmetric.monitor.MonitorTypeCpu;
Expand Down Expand Up @@ -91,7 +92,7 @@ public MonitorService(IParameterService parameterService, ISymmetricDialect symm
hostName = AppUtils.getHostName();

IMonitorType monitorExtensions[] = { new MonitorTypeBatchError(), new MonitorTypeBatchUnsent(), new MonitorTypeCpu(),
new MonitorTypeDataGap(), new MonitorTypeDisk(), new MonitorTypeMemory(), new MonitorTypeUnrouted() };
new MonitorTypeDataGap(), new MonitorTypeDisk(), new MonitorTypeMemory(), new MonitorTypeUnrouted(), new MonitorTypeOfflineNodes() };
for (IMonitorType ext : monitorExtensions) {
extensionService.addExtensionPoint(ext.getName(), ext);
}
Expand Down
Expand Up @@ -1985,3 +1985,9 @@ smtp.starttls=false
# Type: boolean
# Tags: smtp
smtp.allow.untrusted.cert=false

# Setting for that defines when a Node should be considered "offline." The node offline monitor uses this setting.
#
# DatabaseOverridable: true
# Tags: other
console.report.as.offline.minutes=1440

0 comments on commit 0232b2b

Please sign in to comment.