use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class RendezvousAffinityFunctionSimpleBenchmark method createBaseNodes.
/**
* @param nodesCnt Count of nodes to generate.
* @return Nodes list.
*/
private List<ClusterNode> createBaseNodes(int nodesCnt) {
List<ClusterNode> nodes = new ArrayList<>(nodesCnt);
for (int i = 0; i < nodesCnt; i++) {
GridTestNode node = new GridTestNode(UUID.randomUUID());
// two neighbours nodes
node.setAttribute(IgniteNodeAttributes.ATTR_MACS, MAC_PREF + i / 2);
nodes.add(node);
}
return nodes;
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class RendezvousAffinityFunctionSimpleBenchmark method addNode.
/**
* @param nodes Topology.
* @param iter Iteration count.
* @return Discovery event.
*/
@NotNull
private DiscoveryEvent addNode(List<ClusterNode> nodes, int iter) {
GridTestNode node = new GridTestNode(UUID.randomUUID());
// two neighbours nodes
node.setAttribute(IgniteNodeAttributes.ATTR_MACS, MAC_PREF + "_add_" + iter / 4);
nodes.add(node);
return new DiscoveryEvent(nodes.get(0), "", EventType.EVT_NODE_JOINED, node);
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiSelfTest method testSingleNodeZeroWeight.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "ObjectEquality" })
public void testSingleNodeZeroWeight() throws Exception {
GridTestNode node = (GridTestNode) getSpiContext().nodes().iterator().next();
node.addAttribute("load", 0d);
List<ClusterNode> nodes = Collections.singletonList((ClusterNode) node);
ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid());
GridTestNode pick1 = (GridTestNode) getSpi().getBalancedNode(ses, nodes, new GridTestJob());
pick1.setAttribute("used", true);
assert nodes.contains(pick1);
// Verify that same instance is returned every time.
ClusterNode pick2 = getSpi().getBalancedNode(ses, nodes, new GridTestJob());
assert pick1 == pick2;
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiSelfTest method testSingleNodeSameSession.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "ObjectEquality" })
public void testSingleNodeSameSession() throws Exception {
GridTestNode node = (GridTestNode) getSpiContext().nodes().iterator().next();
node.addAttribute("load", 1d);
List<ClusterNode> nodes = Collections.singletonList((ClusterNode) node);
ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid());
GridTestNode pick1 = (GridTestNode) getSpi().getBalancedNode(ses, nodes, new GridTestJob());
pick1.setAttribute("used", true);
assert nodes.contains(pick1);
// Verify that same instance is returned every time.
ClusterNode pick2 = getSpi().getBalancedNode(ses, nodes, new GridTestJob());
assert pick1 == pick2;
}
use of org.apache.ignite.testframework.GridTestNode 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);
}
Aggregations