@Test
  public void testFindWorkerForTask() {
    ImmutableZkWorker worker1 = createMockWorker(1, true, true);
    ImmutableZkWorker worker2 = createMockWorker(1, true, true);
    ImmutableMap<String, ImmutableZkWorker> workerMap =
        ImmutableMap.of(
            "10.0.0.1", worker1,
            "10.0.0.3", worker2);

    ImmutableZkWorker workerForBatchTask =
        strategy
            .findWorkerForTask(
                new TestRemoteTaskRunnerConfig(new Period("PT1S")),
                workerMap,
                createMockTask("index_hadoop"))
            .get();
    // batch tasks should be sent to worker1
    Assert.assertEquals(worker1, workerForBatchTask);

    ImmutableZkWorker workerForOtherTask =
        strategy
            .findWorkerForTask(
                new TestRemoteTaskRunnerConfig(new Period("PT1S")),
                workerMap,
                createMockTask("other_type"))
            .get();
    // all other tasks should be sent to worker2
    Assert.assertEquals(worker2, workerForOtherTask);
  }
  @Test
  public void testNoWorkerCanRunTask() {
    ImmutableMap<String, ImmutableZkWorker> workerMap =
        ImmutableMap.of(
            "10.0.0.1", createMockWorker(1, false, true),
            "10.0.0.4", createMockWorker(1, false, true));
    Optional<ImmutableZkWorker> workerForBatchTask =
        strategy.findWorkerForTask(
            new TestRemoteTaskRunnerConfig(new Period("PT1S")),
            workerMap,
            createMockTask("index_hadoop"));
    Assert.assertFalse(workerForBatchTask.isPresent());

    Optional<ImmutableZkWorker> workerForOtherTask =
        strategy.findWorkerForTask(
            new TestRemoteTaskRunnerConfig(new Period("PT1S")),
            workerMap,
            createMockTask("otherTask"));
    // all other tasks should be sent to worker2
    Assert.assertFalse(workerForOtherTask.isPresent());
  }
 @Test
 public void testIsolationOfBatchWorker() {
   ImmutableMap<String, ImmutableZkWorker> workerMap =
       ImmutableMap.of(
           "10.0.0.1", createMockWorker(1, true, true),
           "10.0.0.2", createMockWorker(1, true, true));
   Optional<ImmutableZkWorker> workerForOtherTask =
       strategy.findWorkerForTask(
           new TestRemoteTaskRunnerConfig(new Period("PT1S")),
           workerMap,
           createMockTask("other_type"));
   Assert.assertFalse(workerForOtherTask.isPresent());
 }
 @Test
 public void testFillWorkerCapacity() {
   // tasks shoudl be assigned to the worker with maximum currCapacity used until its full
   ImmutableMap<String, ImmutableZkWorker> workerMap =
       ImmutableMap.of(
           "10.0.0.1", createMockWorker(1, true, true),
           "10.0.0.2", createMockWorker(5, true, true));
   Optional<ImmutableZkWorker> workerForBatchTask =
       strategy.findWorkerForTask(
           new TestRemoteTaskRunnerConfig(new Period("PT1S")),
           workerMap,
           createMockTask("index_hadoop"));
   Assert.assertEquals(workerMap.get("10.0.0.2"), workerForBatchTask.get());
 }