<%@ page import="com.liferay.portal.kernel.scheduler.*" %> <%@ page import="com.liferay.portal.kernel.scheduler.TimeUnit" %> <%@ page import="com.liferay.portal.kernel.scheduler.Trigger" %> <%@ page import="com.liferay.portal.kernel.scheduler.TriggerFactoryUtil" %> <%@ page import="com.liferay.portal.kernel.scheduler.messaging.*" %> <%@ page import="java.util.*" %> <% try { System.out.println("\n***************************Test Clustered Scheduler Memory Job**********************************\n"); System.out.println("\n**********************Current Jobs************************"); List jobs = SchedulerEngineHelperUtil.getScheduledJobs(); for(SchedulerResponse job : jobs) { System.out.println("Job (name: " + job.getJobName() + ", group: " + job.getGroupName()+ " , type : " + job.getStorageType() + ", state : " + SchedulerEngineHelperUtil.getJobState(job) + ")"); } System.out.println("\n*********************Starting Trigger **********************"); // Trigger object will stop after 3600000 milliseconds or 60 minutes Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + 3600000); System.out.println("Start date is: " + startDate); System.out.println("End date is: " + endDate + "\n"); Trigger trigger = TriggerFactoryUtil.createTrigger("memory", "memory", startDate, endDate, 60, TimeUnit.SECOND); System.out.println("\n***Add memory job with jobName (memory), groupName(memory)***"); // The Job is currently set to refire every 60 seconds SchedulerEngineHelperUtil.addScriptingJob(trigger, StorageType.MEMORY_CLUSTERED, "", "python", "import datetime; from java.lang import System; System.setProperty('test', 'true');print 'Memory job is triggered at ' + str(datetime.datetime.now())", 0); Thread.sleep(90000); System.out.println("\n******************Current jobs, after add job(jobName:memory, groupName:memory)********************"); jobs = SchedulerEngineHelperUtil.getScheduledJobs(); for(SchedulerResponse job : jobs) { System.out.println("Job (name: " + job.getJobName() + ", group: " + job.getGroupName()+ " , type : " + job.getStorageType() + ", state : " + SchedulerEngineHelperUtil.getJobState(job) + ")"); } } catch(Exception e) { } %>