Search in sources :

Example 1 with GridFailoverTestContext

use of org.apache.ignite.spi.failover.GridFailoverTestContext in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testMaxHopsExceededThiefNotSet.

/**
     * @throws Exception If test failed.
     */
public void testMaxHopsExceededThiefNotSet() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    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 2 with GridFailoverTestContext

use of org.apache.ignite.spi.failover.GridFailoverTestContext in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testThiefEqualsVictim.

/**
     * @throws Exception If test failed.
     */
public void testThiefEqualsVictim() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    failed.getJobContext().setAttribute(THIEF_NODE_ATTR, rmt.id());
    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 3 with GridFailoverTestContext

use of org.apache.ignite.spi.failover.GridFailoverTestContext in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testFailover.

/**
     * @throws Exception If test failed.
     */
public void testFailover() throws Exception {
    ClusterNode rmt = getSpiContext().remoteNodes().iterator().next();
    GridTestJobResult failed = new GridTestJobResult(rmt);
    failed.getJobContext().setAttribute(THIEF_NODE_ATTR, getSpiContext().localNode().id());
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes()));
    assert other == getSpiContext().localNode();
    // This is not a failover but stealing.
    checkAttributes(failed.getJobContext(), null, 0);
}
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 4 with GridFailoverTestContext

use of org.apache.ignite.spi.failover.GridFailoverTestContext in project ignite by apache.

the class GridAlwaysFailoverSpiSelfTest method testTwoNodes.

/**
     * @throws Exception If test failed.
     */
@SuppressWarnings("unchecked")
public void testTwoNodes() throws Exception {
    AlwaysFailoverSpi spi = getSpi();
    List<ClusterNode> nodes = new ArrayList<>();
    nodes.add(new GridTestNode(UUID.randomUUID()));
    nodes.add(new GridTestNode(UUID.randomUUID()));
    ComputeJobResult jobRes = new GridTestJobResult(nodes.get(0));
    ClusterNode node = spi.failover(new GridFailoverTestContext(new GridTestTaskSession(), jobRes), nodes);
    assert node != null;
    assert node.equals(nodes.get(1));
    checkFailedNodes(jobRes, 1);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridTestNode(org.apache.ignite.testframework.GridTestNode) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult)

Example 5 with GridFailoverTestContext

use of org.apache.ignite.spi.failover.GridFailoverTestContext in project ignite by apache.

the class GridAlwaysFailoverSpiSelfTest method testMaxAttempts.

/**
     * @throws Exception If failed.
     */
public void testMaxAttempts() throws Exception {
    AlwaysFailoverSpi spi = getSpi();
    spi.setMaximumFailoverAttempts(1);
    List<ClusterNode> nodes = new ArrayList<>();
    nodes.add(new GridTestNode(UUID.randomUUID()));
    nodes.add(new GridTestNode(UUID.randomUUID()));
    ComputeJobResult jobRes = new GridTestJobResult(nodes.get(0));
    // First attempt.
    ClusterNode node = spi.failover(new GridFailoverTestContext(new GridTestTaskSession(), jobRes), nodes);
    assert node != null;
    assert node.equals(nodes.get(1));
    checkFailedNodes(jobRes, 1);
    // Second attempt (exceeds default max attempts of 1).
    node = spi.failover(new GridFailoverTestContext(new GridTestTaskSession(), jobRes), nodes);
    assert node == null;
    checkFailedNodes(jobRes, 1);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridTestNode(org.apache.ignite.testframework.GridTestNode) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult)

Aggregations

GridTestJobResult (org.apache.ignite.GridTestJobResult)13 GridTestTaskSession (org.apache.ignite.GridTestTaskSession)13 ClusterNode (org.apache.ignite.cluster.ClusterNode)13 GridFailoverTestContext (org.apache.ignite.spi.failover.GridFailoverTestContext)13 GridTestNode (org.apache.ignite.testframework.GridTestNode)5 ArrayList (java.util.ArrayList)4 ComputeJobResult (org.apache.ignite.compute.ComputeJobResult)2