use of org.apache.ignite.spi.collision.CollisionJobContext in project ignite by apache.
the class GridJobStealingCollisionSpiSelfTest method testOnePassiveZeroActive.
/**
* @throws Exception If test failed.
*/
public void testOnePassiveZeroActive() throws Exception {
List<CollisionJobContext> waitCtxs = new ArrayList<>(1);
// Add passive.
Collections.addAll(waitCtxs, new GridTestCollisionJobContext(createTaskSession(), IgniteUuid.randomUuid()));
Collection<CollisionJobContext> activeCtxs = Collections.emptyList();
ClusterNode rmtNode = F.first(getSpiContext().remoteNodes());
getSpiContext().triggerMessage(rmtNode, new JobStealingRequest(1));
getSpi().onCollision(new GridCollisionTestContext(activeCtxs, waitCtxs));
// Rejected.
checkActivated((GridTestCollisionJobContext) waitCtxs.get(0));
// Make sure that no message was sent.
Serializable msg = getSpiContext().removeSentMessage(rmtNode);
assert msg == null;
}
use of org.apache.ignite.spi.collision.CollisionJobContext in project ignite by apache.
the class GridJobStealingCollisionSpiSelfTest method testZeroPassiveOneActive.
/**
* @throws Exception If test failed.
*/
public void testZeroPassiveOneActive() throws Exception {
Collection<CollisionJobContext> empty = Collections.emptyList();
List<CollisionJobContext> activeCtxs = new ArrayList<>(1);
// Add active.
Collections.addAll(activeCtxs, new GridTestCollisionJobContext(createTaskSession(), IgniteUuid.randomUuid()));
ClusterNode rmtNode = F.first(getSpiContext().remoteNodes());
getSpiContext().triggerMessage(rmtNode, new JobStealingRequest(1));
getSpi().onCollision(new GridCollisionTestContext(activeCtxs, empty));
// Active job.
checkNoAction((GridTestCollisionJobContext) activeCtxs.get(0));
// Make sure that no message was sent.
Serializable msg = getSpiContext().removeSentMessage(rmtNode);
assert msg == null;
}
use of org.apache.ignite.spi.collision.CollisionJobContext in project ignite by apache.
the class GridFifoQueueCollisionSpiSelfTest method testCollision0.
/**
* @throws Exception If failed.
*/
public void testCollision0() throws Exception {
int activeCnt = 2;
assert getSpi().getParallelJobsNumber() > activeCnt;
GridCollisionTestContext cntx = createContext(activeCnt, getSpi().getParallelJobsNumber() - activeCnt);
Collection<CollisionJobContext> activeJobs = cntx.activeJobs();
Collection<CollisionJobContext> passiveJobs = cntx.waitingJobs();
getSpi().onCollision(new GridCollisionTestContext(activeJobs, passiveJobs));
for (CollisionJobContext ctx : passiveJobs) {
assert ((GridTestCollisionJobContext) ctx).isActivated();
assert !((GridTestCollisionJobContext) ctx).isCanceled();
}
int i = 0;
for (CollisionJobContext ctx : activeJobs) {
if (i++ < activeCnt)
assert !((GridTestCollisionJobContext) ctx).isActivated() : i;
else
assert ((GridTestCollisionJobContext) ctx).isActivated() : i;
assert !((GridTestCollisionJobContext) ctx).isCanceled();
}
}
use of org.apache.ignite.spi.collision.CollisionJobContext in project ignite by apache.
the class GridFifoQueueCollisionSpiSelfTest method testCollision2.
/**
* @throws Exception If failed.
*/
public void testCollision2() throws Exception {
getSpi().setParallelJobsNumber(3);
GridCollisionTestContext cntx = createContext(11, 0);
Collection<CollisionJobContext> activeJobs = cntx.activeJobs();
Collection<CollisionJobContext> passiveJobs = cntx.waitingJobs();
getSpi().onCollision(new GridCollisionTestContext(activeJobs, passiveJobs));
for (CollisionJobContext ctx : activeJobs) {
assert !((GridTestCollisionJobContext) ctx).isActivated();
assert !((GridTestCollisionJobContext) ctx).isCanceled();
}
assert passiveJobs.isEmpty();
}
use of org.apache.ignite.spi.collision.CollisionJobContext in project ignite by apache.
the class GridFifoQueueCollisionSpiSelfTest method testCollision3.
/**
* @throws Exception If failed.
*/
public void testCollision3() throws Exception {
getSpi().setParallelJobsNumber(15);
GridCollisionTestContext cntx = createContext(10, 10);
Collection<CollisionJobContext> activeJobs = cntx.activeJobs();
Collection<CollisionJobContext> passiveJobs = cntx.waitingJobs();
getSpi().onCollision(new GridCollisionTestContext(activeJobs, passiveJobs));
int i = 0;
for (CollisionJobContext ctx : activeJobs) {
if (i++ < 10)
assert !((GridTestCollisionJobContext) ctx).isActivated();
else
assert ((GridTestCollisionJobContext) ctx).isActivated();
assert !((GridTestCollisionJobContext) ctx).isCanceled();
}
for (CollisionJobContext ctx : passiveJobs) {
if (((GridTestCollisionJobContext) ctx).getIndex() < 5) {
assert ((GridTestCollisionJobContext) ctx).isActivated();
assert !((GridTestCollisionJobContext) ctx).isCanceled();
} else {
assert !((GridTestCollisionJobContext) ctx).isActivated();
assert !((GridTestCollisionJobContext) ctx).isCanceled();
}
}
}
Aggregations