Skip to content

Commit

Permalink
added heartbeat job.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Sep 30, 2007
1 parent 95b49d4 commit ba2bd6f
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 1 deletion.
Expand Up @@ -115,6 +115,14 @@ private void startJobs() {
applicationContext.getBean(Constants.PURGE_JOB_TIMER);
}

if (Boolean.TRUE
.toString()
.equalsIgnoreCase(
properties
.getProperty(PropertiesConstants.START_HEARTBEAT_JOB))) {
applicationContext.getBean(Constants.HEARTBEAT_JOB_TIMER);
}

if (Boolean.TRUE
.toString()
.equalsIgnoreCase(
Expand Down Expand Up @@ -169,7 +177,7 @@ public void purge() {
"Cannot actuate a purge if it is already scheduled.");
}
}

public void heartbeat() {
bootstrapService.heartbeat();
}
Expand Down
Expand Up @@ -48,6 +48,8 @@ public class Constants {

public static final String PURGE_JOB_TIMER = "purgeJobTimer";

public static final String HEARTBEAT_JOB_TIMER = "heartbeatJobTimer";

public static final String SYNC_TRIGGERS_JOB_TIMER = "syncTriggersJobTimer";

public static final String DATA_EXTRACTOR = "dataExtractor";
Expand Down
Expand Up @@ -5,5 +5,6 @@ public class PropertiesConstants {
public final static String START_PULL_JOB = "symmetric.runtime.start.pull.job";
public final static String START_PUSH_JOB = "symmetric.runtime.start.push.job";
public final static String START_PURGE_JOB = "symmetric.runtime.start.purge.job";
public final static String START_HEARTBEAT_JOB = "symmetric.runtime.start.heartbeat.job";
public final static String START_SYNCTRIGGERS_JOB = "symmetric.runtime.start.synctriggers.job";
}
@@ -0,0 +1,28 @@
package org.jumpmind.symmetric.job;

import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jumpmind.symmetric.service.IBootstrapService;

public class HeartbeatJob extends TimerTask {

private static final Log logger = LogFactory.getLog(PushJob.class);

private IBootstrapService bootstrapService;

@Override
public void run() {
try {
bootstrapService.heartbeat();
} catch (Throwable ex) {
logger.error(ex, ex);
}
}

public void setBootstrapService(IBootstrapService bootstrapService) {
this.bootstrapService = bootstrapService;
}

}
Expand Up @@ -191,6 +191,7 @@ public void register() {
public void heartbeat() {
Node node = nodeService.findIdentity();
if (node != null) {
logger.info("Updating my node information and heartbeat time.");
node.setHeartbeatTime(new Date());
node.setDatabaseType(dbDialect.getName());
node.setDatabaseVersion(dbDialect.getVersion());
Expand Down
17 changes: 17 additions & 0 deletions symmetric/src/main/resources/symmetric-jobs.xml
Expand Up @@ -95,6 +95,23 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema
</bean>
</list>
</property>
</bean>

<bean id="heartbeatJobTimer" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<bean class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="delay" value="900000" />
<property name="period" value="900000" />
<property name="timerTask">
<bean class="org.jumpmind.symmetric.job.HeartbeatJob">
<property name="bootstrapService" ref="bootstrapService" />
</bean>
</property>
</bean>
</list>
</property>
</bean>


</beans>
1 change: 1 addition & 0 deletions symmetric/src/main/resources/symmetric-properties.xml
Expand Up @@ -27,6 +27,7 @@
<prop key="symmetric.runtime.start.pull.job">true</prop>
<prop key="symmetric.runtime.start.push.job">true</prop>
<prop key="symmetric.runtime.start.purge.job">true</prop>
<prop key="symmetric.runtime.start.heartbeat.job">true</prop>
<prop key="symmetric.runtime.start.synctriggers.job">true</prop>
<prop key="symmetric.runtime.registration.url"></prop>
<prop key="symmetric.runtime.my.url">http://localhost:8080/sync</prop>
Expand Down
Expand Up @@ -9,5 +9,6 @@ symmetric.runtime.start.pull.job=false
symmetric.runtime.start.push.job=false
symmetric.runtime.start.purge.job=false
symmetric.runtime.start.synctriggers.job=false
symmetric.runtime.start.heartbeat.job=false
symmetric.runtime.purge.retention.minutes=0
symmetric.runtime.schema.version=1
Expand Up @@ -9,4 +9,5 @@ symmetric.runtime.start.pull.job=false
symmetric.runtime.start.push.job=false
symmetric.runtime.start.purge.job=false
symmetric.runtime.start.synctriggers.job=false
symmetric.runtime.start.heartbeat.job=false
symmetric.runtime.purge.retention.minutes=0
Expand Up @@ -9,5 +9,6 @@ symmetric.runtime.my.url=internal://symmetric2
symmetric.runtime.start.pull.job=false
symmetric.runtime.start.push.job=false
symmetric.runtime.start.purge.job=false
symmetric.runtime.start.heartbeat.job=false
symmetric.runtime.start.synctriggers.job=false
symmetric.runtime.purge.retention.minutes=0
Expand Up @@ -10,6 +10,7 @@ symmetric.transport.type=internal
symmetric.runtime.my.url=internal://symmetric
symmetric.runtime.start.pull.job=false
symmetric.runtime.start.push.job=false
symmetric.runtime.start.heartbeat.job=false
symmetric.runtime.start.purge.job=false
symmetric.runtime.start.synctriggers.job=false
symmetric.runtime.purge.retention.minutes=0

0 comments on commit ba2bd6f

Please sign in to comment.