mirror of https://github.com/apache/activemq.git
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:
parent
952d036856
commit
fab6ba187d
|
@ -20,7 +20,9 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.kahadb.journal.Location;
|
import org.apache.kahadb.journal.Location;
|
||||||
import org.apache.kahadb.util.VariableMarshaller;
|
import org.apache.kahadb.util.VariableMarshaller;
|
||||||
|
|
||||||
|
@ -183,6 +185,12 @@ class JobLocation {
|
||||||
return this.location;
|
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 class JobLocationMarshaller extends VariableMarshaller<List<JobLocation>> {
|
||||||
static final JobLocationMarshaller INSTANCE = new JobLocationMarshaller();
|
static final JobLocationMarshaller INSTANCE = new JobLocationMarshaller();
|
||||||
public List<JobLocation> readPayload(DataInput dataIn) throws IOException {
|
public List<JobLocation> readPayload(DataInput dataIn) throws IOException {
|
||||||
|
|
|
@ -25,7 +25,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.jms.MessageFormatException;
|
import javax.jms.MessageFormatException;
|
||||||
|
|
||||||
import org.apache.activemq.util.IdGenerator;
|
import org.apache.activemq.util.IdGenerator;
|
||||||
import org.apache.activemq.util.ServiceStopper;
|
import org.apache.activemq.util.ServiceStopper;
|
||||||
import org.apache.activemq.util.ServiceSupport;
|
import org.apache.activemq.util.ServiceSupport;
|
||||||
|
@ -286,6 +288,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
|
||||||
jobLocation.setDelay(delay);
|
jobLocation.setDelay(delay);
|
||||||
jobLocation.setPeriod(period);
|
jobLocation.setPeriod(period);
|
||||||
jobLocation.setRepeat(repeat);
|
jobLocation.setRepeat(repeat);
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Scheduling " + jobLocation);
|
||||||
|
}
|
||||||
storeJob(tx, jobLocation, time);
|
storeJob(tx, jobLocation, time);
|
||||||
this.scheduleTime.newJob();
|
this.scheduleTime.newJob();
|
||||||
}
|
}
|
||||||
|
@ -410,6 +415,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
void fireJob(JobLocation job) throws IllegalStateException, IOException {
|
void fireJob(JobLocation job) throws IllegalStateException, IOException {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Firing " + job);
|
||||||
|
}
|
||||||
ByteSequence bs = this.store.getPayload(job.getLocation());
|
ByteSequence bs = this.store.getPayload(job.getLocation());
|
||||||
for (JobListener l : jobListeners) {
|
for (JobListener l : jobListeners) {
|
||||||
l.scheduledJob(job.getJobId(), bs);
|
l.scheduledJob(job.getJobId(), bs);
|
||||||
|
@ -506,6 +514,9 @@ class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
|
||||||
// rescheduled from this execution time
|
// rescheduled from this execution time
|
||||||
remove(executionTime);
|
remove(executionTime);
|
||||||
} else {
|
} else {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Not yet time to execute the job, waiting " + (executionTime - currentTime) + " ms");
|
||||||
|
}
|
||||||
this.scheduleTime.setWaitTime(executionTime - currentTime);
|
this.scheduleTime.setWaitTime(executionTime - currentTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
JobScheduler js = sb.getJobScheduler();
|
JobScheduler js = sb.getJobScheduler();
|
||||||
List<Job> list = js.getAllJobs();
|
List<Job> list = js.getAllJobs();
|
||||||
assertEquals(1, list.size());
|
assertEquals(1, list.size());
|
||||||
latch.await(120,TimeUnit.SECONDS);
|
latch.await(240, TimeUnit.SECONDS);
|
||||||
assertEquals(COUNT,count.get());
|
assertEquals(COUNT, count.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSchedule() throws Exception {
|
public void testSchedule() throws Exception {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#
|
#
|
||||||
log4j.rootLogger=INFO, out, stdout
|
log4j.rootLogger=INFO, out, stdout
|
||||||
|
|
||||||
|
log4j.logger.org.apache.activemq.broker.scheduler=DEBUG
|
||||||
#log4j.logger.org.apache.activemq=DEBUG
|
#log4j.logger.org.apache.activemq=DEBUG
|
||||||
#log4j.logger.org.apache.activemq.store.jdbc=DEBUG
|
#log4j.logger.org.apache.activemq.store.jdbc=DEBUG
|
||||||
#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG
|
#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG
|
||||||
|
|
Loading…
Reference in New Issue