/** * Adds Failover SPI attribute. * * @param node Node to add attribute to. */ private void addSpiDependency(GridTestNode node) { node.addAttribute(IgniteNodeAttributes.ATTR_SPI_CLASS, JobStealingCollisionSpi.class.getName()); } }
/** * Adds Failover SPI attribute. * * @param node Node to add attribute to. * @throws Exception If failed. */ private void addSpiDependency(GridTestNode node) throws Exception { node.addAttribute(U.spiAttribute(getSpi(), ATTR_SPI_CLASS), JobStealingFailoverSpi.class.getName()); }
/** * Adds Failover SPI attribute. * * @param node Node to add attribute to. * @throws Exception If failed. */ private void addSpiDependency(GridTestNode node) throws Exception { node.addAttribute(U.spiAttribute(getSpi(), ATTR_SPI_CLASS), JobStealingFailoverSpi.class.getName()); }
/** * Adds Failover SPI attribute. * * @param node Node to add attribute to. * @throws Exception If failed. */ private void addSpiDependency(GridTestNode node) throws Exception { node.addAttribute(U.spiAttribute(getSpi(), ATTR_SPI_CLASS), JobStealingFailoverSpi.class.getName()); } }
/** * Adds Failover SPI attribute. * * @param node Node to add attribute to. * @throws Exception If failed. */ private void addSpiDependency(GridTestNode node) throws Exception { node.addAttribute(U.spiAttribute(getSpi(), ATTR_SPI_CLASS), JobStealingFailoverSpi.class.getName()); }
/** * Adds Collision SPI attribute. * * @param node Node to add attribute to. * @return Passed in node. * @throws Exception If failed. */ private ClusterNode addSpiDependency(GridTestNode node) throws Exception { node.addAttribute( U.spiAttribute(getSpi(), IgniteNodeAttributes.ATTR_SPI_CLASS), JobStealingCollisionSpi.class.getName()); node.addAttribute( U.spiAttribute(getSpi(), IgniteNodeAttributes.ATTR_SPI_CLASS), JobStealingCollisionSpi.class.getName()); return node; }
/** * Creates test node with specified attributes. * * @param mac Node mac addresses. * @param pid Node PID. * @return Node. */ private GridTestNode getNode(String mac, int pid) { ClusterMetricsSnapshot metrics = new ClusterMetricsSnapshot(); metrics.setHeapMemoryMaximum(1024L * 1024 * 1024); metrics.setHeapMemoryInitialized(1024L * 1024 * 1024); GridTestNode node = new GridTestNode(UUID.randomUUID(), metrics); node.addAttribute(ATTR_MACS, mac); node.addAttribute(ATTR_JVM_PID, pid); return node; } }
/** * Adds Collision SPI attribute. * * @param node Node to add attribute to. * @throws Exception If failed. */ private void addSpiDependency(GridTestNode node) throws Exception { node.addAttribute(ATTR_SPI_CLASS, JobStealingCollisionSpi.class.getName()); node.setAttribute(U.spiAttribute(getSpi(), ATTR_SPI_CLASS), getSpi().getClass().getName()); }
/** * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) @Test 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; }
/** * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) @Test 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; }
GridTestNode node = new GridTestNode(UUID.randomUUID()); node.addAttribute(U.spiAttribute(getSpi(), NODE_WEIGHT_ATTR_NAME), i + 1);
/** * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) @Test 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; } }
/** * @return SPI context. * @throws Exception If anything failed. */ protected GridSpiTestContext initSpiContext() throws Exception { GridSpiTestContext spiCtx = new GridSpiTestContext(); if (getTestData().getDiscoverySpi() != null) { spiCtx.setLocalNode(getTestData().getDiscoverySpi().getLocalNode()); for (ClusterNode node : getTestData().getDiscoverySpi().getRemoteNodes()) spiCtx.addNode(node); } else { GridTestNode node = new GridTestNode(UUID.randomUUID()); spiCtx.setLocalNode(node); if (getSpi() != null) { // Set up SPI class name and SPI version. Map<String, Serializable> attrs = initSpiClassAndVersionAttributes(getSpi()); for (Map.Entry<String, Serializable> entry: attrs.entrySet()) node.addAttribute(entry.getKey(), entry.getValue()); } } return spiCtx; }