Skip to content

Commit

Permalink
0002547: Notification of system event problems
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Apr 4, 2016
1 parent eca5950 commit d325b0c
Show file tree
Hide file tree
Showing 30 changed files with 1,409 additions and 4 deletions.
1 change: 1 addition & 0 deletions symmetric-assemble/build.gradle
Expand Up @@ -127,6 +127,7 @@ project(':symmetric-core') {
compile project(":symmetric-io")
compile project(":symmetric-util")
compile "commons-fileupload:commons-fileupload:$commonsFileuploadVersion"
compile "javax.mail:mail:1.4.5"
testCompile project(path: ':symmetric-util', configuration: 'testArtifacts')
testCompile project(path: ':symmetric-jdbc', configuration: 'testArtifacts')
}
Expand Down
1 change: 1 addition & 0 deletions symmetric-assemble/src/asciidoc/configuration.ad
Expand Up @@ -43,5 +43,6 @@ include::configuration/parameters.ad[]
ifdef::pro[]
include::configuration/users.ad[]
include::configuration/ldap.ad[]
include::configuration/mail-server.ad[]
include::configuration/license-key.ad[]
endif::pro[]
18 changes: 18 additions & 0 deletions symmetric-assemble/src/asciidoc/configuration/mail-server.ad
@@ -0,0 +1,18 @@

=== Mail Server

A mail server can be configured for sending email notifications.

Target Nodes:: The node group ID that will use this configuration.
Hostname:: The hostname or IP address of the mail server to contact for sending mail.
Transport:: The transport mechanism is either SMTP (Simple Mail Transfer Protocol) or SMTPS (encrypted with SSL).
Port:: The default port for SMTP is 25, while the default port for SMTPS is 465.
Use StartTLS:: After connecting over SMTP, the TLS protocol is used to encrypt content.
Use Authentication:: The mail server requires a login and password before email can be sent.
User:: The user login to use for authentication.
Password:: The login password to use for authentication.

ifdef::pro[]
The "Test" button will use the current settings on the screen to connect to the mail server with the configured
transport and report any errors.
endif::pro[]
Expand Up @@ -64,7 +64,7 @@ public JobManager(ISymmetricEngine engine) {
this.jobs.add(new FileSyncPullJob(engine,taskScheduler));
this.jobs.add(new FileSyncPushJob(engine,taskScheduler));
this.jobs.add(new InitialLoadExtractorJob(engine,taskScheduler));

this.jobs.add(new NotificationJob(engine, taskScheduler));
}

public IJob getJob(String name) {
Expand Down
@@ -0,0 +1,44 @@
/**
* 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.job;

import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.service.ClusterConstants;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

public class NotificationJob extends AbstractJob {

public NotificationJob(ISymmetricEngine engine, ThreadPoolTaskScheduler taskScheduler) {
super("job.notification", true, engine.getParameterService().is("start.notification.job"), engine, taskScheduler);
}

@Override
public void doJob(boolean force) throws Exception {
if (engine != null) {
engine.getNotificationService().update();
}
}

public String getClusterLockName() {
return ClusterConstants.NOTIFICATION;
}

}
Expand Up @@ -79,8 +79,10 @@
import org.jumpmind.symmetric.service.IGroupletService;
import org.jumpmind.symmetric.service.IIncomingBatchService;
import org.jumpmind.symmetric.service.ILoadFilterService;
import org.jumpmind.symmetric.service.IMailService;
import org.jumpmind.symmetric.service.INodeCommunicationService;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.INotificationService;
import org.jumpmind.symmetric.service.IOfflinePullService;
import org.jumpmind.symmetric.service.IOfflinePushService;
import org.jumpmind.symmetric.service.IOutgoingBatchService;
Expand All @@ -106,8 +108,10 @@
import org.jumpmind.symmetric.service.impl.GroupletService;
import org.jumpmind.symmetric.service.impl.IncomingBatchService;
import org.jumpmind.symmetric.service.impl.LoadFilterService;
import org.jumpmind.symmetric.service.impl.MailService;
import org.jumpmind.symmetric.service.impl.NodeCommunicationService;
import org.jumpmind.symmetric.service.impl.NodeService;
import org.jumpmind.symmetric.service.impl.NotificationService;
import org.jumpmind.symmetric.service.impl.OfflinePullService;
import org.jumpmind.symmetric.service.impl.OfflinePushService;
import org.jumpmind.symmetric.service.impl.OutgoingBatchService;
Expand Down Expand Up @@ -219,7 +223,11 @@ abstract public class AbstractSymmetricEngine implements ISymmetricEngine {

protected INodeCommunicationService nodeCommunicationService;

protected IFileSyncService fileSyncService;
protected IFileSyncService fileSyncService;

protected INotificationService notificationService;

protected IMailService mailService;

protected Date lastRestartTime = null;

Expand Down Expand Up @@ -344,6 +352,8 @@ protected void init() {
nodeService, dataLoaderService, clusterService, nodeCommunicationService,
configurationService, extensionService, offlineTransportManager);
this.fileSyncService = new FileSyncService(this);
this.notificationService = new NotificationService(parameterService, symmetricDialect, extensionService);
this.mailService = new MailService(parameterService, symmetricDialect);
this.jobManager = createJobManager();

extensionService.addExtensionPoint(new DefaultOfflineServerListener(
Expand Down Expand Up @@ -1044,6 +1054,14 @@ public IExtensionService getExtensionService() {
return extensionService;
}

public INotificationService getNotificationService() {
return notificationService;
}

public IMailService getMailService() {
return mailService;
}

public IStagingManager getStagingManager() {
return stagingManager;
}
Expand All @@ -1059,7 +1077,7 @@ public INodeCommunicationService getNodeCommunicationService() {
public IGroupletService getGroupletService() {
return groupletService;
}

private void removeMeFromMap(Map<String, ISymmetricEngine> map) {
Set<String> keys = new HashSet<String>(map.keySet());
for (String key : keys) {
Expand Down
Expand Up @@ -45,8 +45,10 @@
import org.jumpmind.symmetric.service.IGroupletService;
import org.jumpmind.symmetric.service.IIncomingBatchService;
import org.jumpmind.symmetric.service.ILoadFilterService;
import org.jumpmind.symmetric.service.IMailService;
import org.jumpmind.symmetric.service.INodeCommunicationService;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.INotificationService;
import org.jumpmind.symmetric.service.IOfflinePullService;
import org.jumpmind.symmetric.service.IOfflinePushService;
import org.jumpmind.symmetric.service.IOutgoingBatchService;
Expand Down Expand Up @@ -289,6 +291,10 @@ public interface ISymmetricEngine {

public IExtensionService getExtensionService();

public INotificationService getNotificationService();

public IMailService getMailService();

public IStagingManager getStagingManager();

public ISqlTemplate getSqlTemplate();
Expand Down
Expand Up @@ -56,6 +56,7 @@ private ParameterConstants() {
public final static String START_STATISTIC_FLUSH_JOB = "start.stat.flush.job";
public final static String START_STAGE_MGMT_JOB = "start.stage.management.job";
public final static String START_WATCHDOG_JOB = "start.watchdog.job";
public final static String START_NOTIFICATION_JOB = "start.notification.job";

public final static String PULL_THREAD_COUNT_PER_SERVER = "pull.thread.per.server.count";
public final static String PULL_MINIMUM_PERIOD_MS = "pull.period.minimum.ms";
Expand Down Expand Up @@ -311,6 +312,15 @@ private ParameterConstants() {

public final static String DATA_CREATE_TIME_TIMEZONE = "data.create_time.timezone";

public static final String SMTP_HOST = "smtp.host";
public static final String SMTP_TRANSPORT = "smtp.transport";
public static final String SMTP_PORT = "smtp.port";
public static final String SMTP_FROM = "smtp.from";
public static final String SMTP_USER = "smtp.user";
public static final String SMTP_PASSWORD = "smtp.password";
public static final String SMTP_USE_STARTTLS = "smtp.starttls";
public static final String SMTP_USE_AUTH = "smtp.auth";

public static Map<String, ParameterMetaData> getParameterMetaData() {
return parameterMetaData;
}
Expand Down
Expand Up @@ -73,6 +73,7 @@ public class TableConstants {
public static final String SYM_FILE_INCOMING = "file_incoming";
public static final String SYM_CONSOLE_USER = "console_user";
public static final String SYM_EXTENSION = "extension";
public static final String SYM_NOTIFICATION = "notification";

private static List<String> tablesWithPrefix;

Expand Down Expand Up @@ -127,6 +128,7 @@ protected static List<String> populateConfigTables(String tablePrefix) {
configTables.add(getTableName(tablePrefix, TableConstants.SYM_FILE_SNAPSHOT));
configTables.add(getTableName(tablePrefix, TableConstants.SYM_NODE_IDENTITY));
configTables.add(getTableName(tablePrefix, TableConstants.SYM_EXTENSION));
configTables.add(getTableName(tablePrefix, TableConstants.SYM_NOTIFICATION));
return configTables;
}

Expand Down Expand Up @@ -175,6 +177,7 @@ protected static List<String> populateAllTables(String tablePrefix) {
tables.add(getTableName(tablePrefix, TableConstants.SYM_FILE_SNAPSHOT));
tables.add(getTableName(tablePrefix, TableConstants.SYM_FILE_INCOMING));
tables.add(getTableName(tablePrefix, SYM_EXTENSION));
tables.add(getTableName(tablePrefix, SYM_NOTIFICATION));
return tables;
}

Expand Down
@@ -0,0 +1,160 @@
/**
* 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.model;

import java.util.Date;

public class Notification {

protected String notificationId;

protected String externalId;

protected String nodeGroupId;

protected String type;

protected boolean enabled;

protected long threshold;

protected int period;

protected int sampleMinutes;

protected int severityLevel;

protected long windowMinutes;

protected Date createTime;

protected String lastUpdateBy;

protected Date lastUpdateTime;

public String getNotificationId() {
return notificationId;
}

public Notification() {
}

public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}

public String getExternalId() {
return externalId;
}

public void setExternalId(String externalId) {
this.externalId = externalId;
}

public String getNodeGroupId() {
return nodeGroupId;
}

public void setNodeGroupId(String nodeGroupId) {
this.nodeGroupId = nodeGroupId;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public long getThreshold() {
return threshold;
}

public void setThreshold(long threshhold) {
this.threshold = threshhold;
}

public int getPeriod() {
return period;
}

public void setPeriod(int period) {
this.period = period;
}

public int getSampleMinutes() {
return sampleMinutes;
}

public void setSampleMinutes(int sampleMinutes) {
this.sampleMinutes = sampleMinutes;
}

public int getSeverityLevel() {
return severityLevel;
}

public void setSeverityLevel(int severityLevel) {
this.severityLevel = severityLevel;
}

public long getWindowMinutes() {
return windowMinutes;
}

public void setWindowMinutes(long windowMinutes) {
this.windowMinutes = windowMinutes;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public String getLastUpdateBy() {
return lastUpdateBy;
}

public void setLastUpdateBy(String lastUpdateBy) {
this.lastUpdateBy = lastUpdateBy;
}

public Date getLastUpdateTime() {
return lastUpdateTime;
}

public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}

}

0 comments on commit d325b0c

Please sign in to comment.