Skip to content

Commit

Permalink
SAK-13696, SAK-18864
Browse files Browse the repository at this point in the history
1) altered AbstractConfigurableJob to use getMergedDataMap() instead of getTrigger().getMergedDataMap(). Also updated README file to indicate this distinction
2) implemented hibernate storage for trigger event longs so they are persistent and available across a cluster


git-svn-id: https://source.sakaiproject.org/svn/jobscheduler/branches/SAK-18864@81958 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
Duffy Gillman committed Aug 27, 2010
1 parent 90dc0bb commit 1edc475
Show file tree
Hide file tree
Showing 16 changed files with 606 additions and 45 deletions.
4 changes: 3 additions & 1 deletion jobscheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<module>scheduler-assembly</module>
<module>scheduler-component</module>
<module>scheduler-component-shared</module>
<module>scheduler-events-model</module>
<module>scheduler-tool</module>
</modules>
</profile>
Expand All @@ -45,9 +46,10 @@
<module>scheduler-assembly</module>
<module>scheduler-component</module>
<module>scheduler-component-shared</module>
<module>scheduler-tool</module>
<module>scheduler-configurable-job-test-component</module>
<module>scheduler-configurable-job-test-component-shared</module>
<module>scheduler-events-model</module>
<module>scheduler-tool</module>
</modules>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
**********************************************************************************/
package org.sakaiproject.api.app.scheduler;

import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.sql.DataSource;

import org.quartz.JobListener;
import org.quartz.Scheduler;
import org.quartz.TriggerListener;

