SchedulerUtils { public static boolean supervisorExists(String offerHost, Collection<SupervisorDetails> existingSupervisors, String topologyId) { boolean supervisorExists = false; String expectedSupervisorId = MesosCommon.supervisorId(offerHost, topologyId); for (SupervisorDetails supervisorDetail : existingSupervisors) { if (supervisorDetail.getId().equals(expectedSupervisorId)) { supervisorExists = true; } } return supervisorExists; }  static boolean isFit(Map mesosStormConf, OfferResources offerResources, TopologyDetails topologyDetails, boolean supervisorExists); static boolean isFit(Map mesosStormConf, Protos.Offer offer, TopologyDetails topologyDetails, boolean supervisorExists); static boolean supervisorExists(String offerHost, Collection<SupervisorDetails> existingSupervisors,
                                   String topologyId); static Map<String, List<OfferResources>> getOfferResourcesListPerNode(RotatingMap<Protos.OfferID, Protos.Offer> offers); static MesosWorkerSlot createWorkerSlotFromOfferResources(Map mesosStormConf, OfferResources offerResources,
                                                            TopologyDetails topologyDetails, boolean supervisorExists);  }
@Test public void testSupervisorExists() throws Exception { Collection<SupervisorDetails> existingSupervisors = new ArrayList<>(); String hostName = "host1.east"; existingSupervisors.add(new SupervisorDetails(MesosCommon.supervisorId(hostName, "test-topology1-65-1442255385"), hostName, null)); existingSupervisors.add(new SupervisorDetails(MesosCommon.supervisorId(hostName, "test-topology10-65-1442255385"), hostName, null)); assertEquals(true, SchedulerUtils.supervisorExists(hostName, existingSupervisors, "test-topology1-65-1442255385")); assertEquals(false, SchedulerUtils.supervisorExists(hostName, existingSupervisors, "test-topology2-65-1442255385")); }