@Test void shouldNotGetRandomWorkerFromEmptyPool() { assertNull(workerPool.getRandomWorker()); }
MantisWorker getRandomWorker() { int poolSize = pool.size(); if (poolSize == 0) { return null; } else if (poolSize == 1) { return (MantisWorker) pool.keySet().toArray()[0]; } else { List<MantisWorker> candidates = new ArrayList<>(pool.keySet()); int randomIndex1 = ThreadLocalRandom.current().nextInt(pool.size()); int randomIndex2 = ThreadLocalRandom.current().nextInt(pool.size()); MantisWorker candidate1 = candidates.get(randomIndex1); MantisWorker candidate2 = candidates.get(randomIndex2); double candidate1Score = getWorkerScore(candidate1); double candidate2Score = getWorkerScore(candidate2); return candidate1Score <= candidate2Score ? candidate1 : candidate2; } }
ChoiceOfTwoWorkerPool { MantisWorker getRandomWorker() { int poolSize = pool.size(); if (poolSize == 0) { return null; } else if (poolSize == 1) { return (MantisWorker) pool.keySet().toArray()[0]; } else { List<MantisWorker> candidates = new ArrayList<>(pool.keySet()); int randomIndex1 = ThreadLocalRandom.current().nextInt(pool.size()); int randomIndex2 = ThreadLocalRandom.current().nextInt(pool.size()); MantisWorker candidate1 = candidates.get(randomIndex1); MantisWorker candidate2 = candidates.get(randomIndex2); double candidate1Score = getWorkerScore(candidate1); double candidate2Score = getWorkerScore(candidate2); return candidate1Score <= candidate2Score ? candidate1 : candidate2; } } }
ChoiceOfTwoWorkerPool { MantisWorker getRandomWorker() { int poolSize = pool.size(); if (poolSize == 0) { return null; } else if (poolSize == 1) { return (MantisWorker) pool.keySet().toArray()[0]; } else { List<MantisWorker> candidates = new ArrayList<>(pool.keySet()); int randomIndex1 = ThreadLocalRandom.current().nextInt(pool.size()); int randomIndex2 = ThreadLocalRandom.current().nextInt(pool.size()); MantisWorker candidate1 = candidates.get(randomIndex1); MantisWorker candidate2 = candidates.get(randomIndex2); double candidate1Score = getWorkerScore(candidate1); double candidate2Score = getWorkerScore(candidate2); return candidate1Score <= candidate2Score ? candidate1 : candidate2; } } ChoiceOfTwoWorkerPool(MrePublishConfiguration config, Registry registry, EventChannel eventChannel); }
ChoiceOfTwoWorkerPool { MantisWorker getRandomWorker() { int poolSize = pool.size(); if (poolSize == 0) { return null; } else if (poolSize == 1) { return (MantisWorker) pool.keySet().toArray()[0]; } else { List<MantisWorker> candidates = new ArrayList<>(pool.keySet()); int randomIndex1 = ThreadLocalRandom.current().nextInt(pool.size()); int randomIndex2 = ThreadLocalRandom.current().nextInt(pool.size()); MantisWorker candidate1 = candidates.get(randomIndex1); MantisWorker candidate2 = candidates.get(randomIndex2); double candidate1Score = getWorkerScore(candidate1); double candidate2Score = getWorkerScore(candidate2); return candidate1Score <= candidate2Score ? candidate1 : candidate2; } } ChoiceOfTwoWorkerPool(MrePublishConfiguration config, Registry registry, EventChannel eventChannel);  }
ChoiceOfTwoWorkerPool { MantisWorker getRandomWorker() { int poolSize = pool.size(); if (poolSize == 0) { return null; } else if (poolSize == 1) { return (MantisWorker) pool.keySet().toArray()[0]; } else { List<MantisWorker> candidates = new ArrayList<>(pool.keySet()); int randomIndex1 = ThreadLocalRandom.current().nextInt(pool.size()); int randomIndex2 = ThreadLocalRandom.current().nextInt(pool.size()); MantisWorker candidate1 = candidates.get(randomIndex1); MantisWorker candidate2 = candidates.get(randomIndex2); double candidate1Score = getWorkerScore(candidate1); double candidate2Score = getWorkerScore(candidate2); return candidate1Score <= candidate2Score ? candidate1 : candidate2; } } ChoiceOfTwoWorkerPool(MrePublishConfiguration config, Registry registry, EventChannel eventChannel);   }