use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest method testTopologyChange.
/**
* @throws Exception If failed.
*/
public void testTopologyChange() throws Exception {
ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid());
// Warm up.
List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
List<UUID> orderedNodes = getSpi().getNodeIds(ses);
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
// Remove node.
UUID doomed = orderedNodes.get(0);
if (getSpiContext().localNode().id().equals(doomed))
doomed = orderedNodes.get(1);
getSpiContext().removeNode(doomed);
assertTrue(allNodes.remove(new GridTestNode(doomed)));
orderedNodes = getSpi().getNodeIds(ses);
assertFalse("Balancer uses removed node", orderedNodes.contains(doomed));
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
// Add node.
ClusterNode newNode = new GridTestNode(UUID.randomUUID());
getSpiContext().addNode(newNode);
assertTrue(allNodes.add(newNode));
// Check that new node was added to balancing.
boolean foundNewNode = false;
for (int i = 0; i < allNodes.size(); i++) {
ClusterNode node = getSpi().getBalancedNode(ses, allNodes, new GridTestJob());
if (newNode.id().equals(node.id())) {
foundNewNode = true;
break;
}
}
assertTrue("Balancer doesn't use added node", foundNewNode);
orderedNodes = getSpi().getNodeIds(ses);
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridTopologyHeapSizeSelfTest method testTopologyHeapSizeForNodesWithDifferentPids.
/** */
public void testTopologyHeapSizeForNodesWithDifferentPids() {
GridTestNode node1 = getNode("123456789ABC", 1000);
GridTestNode node2 = getNode("123456789ABC", 1001);
double size1 = U.heapSize(node1, 10);
double size2 = U.heapSize(node2, 10);
double allSize = U.heapSize(F.asList((ClusterNode) node1, node2), 10);
assertEquals(size1 + size2, allSize, 1E-5);
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class AbstractAffinityFunctionSelfTest method checkNodeRemoved.
/**
* @throws Exception If failed.
*/
protected void checkNodeRemoved(int backups, int neighborsPerHost, int neighborsPeriod) throws Exception {
AffinityFunction aff = affinityFunction();
int nodesCnt = 50;
List<ClusterNode> nodes = new ArrayList<>(nodesCnt);
List<List<ClusterNode>> prev = null;
for (int i = 0; i < nodesCnt; i++) {
info("======================================");
info("Assigning partitions: " + i);
info("======================================");
ClusterNode node = new GridTestNode(UUID.randomUUID());
if (neighborsPerHost > 0)
node.attribute(MAC_PREF + ((i / neighborsPeriod) % (nodesCnt / neighborsPerHost)));
nodes.add(node);
DiscoveryEvent discoEvt = new DiscoveryEvent(node, "", EventType.EVT_NODE_JOINED, node);
GridAffinityFunctionContextImpl ctx = new GridAffinityFunctionContextImpl(nodes, prev, discoEvt, new AffinityTopologyVersion(i), backups);
List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
info("Assigned.");
verifyAssignment(assignment, backups, aff.partitions(), nodes.size());
prev = assignment;
}
info("======================================");
info("Will remove nodes.");
info("======================================");
for (int i = 0; i < nodesCnt - 1; i++) {
info("======================================");
info("Assigning partitions: " + i);
info("======================================");
ClusterNode rmv = nodes.remove(nodes.size() - 1);
DiscoveryEvent discoEvt = new DiscoveryEvent(rmv, "", EventType.EVT_NODE_LEFT, rmv);
List<List<ClusterNode>> assignment = aff.assignPartitions(new GridAffinityFunctionContextImpl(nodes, prev, discoEvt, new AffinityTopologyVersion(i), backups));
info("Assigned.");
verifyAssignment(assignment, backups, aff.partitions(), nodes.size());
prev = assignment;
}
}
Aggregations