use of net.dempsy.container.ContainerJob in project Dempsy by Dempsy.
the class TestThreadingModel method submitOne.
private void submitOne(final ThreadingModel ut, final Object waitOnMe, final AtomicLong sequence, final AtomicLong numPending, final AtomicLong numRejected, final AtomicLong numCompleted, final AtomicLong numCompletedSuccessfully) {
waitOnSignal = true;
ut.submitLimited(new MessageDeliveryJob() {
// long seq = sequence.getAndIncrement();
@Override
public void rejected(final boolean stopping) {
numRejected.incrementAndGet();
numCompleted.incrementAndGet();
}
@Override
public void individuatedJobsComplete() {
}
@Override
public List<ContainerJob> individuate() {
return List.of(new ContainerJob() {
@Override
public void reject(final ContainerJobMetadata container) {
numRejected.incrementAndGet();
numCompleted.incrementAndGet();
}
@Override
public void execute(final ContainerJobMetadata container) {
numPending.incrementAndGet();
synchronized (waitOnMe) {
if (waitOnSignal)
ignore(() -> waitOnMe.wait());
}
numPending.decrementAndGet();
numCompletedSuccessfully.incrementAndGet();
numCompleted.incrementAndGet();
}
});
}
@Override
public void executeAllContainers() {
synchronized (waitOnMe) {
numPending.incrementAndGet();
synchronized (waitOnMe) {
if (waitOnSignal)
ignore(() -> waitOnMe.wait());
}
numPending.decrementAndGet();
numCompletedSuccessfully.incrementAndGet();
numCompleted.incrementAndGet();
}
}
@Override
public boolean containersCalculated() {
return true;
}
@Override
public ContainerJobMetadata[] containerData() {
return new ContainerJobMetadata[] { new ContainerJobMetadata(container, null) };
}
@Override
public void calculateContainers() {
}
});
}
Aggregations