Search in sources :

Example 26 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testThiefIdNotSet.

/**
     * @throws Exception If test failed.
     */
public void testThiefIdNotSet() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes()));
    assert other != null;
    assert other != rmt;
    assert other.equals(getSpiContext().localNode());
    checkAttributes(failed.getJobContext(), rmt, 1);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext)

Example 27 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testNonZeroFailoverCount.

/**
     * @throws Exception If test failed.
     */
public void testNonZeroFailoverCount() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    failed.getJobContext().setAttribute(FAILOVER_ATTEMPT_COUNT_ATTR, getSpi().getMaximumFailoverAttempts() - 1);
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes()));
    assert other != null;
    assert other != rmt;
    assert other == getSpiContext().localNode();
    checkAttributes(failed.getJobContext(), rmt, getSpi().getMaximumFailoverAttempts());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext)

Example 28 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testMaxHopsExceeded.

/**
     * @throws Exception If test failed.
     */
public void testMaxHopsExceeded() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    failed.getJobContext().setAttribute(THIEF_NODE_ATTR, getSpiContext().localNode().id());
    failed.getJobContext().setAttribute(FAILOVER_ATTEMPT_COUNT_ATTR, getSpi().getMaximumFailoverAttempts());
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes()));
    assert other == null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext)

Example 29 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession in project ignite by apache.

the class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest method testTopologyChange.

/**
     * @throws Exception If failed.
     */
public void testTopologyChange() throws Exception {
    ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid());
    // Warm up.
    List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
    List<UUID> orderedNodes = getSpi().getNodeIds(ses);
    checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
    // Remove node.
    UUID doomed = orderedNodes.get(0);
    if (getSpiContext().localNode().id().equals(doomed))
        doomed = orderedNodes.get(1);
    getSpiContext().removeNode(doomed);
    assertTrue(allNodes.remove(new GridTestNode(doomed)));
    orderedNodes = getSpi().getNodeIds(ses);
    assertFalse("Balancer uses removed node", orderedNodes.contains(doomed));
    checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
    // Add node.
    ClusterNode newNode = new GridTestNode(UUID.randomUUID());
    getSpiContext().addNode(newNode);
    assertTrue(allNodes.add(newNode));
    // Check that new node was added to balancing.
    boolean foundNewNode = false;
    for (int i = 0; i < allNodes.size(); i++) {
        ClusterNode node = getSpi().getBalancedNode(ses, allNodes, new GridTestJob());
        if (newNode.id().equals(node.id())) {
            foundNewNode = true;
            break;
        }
    }
    assertTrue("Balancer doesn't use added node", foundNewNode);
    orderedNodes = getSpi().getNodeIds(ses);
    checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) List(java.util.List) UUID(java.util.UUID) GridTestJob(org.apache.ignite.GridTestJob) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Aggregations

GridTestTaskSession (org.apache.ignite.GridTestTaskSession)29 ClusterNode (org.apache.ignite.cluster.ClusterNode)29 GridTestJob (org.apache.ignite.GridTestJob)14 GridTestNode (org.apache.ignite.testframework.GridTestNode)14 GridTestJobResult (org.apache.ignite.GridTestJobResult)13 GridFailoverTestContext (org.apache.ignite.spi.failover.GridFailoverTestContext)13 ArrayList (java.util.ArrayList)12 ComputeTaskSession (org.apache.ignite.compute.ComputeTaskSession)10 List (java.util.List)7 UUID (java.util.UUID)5 ComputeJobResult (org.apache.ignite.compute.ComputeJobResult)2 TaskEvent (org.apache.ignite.events.TaskEvent)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteException (org.apache.ignite.IgniteException)1