use of org.apache.ignite.GridTestTaskSession in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest method testNodeNotInTopology.
/** */
public void testNodeNotInTopology() throws Exception {
ComputeTaskSession ses = new GridTestTaskSession();
ClusterNode node = new GridTestNode(UUID.randomUUID());
List<ClusterNode> notInTop = Arrays.asList(node);
try {
getSpi().getBalancedNode(ses, notInTop, new GridTestJob());
} catch (IgniteException e) {
assertTrue(e.getMessage().contains("Task topology does not have alive nodes"));
}
}
use of org.apache.ignite.GridTestTaskSession in project ignite by apache.
the class GridNeverFailoverSpiSelfTest method testAlwaysNull.
/**
* @throws Exception If failed.
*/
public void testAlwaysNull() throws Exception {
List<ClusterNode> nodes = new ArrayList<>();
ClusterNode node = new GridTestNode(UUID.randomUUID());
nodes.add(node);
assert getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), new GridTestJobResult(node)), nodes) == null;
}
use of org.apache.ignite.GridTestTaskSession in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest method testWeights.
/**
* @throws Exception If failed.
*/
public void testWeights() throws Exception {
// Seal it.
List<ClusterNode> nodes = new ArrayList<>(getSpiContext().remoteNodes());
int[] cnts = new int[RMT_NODE_CNT];
// Invoke load balancer a large number of times, so statistics won't lie.
for (int i = 0; i < 50000; i++) {
GridTestNode node = (GridTestNode) getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
int idx = ((Double) node.attribute("load")).intValue() - 1;
if (cnts[idx] == 0)
node.setAttribute("used", true);
// Increment number of times a node was picked.
cnts[idx]++;
}
info("Node counts: " + Arrays.toString(cnts));
for (int i = 0; i < cnts.length - 1; i++) {
assert cnts[i] > cnts[i + 1] : "Invalid node counts for index [idx=" + i + ", cnts[i]=" + cnts[i] + ", cnts[i+1]=" + cnts[i + 1] + ']';
}
}
use of org.apache.ignite.GridTestTaskSession in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiSelfTest method testSingleNodeDifferentSession.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "ObjectEquality" })
public void testSingleNodeDifferentSession() throws Exception {
GridTestNode node = (GridTestNode) getSpiContext().nodes().iterator().next();
node.addAttribute("load", 2d);
List<ClusterNode> nodes = Collections.singletonList((ClusterNode) node);
GridTestNode pick1 = (GridTestNode) getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
pick1.setAttribute("used", true);
assert nodes.contains(pick1);
// Verify that same instance is returned every time.
ClusterNode pick2 = getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
assert pick1 == pick2;
}
use of org.apache.ignite.GridTestTaskSession in project ignite by apache.
the class GridJobStealingFailoverSpiSelfTest method testThiefNotInTopology.
/**
* @throws Exception If test failed.
*/
public void testThiefNotInTopology() throws Exception {
ClusterNode rmt = new GridTestNode(UUID.randomUUID());
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 getSpiContext().nodes().contains(other);
checkAttributes(failed.getJobContext(), rmt, 1);
}
Aggregations