Commits

Zemian Deng  committed 5fbc626 Merge

Merged latest default into stable branch.

  • Participants
  • Parent commits 1c01324, 2f98d16
  • Branches stable

Comments (0)

Files changed (13)

 ae9b33cd62a426fe87a13ec1b5aa47f43b4ebaf1 1.0.0
 94f80e87540ca98feb2d279807e6beddf0221ec4 1.1.0
 066ac933f4fd2f276865653de22c13913359dd05 1.1.1
-449455daa28462598cb1a72c055a0389c22a3b19 timemachine-parent-1.2.0
+449455daa28462598cb1a72c055a0389c22a3b19 1.2.0

File scripts/root-war.sh

-#!/usr/bin/env bash
-#
-# Build ROOT.war for openshift JBoss Application's deployment that contains links to other web applications.
-#
-
-SCRIPT_DIR=$(dirname $0)
-PROJ=$1
-if [[ "$PROJ" == "" ]]; then
-	PROJ=$SCRIPT_DIR/target
-fi
-PROJ=$PROJ/ROOT-war
-
-mkdir -p $PROJ/WEB-INF
-echo '<?xml version="1.0"?>
-<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-</web-app>' > $PROJ/WEB-INF/web.xml
-
-echo '
-<html>
-<body>
-<script type="text/javascript">
-
-  var _gaq = _gaq || [];
-  _gaq.push(["_setAccount", "UA-29830061-2"]);
-  _gaq.push(["_trackPageview"]);
-
-  (function() {
-    var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
-    ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
-    var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
-  })();
-
-</script>
-<h1>TimeMachine Scheduler</h1>
-<ul>
-<li><a href="http://tmschedulerdemo-zdeng.rhcloud.com/scheduler-demo">Scheduler Demo</a></li>
-<li><a href="http://tmschedulersite-zdeng.rhcloud.com/scheduler-site">Scheduler Maven Site Reports</a></li>
-</ul>
-</body>
-</html> 
-' > $PROJ/index.html
-
-if [[ -e $PROJ/../ROOT.war ]]; then
-	rm -vf $PROJ/../ROOT.war
-fi
-jar -cvf $PROJ/../ROOT.war -C $PROJ .
-rm -rf $PROJ
-
-echo "$PROJ/../ROOT.war is created."

File timemachine-dist/src/main/assembly/bin.xml

 			<includes>
 				<include>org.bitbucket.timemachine:timemachine-scheduler</include>
 				<include>org.bitbucket.timemachine:timemachine-hibernate</include>
-				<include>org.bitbucket.timemachine:timemachine-web</include>
 				<include>org.bitbucket.timemachine:timemachine-dist</include>
 			</includes>
 			<sources>

File timemachine-hibernate/config/scripting-scheduler.properties

+# Use configure scripting service that take -Dscript parameter as input to run
 timemachine.scheduler.userservice.scriptingService.class = timemachine.scheduler.userservice.ScriptingService
 ScriptingService.scriptEngineName = Groovy
 ScriptingService.initScript = ${script}
 
-timemachine.scheduler.schedulerName = TimeMachineScheduler
-timemachine.scheduler.nodeName = Node1
-
-# Use MySQL for scheduler as data store
+# Configure a dataStore service you want the script to operate on.
 timemachine.scheduler.dataStore.class = timemachine.scheduler.hibernate.HibernateDataStore
-timemachine.scheduler.dataStore.hibernateDataStore.hibernate.hbm2ddl.auto = update
-
 timemachine.scheduler.dataStore.hibernateDataStore.hibernate.connection.driver_class = com.mysql.jdbc.Driver
 timemachine.scheduler.dataStore.hibernateDataStore.hibernate.connection.url = jdbc:mysql://localhost:3306/tmscheduler
 timemachine.scheduler.dataStore.hibernateDataStore.hibernate.connection.username = admin

File timemachine-hibernate/pom.xml

 				</dependency>
 			</dependencies>
 		</profile>
+		<!-- For testing purpose, we will add groovy profile -->
+		<profile>
+			<id>groovy</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.codehaus.groovy</groupId>
+					<artifactId>groovy-jsr223</artifactId>
+					<version>2.0.0</version>
+				</dependency>
+			</dependencies>
+		</profile>
 	</profiles>
 </project>

File timemachine-scheduler/src/main/java/timemachine/scheduler/JobDef.java

 		return props;
 	}
 	
