JmsSchedulerTest give it more time to handle slow machines and add some debugging

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@934839 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-04-16 12:14:52 +00:00
parent 952d036856
commit fab6ba187d
4 changed files with 22 additions and 2 deletions

View File

@ -20,7 +20,9 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.kahadb.journal.Location;
import org.apache.kahadb.util.VariableMarshaller;
@ -183,6 +185,12 @@ class JobLocation {
return this.location;
}
public String toString() {
return "Job [id=" + jobId + ", startTime=" + new Date(startTime)
+ ", delay=" + delay + ", period=" + period + ", repeat="
+ repeat + ", nextTime=" + new Date(nextTime) + "]";
}
static class JobLocationMarshaller extends VariableMarshaller<List<JobLocation>> {
static final JobLocationMarshaller INSTANCE = new JobLocationMarshaller();
public List<JobLocation> readPayload(DataInput dataIn) throws IOException {

View File

@ -25,7 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.MessageFormatException;
import org.apache.activemq.util.IdGenerator;
import org.apache.activemq.util.ServiceStopper;
import org.apache.activemq.util.ServiceSupport;
@ -286,6 +288,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
jobLocation.setDelay(delay);
jobLocation.setPeriod(period);
jobLocation.setRepeat(repeat);
if (LOG.isDebugEnabled()) {
LOG.debug("Scheduling " + jobLocation);
}
storeJob(tx, jobLocation, time);
this.scheduleTime.newJob();
}
@ -410,6 +415,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
}
void fireJob(JobLocation job) throws IllegalStateException, IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("Firing " + job);
}
ByteSequence bs = this.store.getPayload(job.getLocation());
for (JobListener l : jobListeners) {
l.scheduledJob(job.getJobId(), bs);
@ -506,6 +514,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
// rescheduled from this execution time
remove(executionTime);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Not yet time to execute the job, waiting " + (executionTime - currentTime) + " ms");
}
this.scheduleTime.setWaitTime(executionTime - currentTime);
}
}

View File

@ -70,8 +70,8 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
JobScheduler js = sb.getJobScheduler();
List<Job> list = js.getAllJobs();
assertEquals(1, list.size());
latch.await(120,TimeUnit.SECONDS);
assertEquals(COUNT,count.get());
latch.await(240, TimeUnit.SECONDS);
assertEquals(COUNT, count.get());
}
public void testSchedule() throws Exception {

View File

@ -20,6 +20,7 @@
#
log4j.rootLogger=INFO, out, stdout
log4j.logger.org.apache.activemq.broker.scheduler=DEBUG
#log4j.logger.org.apache.activemq=DEBUG
#log4j.logger.org.apache.activemq.store.jdbc=DEBUG
#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG