1
22
23 package com.liferay.counter.service.persistence;
24
25 import com.liferay.portal.kernel.job.IntervalJob;
26 import com.liferay.portal.kernel.job.JobExecutionContext;
27 import com.liferay.portal.kernel.job.JobExecutionException;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.Time;
31 import com.liferay.portal.util.PropsValues;
32
33 import java.sql.Connection;
34 import java.sql.Statement;
35
36
42 public class ConnectionHeartbeatJob implements IntervalJob {
43
44 public static final long INTERVAL =
45 PropsValues.COUNTER_CONNECTION_HEARTBEAT_JOB_INTERVAL * Time.MINUTE;
46
47 public void execute(JobExecutionContext context)
48 throws JobExecutionException {
49
50 try {
51 sendHeartbeat();
52 }
53 catch (Exception e) {
54 throw new JobExecutionException(e);
55 }
56 }
57
58 public long getInterval() {
59 return INTERVAL;
60 }
61
62 protected void sendHeartbeat() throws Exception {
63 if (_log.isDebugEnabled()) {
64 _log.debug("Sending heartbeat");
65 }
66
67 Connection connection = CounterUtil.getPersistence().getConnection();
68
69 Statement statement = connection.createStatement();
70
71 statement.execute(_SELECT_RELEASE);
72 }
73
74 private static String _SELECT_RELEASE = "SELECT releaseId FROM Release_";
75
76 private static final Log _log =
77 LogFactoryUtil.getLog(ConnectionHeartbeatJob.class);
78
79 }