/** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { super.afterTestsStopped(); ignite = null; }
/** * @throws Exception If failed. */ protected void checkNodeRemoved(int backups) throws Exception { checkNodeRemoved(backups, 1, 1); }
AffinityFunction aff = affinityFunction(); info("======================================"); info("Assigning partitions: " + i); info("======================================"); info("Assigned."); verifyAssignment(assignment, backups, aff.partitions(), nodes.size()); info("======================================"); info("Will remove nodes."); info("======================================"); info("======================================"); info("Assigning partitions: " + i); info("======================================"); backups)); info("Assigned."); verifyAssignment(assignment, backups, aff.partitions(), nodes.size());
/** * @param assignment Assignment to verify. */ private void verifyAssignment(List<List<ClusterNode>> assignment, int keyBackups, int partsCnt, int topSize) { Map<UUID, Collection<Integer>> mapping = new HashMap<>(); int ideal = Math.round((float)partsCnt / topSize * Math.min(keyBackups + 1, topSize)); for (int part = 0; part < assignment.size(); part++) { for (ClusterNode node : assignment.get(part)) { assert node != null; Collection<Integer> parts = mapping.get(node.id()); if (parts == null) { parts = new HashSet<>(); mapping.put(node.id(), parts); } assertTrue(parts.add(part)); } } int max = -1, min = Integer.MAX_VALUE; for (Collection<Integer> parts : mapping.values()) { max = Math.max(max, parts.size()); min = Math.min(min, parts.size()); } log().warning("max=" + max + ", min=" + min + ", ideal=" + ideal + ", minDev=" + deviation(min, ideal) + "%, " + "maxDev=" + deviation(max, ideal) + "%"); }
/** * @param backups Number of backups. * @throws Exception If failed. */ @Test public void testNullKeyForPartitionCalculation() throws Exception { AffinityFunction aff = affinityFunction(); try { aff.partition(null); fail("Should throw IllegalArgumentException due to NULL affinity key."); } catch (IllegalArgumentException e) { e.getMessage().contains("Null key is passed for a partition calculation. " + "Make sure that an affinity key that is used is initialized properly."); } }
/** * @throws Exception If failed. */ @Test public void testRandomReassignmentThreeBackups() throws Exception { checkRandomReassignment(3); }
AffinityFunction aff = affinityFunction(); info("======================================"); info("Assigning partitions [iter=" + i + ", discoEvt=" + discoEvt + ", nodesSize=" + nodes.size() + ']'); info("======================================"); backups)); verifyAssignment(assignment, backups, aff.partitions(), nodes.size());
/** * @throws Exception If failed. */ @Test public void testRandomReassignmentOneBackup() throws Exception { checkRandomReassignment(1); }
/** * @throws Exception If failed. */ @Test public void testNodeRemovedNoBackups() throws Exception { checkNodeRemoved(0); }
/** * @throws Exception If failed. */ @Test public void testRandomReassignmentTwoBackups() throws Exception { checkRandomReassignment(2); }
/** * @throws Exception If failed. */ @Test public void testNodeRemovedTwoBackups() throws Exception { checkNodeRemoved(2); }
/** * @throws Exception If failed. */ @Test public void testRandomReassignmentNoBackups() throws Exception { checkRandomReassignment(0); }
/** * @throws Exception If failed. */ @Test public void testNodeRemovedThreeBackups() throws Exception { checkNodeRemoved(3); }
/** * @throws Exception If failed. */ @Test public void testNodeRemovedOneBackup() throws Exception { checkNodeRemoved(1); }