package com.hubspot.singularity.scheduler;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.hubspot.singularity.data.RequestManager;
import com.hubspot.singularity.data.TaskManager;

@Singleton
public class SingularityLeaderCacheCoordinator {

  private final TaskManager taskManager;
  private final RequestManager requestManager;
  private final SingularityLeaderCache leaderCache;

  @Inject
  public SingularityLeaderCacheCoordinator(TaskManager taskManager, RequestManager requestManager, SingularityLeaderCache leaderCache) {
    this.taskManager = taskManager;
    this.requestManager = requestManager;
    this.leaderCache = leaderCache;
  }

  public void activateLeaderCache() {
    leaderCache.activate();
    taskManager.activateLeaderCache();
    requestManager.activateLeaderCache();
  }

  public void stopLeaderCache() {
    leaderCache.stop();
  }

}

@@ -718,36 +718,8 @@
 ) %7B%0A
-    leaderCache.activate();%0A
     
@@ -791,24 +791,52 @@
 derCache();%0A
+    leaderCache.activate();%0A
   %7D%0A%0A  publi

load the cache before activating