if (r != null) { List<Long> list = createdAtClusters.keySet().stream() .filter(ts -> Math.abs(ts - r.createdAt.toEpochSecond()) < config.getMaxElectionsTime().getSeconds()).collect(Collectors.toList()); .filter(ts -> Math.abs(ts - r.expiresAt.toEpochSecond()) < config.getMaxElectionsTime().getSeconds()).collect(Collectors.toList());
pollingExpiresAt = Instant.now().plus(config.getMaxElectionsTime()); consensusReceivedExpiresAt = Instant.now().plus(config.getMaxConsensusReceivedCheckTime());
@Test(timeout = 90000) public void timeoutError() throws Exception { if(node == null) { System.out.println("network not inited"); return; } Duration savedMaxElectionsTime = config.getMaxElectionsTime(); config.setMaxElectionsTime(Duration.ofMillis(200)); TestItem item = new TestItem(true); // We start elections but no node in the network know the source, so it // will short-circuit to self and then stop by the timeout: ItemResult itemResult = node.checkItem(item.getId()); assertEquals(ItemState.UNDEFINED, itemResult.state); assertFalse(itemResult.haveCopy); assertNull(itemResult.createdAt); assertNull(itemResult.expiresAt); itemResult = node.waitItem(item.getId(), 100); assertEquals(ItemState.UNDEFINED, itemResult.state); itemResult = node.checkItem(item.getId()); assertEquals(ItemState.UNDEFINED, itemResult.state); config.setMaxElectionsTime(savedMaxElectionsTime); }
assertEquals(config.getMaxItemCreationAge(), copyConfig.getMaxItemCreationAge()); assertEquals(config.getRevokedItemExpiration(), copyConfig.getRevokedItemExpiration()); assertEquals(config.getMaxElectionsTime(), copyConfig.getMaxElectionsTime()); assertEquals(config.getMaxConsensusReceivedCheckTime(), copyConfig.getMaxConsensusReceivedCheckTime()); assertEquals(config.getMaxResyncTime(), copyConfig.getMaxResyncTime());