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