Search in sources :

Example 11 with GridTestNode

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ArrayList(java.util.ArrayList) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Example 12 with GridTestNode

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);
}
Also used : DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridTestNode(org.apache.ignite.testframework.GridTestNode) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with GridTestNode

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJob(org.apache.ignite.GridTestJob) GridTestNode(org.apache.ignite.testframework.GridTestNode) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession)

Example 14 with GridTestNode

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJob(org.apache.ignite.GridTestJob) GridTestNode(org.apache.ignite.testframework.GridTestNode) ComputeTaskSession(org.apache.ignite.compute.ComputeTaskSession)

Example 15 with GridTestNode

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);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridTestNode(org.apache.ignite.testframework.GridTestNode) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext) ComputeJobResult(org.apache.ignite.compute.ComputeJobResult)

Aggregations

GridTestNode (org.apache.ignite.testframework.GridTestNode)43 ClusterNode (org.apache.ignite.cluster.ClusterNode)27 GridSpiTestContext (org.apache.ignite.testframework.GridSpiTestContext)17 GridTestTaskSession (org.apache.ignite.GridTestTaskSession)14 ArrayList (java.util.ArrayList)11 GridTestJob (org.apache.ignite.GridTestJob)9 HashMap (java.util.HashMap)7 IgniteTestResources (org.apache.ignite.testframework.junits.IgniteTestResources)7 Map (java.util.Map)5 GridTestJobResult (org.apache.ignite.GridTestJobResult)5 GridFailoverTestContext (org.apache.ignite.spi.failover.GridFailoverTestContext)5 Serializable (java.io.Serializable)4 List (java.util.List)4 ComputeTaskSession (org.apache.ignite.compute.ComputeTaskSession)4 ClusterMetricsSnapshot (org.apache.ignite.internal.ClusterMetricsSnapshot)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)3 GridAffinityFunctionContextImpl (org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl)3 Message (org.apache.ignite.plugin.extensions.communication.Message)3 CollisionJobContext (org.apache.ignite.spi.collision.CollisionJobContext)3