+	public void setProps(Map<String, String> props) {
+		this.props = props;
+	}
+	
 	public JobDef putProp(String key, String value) {
 		props.put(key, value);
 		return this;

File timemachine-scheduler/src/main/java/timemachine/scheduler/jobtask/LoggerJobTask.java

  * @author Zemian Deng
  */
 public class LoggerJobTask implements JobTask {
-	public static Logger logger = LoggerFactory.getLogger(LoggerJobTask.class);
-	public static String MSG_KEY = "msg";
-
+	private static Logger logger = LoggerFactory.getLogger(LoggerJobTask.class);
+	public static final String MSG_KEY = "msg";
+	
 	@Override
 	public void run(JobContext jobContext) {
 		JobDef jobDef = jobContext.getJobDef();

File timemachine-scheduler/src/main/java/timemachine/scheduler/jobtask/SleepyJobTask.java

  */
 public class SleepyJobTask implements JobTask {
 	private static Logger logger = LoggerFactory.getLogger(SleepyJobTask.class);
-	public static String SLEEP_TIME_KEY = "sleepTime";
+	public static final String SLEEP_TIME_KEY = "sleepTime";
 
 	@Override
 	public void run(JobContext jobContext) {

File timemachine-scheduler/src/main/java/timemachine/scheduler/service/JobListenerService.java

  */
 public class JobListenerService extends AbstractService implements JobListener {
 
-	protected Scheduler scheduler;
+	private Scheduler scheduler;
+	
+	public Scheduler getScheduler() {
+		return scheduler;
+	}
 
 	@Override
 	public void onScheduler(Scheduler scheduler) {

File timemachine-scheduler/src/main/java/timemachine/scheduler/service/MemoryDataStore.java

  */
 package timemachine.scheduler.service;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 		// this job def, then remove it.
 		List<Schedule> schedulesToDel = new ArrayList<Schedule>();
 		for (Schedule schedule : nodeStore.getSchedules().values()) {
-			if (schedule.getJobDefId() == jobDef.getId() && !jobDefScheduleKeys.contains(schedule.getId()))
+			if (schedule.getJobDefId().equals(jobDef.getId()) && !jobDefScheduleKeys.contains(schedule.getId()))
 				schedulesToDel.add(schedule);
 		}
 		if (schedulesToDel.size() > 0) {
 	}
 
 	/** Comparator for sorting EventHistory in descending order by createTime then id. */
-	public static class EventHistoryComparator implements Comparator<EventHistory> {
+	public static class EventHistoryComparator implements Comparator<EventHistory>, Serializable {
+		private static final long serialVersionUID = 1L;
 
 		@Override
 		public int compare(EventHistory o1, EventHistory o2) {

File timemachine-scheduler/src/main/java/timemachine/scheduler/support/ProcessUtils.java

 				public void run() {
 					InputStream inStream = process.getInputStream();
 					try {
-						BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
+						InputStreamReader isReader = new InputStreamReader(inStream);
+						BufferedReader reader = new BufferedReader(isReader);
 						String line = null;
 						while ((line = reader.readLine()) != null) {
 							lineAction.onLine(line);

File timemachine-scheduler/src/main/java/timemachine/scheduler/support/ScheduleComparator.java

  */
 package timemachine.scheduler.support;
 
+import java.io.Serializable;
 import java.util.Comparator;
 import java.util.Date;
 
  * </ul>
  * @author Zemian Deng
  */
-public class ScheduleComparator implements Comparator<Schedule> {
+public class ScheduleComparator implements Comparator<Schedule>, Serializable {
+	private static final long serialVersionUID = 1L;
 	private static final int EQUAL = 0; // Do not move
 	private static final int LEFT = -1; // Move to top (first)
 	private static final int RIGHT = 1; // Move to bottom (last)
 		// Compare by default using hashCode
 		return this.hashCode() == obj.hashCode();
 	}
+	
+	/** Call super.hashCode() just to satisfy Java contract when overriding equals(). */
+	@Override
+	public int hashCode() {
+		return super.hashCode();
+	}
 }

File timemachine-web/src/main/java/timemachine/scheduler/web/HealthServlet.java

 	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
 	{
 		long startTime = ((Date)getServletContext().getAttribute("webappStartTime")).getTime();
-		String webappUpTime = DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - startTime); 
+		String webappUpTime = DurationFormatUtils.formatDurationISO(System.currentTimeMillis() - startTime); 
 		logger.trace("Getting health info.");
 		req.setAttribute("serverInfo", getServletContext().getServerInfo());
 		req.setAttribute("serverTime", new Date().getTime());