/** * @throws Exception If test failed. */ @Test public void testFailover() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); GridTestJobResult failed = new GridTestJobResult(rmt); failed.getJobContext().setAttribute(JobStealingCollisionSpi.THIEF_NODE_ATTR, getSpiContext().localNode().id()); ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), Collections.singletonList(getSpiContext().remoteNodes().iterator().next())); assert other == rmt : "Invalid failed-over node: " + other; }
/** * @throws Exception If test failed. */ @Test public void testThiefIdNotSet() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); GridTestJobResult failed = new GridTestJobResult(rmt); ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes())); assert other != null; assert other != rmt; assert other.equals(getSpiContext().localNode()); checkAttributes(failed.getJobContext(), rmt, 1); }
/** * @throws Exception If test failed. */ @Test public void testFailover() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); GridTestJobResult failed = new GridTestJobResult(rmt); failed.getJobContext().setAttribute(THIEF_NODE_ATTR, getSpiContext().localNode().id()); ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes())); assert other == getSpiContext().localNode(); // This is not a failover but stealing. checkAttributes(failed.getJobContext(), null, 0); }
/** * @throws Exception If test failed. */ @Test public void testThiefEqualsVictim() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); 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 other.equals(getSpiContext().localNode()); checkAttributes(failed.getJobContext(), rmt, 1); }
info(">>> Initialized context: nodeId=" + ctx.localNode().id());
info(">>> Initialized context: nodeId=" + ctx.localNode().id());
/** * @throws Exception If test failed. */ @Test public void testMaxHopsExceeded() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); GridTestJobResult failed = new GridTestJobResult(rmt); failed.getJobContext().setAttribute(THIEF_NODE_ATTR, getSpiContext().localNode().id()); failed.getJobContext().setAttribute(FAILOVER_ATTEMPT_COUNT_ATTR, getSpi().getMaximumFailoverAttempts()); ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes())); assert other == null; }
Serializable msg1 = getSpiContext().removeSentMessage(getSpiContext().localNode());
/** * @throws Exception If test failed. */ @Test public void testNonZeroFailoverCount() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); GridTestJobResult failed = new GridTestJobResult(rmt); failed.getJobContext().setAttribute(FAILOVER_ATTEMPT_COUNT_ATTR, getSpi().getMaximumFailoverAttempts() - 1); ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes())); assert other != null; assert other != rmt; assert other == getSpiContext().localNode(); checkAttributes(failed.getJobContext(), rmt, getSpi().getMaximumFailoverAttempts()); }
info(">>> Initialized context: nodeId=" + ctx.localNode().id());
if (getSpiContext().localNode().id().equals(doomed)) doomed = orderedNodes.get(1);
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { spi = createSpi(); spiRsrc = new IgniteTestResources(getMBeanServer()); locNode = new GridTestNode(spiRsrc.getNodeId()); GridSpiTestContext ctx = initSpiContext(); ctx.setLocalNode(locNode); info(">>> Initialized context: nodeId=" + ctx.localNode().id()); spiRsrc.inject(spi); lsnr = new MessageListener(spiRsrc.getNodeId()); spi.setListener(lsnr); Map<String, Object> attrs = spi.getNodeAttributes(); locNode.setAttributes(attrs); spi.spiStart(getTestIgniteInstanceName()); spi.onContextInitialized(ctx); IgniteTestResources remoteRsrc = new IgniteTestResources(); remoteNode = new GridTestNode(remoteRsrc.getNodeId()); remoteNode.setAttributes(attrs); remoteNode.setAttribute(U.spiAttribute(spi, TcpCommunicationSpi.ATTR_ADDRS), Collections.singleton(remoteAddr)); ctx.remoteNodes().add(remoteNode); }