Expand All @@ -34,15 +37,35 @@ public interface SchedulerManager
{

/**
* @deprecated use {@link #getGlobalTriggerListeners()}
* @return Returns the globalTriggerListener.
*/
public TriggerListener getGlobalTriggerListener();

/**
* @deprecated use {@link #setGlobalTriggerListeners(List<TriggerListener>)}
* @param globalTriggerListener The globalTriggerListener to set.
*/
public void setGlobalTriggerListener(TriggerListener globalTriggerListener);

/**
* Registers a List of TriggerListeners which will be registered to respond to events on all Triggers
*
* @param globalTriggerListeners
*/
public void setGlobalTriggerListeners(List<TriggerListener> globalTriggerListeners);

public List<TriggerListener> getGlobalTriggerListeners();

/**
* Registers a List of JobListeners which will be registered to respond to events on all Triggers
*
* @param globalJobListeners
*/
public void setGlobalJobListeners(List<JobListener> globalJobListeners);

public List<JobListener> getGlobalJobListeners();

/**
* @return Returns the serverId.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.sakaiproject.api.app.scheduler.events;

import java.util.Date;

/**
* Created by IntelliJ IDEA.
* User: duffy
* Date: Aug 26, 2010
* Time: 3:39:51 PM
* To change this template use File | Settings | File Templates.
*/
public interface TriggerEvent
{
public static enum TRIGGER_EVENT_TYPE
{
FIRED, COMPLETE, INFO, DEBUG, ERROR
}

public TRIGGER_EVENT_TYPE getEventType();

public String getJobName();

public String getTriggerName();

public Date getTime();

public String getMessage();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.sakaiproject.api.app.scheduler.events;

import java.util.Date;
import java.util.List;

/**
* Created by IntelliJ IDEA.
* User: duffy
* Date: Aug 26, 2010
* Time: 3:40:13 PM
* To change this template use File | Settings | File Templates.
*/
public interface TriggerEventManager
{
public TriggerEvent createTriggerEvent (TriggerEvent.TRIGGER_EVENT_TYPE type, String jobName, String triggerName, Date time, String message);

public List<TriggerEvent> getTriggerEvents ();

public List<TriggerEvent> getTriggerEvents (Date after, Date before, String jobName, String triggerName, TriggerEvent.TRIGGER_EVENT_TYPE[] types);

public void purgeEvents (Date before);
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ D. AbstractConfigurableJob

When a configured job executes it must be supplied the configuration parameters the user has specified during job
creation or scheduling. These are generally available to the job from the Map of values obtained via a call to
JobExecutionEnvironment.getTrigger().getJobDataMap(). AbstractConfigurableJob provides a convenience method for
JobExecutionEnvironment.getMergedJobDataMap(). AbstractConfigurableJob provides a convenience method for
obtaining values from that map:

String getConfiguredProperty(String key);
Expand Down
14 changes: 14 additions & 0 deletions jobscheduler/scheduler-component-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>scheduler-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>scheduler-events-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
Expand All @@ -44,6 +50,14 @@
<groupId>org.opensymphony.quartz</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,31 @@

package org.sakaiproject.component.app.scheduler;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.TriggerListener;
import org.sakaiproject.api.app.scheduler.events.TriggerEvent;
import org.sakaiproject.api.app.scheduler.events.TriggerEventManager;

public class GlobalTriggerListener implements TriggerListener
{

private List<TriggerEvent> triggerEvents = new ArrayList<TriggerEvent>();
private List<TriggerEvent> todaysTriggerEvents = new ArrayList<TriggerEvent>();
private boolean isViewAllSelected = false;
private TriggerEventManager eventManager = null;

public void setTriggerEventManager (TriggerEventManager eMgr)
{
eventManager = eMgr;
}

public TriggerEventManager getTriggerEventManager()
{
return eventManager;
}

public String getName()
{
Expand All @@ -46,11 +55,7 @@ public String getName()
public void triggerFired(Trigger trigger,
JobExecutionContext jobExecutionContext)
{
TriggerEvent te = new TriggerEvent();
te.setEventType(TriggerEvent.TRIGGER_FIRED);
te.setJobName(jobExecutionContext.getJobDetail().getName());
te.setTime(new Date());
triggerEvents.add(0, te);
eventManager.createTriggerEvent (TriggerEvent.TRIGGER_EVENT_TYPE.FIRED, jobExecutionContext.getJobDetail().getName(), trigger.getName(), new Date(), "Trigger fired");
}

public boolean vetoJobExecution(Trigger trigger,
Expand All @@ -66,11 +71,7 @@ public void triggerMisfired(Trigger trigger)
public void triggerComplete(Trigger trigger,
JobExecutionContext jobExecutionContext, int triggerInstructionCode)
{
TriggerEvent te = new TriggerEvent();
te.setEventType(TriggerEvent.TRIGGER_COMPLETE);
te.setJobName(jobExecutionContext.getJobDetail().getName());
te.setTime(new Date());
triggerEvents.add(0, te);
eventManager.createTriggerEvent (TriggerEvent.TRIGGER_EVENT_TYPE.COMPLETE, jobExecutionContext.getJobDetail().getName(), trigger.getName(), new Date(), "Trigger complete");
}

/**
Expand All @@ -80,38 +81,32 @@ public List<TriggerEvent> getTriggerEvents()
{
if (isViewAllSelected)
{
return triggerEvents;
return eventManager.getTriggerEvents();
}
else
{
todaysTriggerEvents = new ArrayList<TriggerEvent>();
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

Date midnightToday = new Date(cal.getTimeInMillis());

for (Iterator<TriggerEvent> i = triggerEvents.iterator(); i.hasNext();)

return eventManager.getTriggerEvents (midnightToday, null, null, null, null);
/*
for (Iterator<TriggerEventImpl> i = triggerEvents.iterator(); i.hasNext();)
{
TriggerEvent te = (TriggerEvent) i.next();
TriggerEventImpl te = (TriggerEventImpl) i.next();
if (te.getTime().after(midnightToday))
{
todaysTriggerEvents.add(te);
}
}
return todaysTriggerEvents;
*/
}
}

/**
* @param triggerEvents The triggerEvents to set.
*/
public void setTriggerEvents(List<TriggerEvent> triggerEvents)
{
this.triggerEvents = triggerEvents;
}

/**
* @return Returns the isViewAllSelected.
*/
Expand Down
Loading

0 comments on commit 1edc475

Please sign in to comment.