Search in sources :

Example 31 with GridCollisionTestContext

use of org.apache.ignite.spi.collision.GridCollisionTestContext in project ignite by apache.

the class GridFifoQueueCollisionSpiSelfTest method testCollision3.

/**
 * @throws Exception If failed.
 */
@Test
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();
        }
    }
}
Also used : GridCollisionTestContext(org.apache.ignite.spi.collision.GridCollisionTestContext) CollisionJobContext(org.apache.ignite.spi.collision.CollisionJobContext) GridTestCollisionJobContext(org.apache.ignite.spi.collision.GridTestCollisionJobContext) GridTestCollisionJobContext(org.apache.ignite.spi.collision.GridTestCollisionJobContext) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) GridSpiAbstractTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest) Test(org.junit.Test)

Example 32 with GridCollisionTestContext

use of org.apache.ignite.spi.collision.GridCollisionTestContext in project ignite by apache.

the class GridFifoQueueCollisionSpiSelfTest method testCollision2.

/**
 * @throws Exception If failed.
 */
@Test
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();
}
Also used : GridCollisionTestContext(org.apache.ignite.spi.collision.GridCollisionTestContext) CollisionJobContext(org.apache.ignite.spi.collision.CollisionJobContext) GridTestCollisionJobContext(org.apache.ignite.spi.collision.GridTestCollisionJobContext) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) GridSpiAbstractTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest) Test(org.junit.Test)

Aggregations

CollisionJobContext (org.apache.ignite.spi.collision.CollisionJobContext)32 GridCollisionTestContext (org.apache.ignite.spi.collision.GridCollisionTestContext)32 GridSpiAbstractTest (org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest)31 GridSpiTest (org.apache.ignite.testframework.junits.spi.GridSpiTest)31 Test (org.junit.Test)31 GridTestCollisionJobContext (org.apache.ignite.spi.collision.GridTestCollisionJobContext)25 Serializable (java.io.Serializable)16 ClusterNode (org.apache.ignite.cluster.ClusterNode)13 ArrayList (java.util.ArrayList)9 GridTestCollisionTaskSession (org.apache.ignite.spi.collision.GridTestCollisionTaskSession)5 GridTestNode (org.apache.ignite.testframework.GridTestNode)3 GridTestJobContext (org.apache.ignite.GridTestJobContext)2 CI1 (org.apache.ignite.internal.util.typedef.CI1)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1