Search in sources :

Example 6 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession 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 7 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession 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 8 with GridTestTaskSession

use of org.apache.ignite.GridTestTaskSession 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)

Example 9 with GridTestTaskSession

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

the class GridJobStealingFailoverSpiOneNodeSelfTest 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(JobStealingCollisionSpi.THIEF_NODE_ATTR, getSpiContext().localNode().id());
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), Collections.singletonList(getSpiContext().remoteNodes().iterator().next()));
    assert other == rmt : "Invalid failed-over node: " + other;
}
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 10 with GridTestTaskSession

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

the class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest method testBalancingOneNode.

/**
     * @throws Exception If test failed.
     */
public void testBalancingOneNode() throws Exception {
    ComputeTaskSession ses = new GridTestTaskSession();
    List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
    List<ClusterNode> balancedNode = Arrays.asList(allNodes.get(0));
    ClusterNode firstNode = getSpi().getBalancedNode(ses, balancedNode, new GridTestJob());
    ClusterNode secondNode = getSpi().getBalancedNode(ses, balancedNode, new GridTestJob());
    assertEquals(firstNode, secondNode);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) List(java.util.List) GridTestJob(org.apache.ignite.GridTestJob) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession)

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