### Question:
SpawnBalancer implements Codable, AutoCloseable { public SpawnBalancerConfig getConfig() { return config; } SpawnBalancer(Spawn spawn, HostManager hostManager); double getHostScoreCached(String hostId); synchronized void startAutobalanceTask(); @Override void close(); void saveConfigToDataStore(); void startTaskSizePolling(); Map<JobTask, String> assignTasksFromMultipleJobsToHosts(Collection<JobTask> tasks,
                                                                   Collection<HostState> hosts); Map<HostState, Double> generateHostStateScoreMap(Collection<HostState> hosts); boolean canReceiveNewTasks(HostState host); List<JobTaskMoveAssignment> pushTasksOffHostForFilesystemOkayFailure(HostState host, int moveLimit); long getTaskTrueSize(JobTask task); static boolean isInMovableState(JobTask task); boolean okayToAutobalance(); @Nullable List<JobTaskMoveAssignment> getAssignmentsForAutoBalance(RebalanceType type,
                                                                              RebalanceWeight weight); List<Job> getJobsToAutobalance(List<HostState> hosts); Map<Integer, List<String>> getAssignmentsForNewReplicas(IJob job); Map<Integer, List<String>> getAssignmentsForNewReplicas(IJob job, int taskID); void requestJobSizeUpdate(String jobId, int taskId); SpawnBalancerConfig getConfig(); void setConfig(SpawnBalancerConfig config); void clearRecentlyRebalancedHosts(); void fixTasksForFailedHost(List<HostState> hosts, String failedHost); List<JobTask> generateAssignedTasksForNewJob(String jobID, int taskCount, Collection<HostState> hosts); List<JobTaskMoveAssignment> getAssignmentsForJobReallocation(Job job,
                                                                        int tasksToMove,
                                                                        List<HostState> hosts); List<JobTaskMoveAssignment> getAssignmentsToBalanceHost(HostState host, List<HostState> hosts); List<HostState> sortHostsByActiveTasks(Collection<HostState> hosts); void removeInvalidReplicas(IJob job); boolean isDiskFull(@Nullable HostState host); @SuppressWarnings("FloatingPointEquality") @Nonnull Collection<JobTask> getTasksToMove(String fromHostUuid, String toHostUuid,
                                                       int numTasks, boolean obeyDontAutobalanceMe); boolean isTaskSpreadOutAcrossAd(@Nullable HostLocation fromHostLocation,
                                           @Nullable HostLocation toHostLocation, JobTask task);  }### Answer:
@Test public void multipleMinionsPerHostReplicaTest() throws Exception { bal.getConfig().setAllowSameHostReplica(true); HostState host1m1 = installHostStateWithUUID("m1", spawn, true, new HostLocation("a", "", "")); host1m1.setHost("h1"); hostManager.updateHostState(host1m1); HostState host1m2 = installHostStateWithUUID("m2", spawn, true, new HostLocation("a", "", "")); host1m2.setHost("h1"); hostManager.updateHostState(host1m2); waitForAllUpHosts(); Job job = createJobAndUpdateHosts(spawn, 1, Arrays.asList("m1", "m2"), now, 1000, 0); job.setReplicas(1); spawn.updateJob(job); assertEquals("should get one replica when we allow same host replicas", 1, spawn.getTask(job.getId(), 0).getAllReplicas().size(), 1); bal.getConfig().setAllowSameHostReplica(false); spawn.updateJob(job); assertEquals("should get no replicas when we disallow same host replicas", 0, spawn.getTask(job.getId(), 0).getAllReplicas().size()); }