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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations