@Test public void testScheduledTasksDontGetRescheduled() { initScheduledRequest(); deploy(firstDeployId); deployChecker.checkDeploys(); Assert.assertTrue(requestManager.getPendingRequests().size() == 1); Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); startup.checkSchedulerForInconsistentState(); Assert.assertTrue(requestManager.getPendingRequests().size() == 1); Assert.assertTrue(requestManager.getPendingRequests().get(0).getPendingType() == PendingType.NEW_DEPLOY); Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); scheduler.drainPendingQueue(stateCacheProvider.get()); Assert.assertTrue(requestManager.getPendingRequests().isEmpty()); List<SingularityPendingTask> pending = taskManager.getPendingTasks(); Assert.assertTrue(taskManager.getPendingTaskIds().size() == 1); startup.checkSchedulerForInconsistentState(); scheduler.drainPendingQueue(stateCacheProvider.get()); Assert.assertTrue(requestManager.getPendingRequests().isEmpty()); Assert.assertTrue(taskManager.getPendingTaskIds().size() == 1); Assert.assertTrue(taskManager.getActiveTaskIds().isEmpty()); Assert.assertTrue(pending.equals(taskManager.getPendingTasks())); taskManager.deletePendingTask(pending.get(0).getPendingTaskId()); startup.checkSchedulerForInconsistentState(); Assert.assertTrue(requestManager.getPendingRequests().size() == 1); Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); }
@VisibleForTesting void checkSchedulerForInconsistentState() { final long now = System.currentTimeMillis(); final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId = getDeployKeyToPendingTaskId(); for (SingularityRequestWithState requestWithState : requestManager.getRequests()) { switch (requestWithState.getState()) { case ACTIVE: case SYSTEM_COOLDOWN: case DEPLOYING_TO_UNPAUSE: checkActiveRequest(requestWithState, deployKeyToPendingTaskId, now); break; case DELETED: case PAUSED: case FINISHED: break; } } }
SingularityStartup { @VisibleForTesting void checkSchedulerForInconsistentState() { final long now = System.currentTimeMillis(); final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId = getDeployKeyToPendingTaskId(); for (SingularityRequestWithState requestWithState : requestManager.getRequests()) { switch (requestWithState.getState()) { case ACTIVE: case SYSTEM_COOLDOWN: case DEPLOYING_TO_UNPAUSE: checkActiveRequest(requestWithState, deployKeyToPendingTaskId, now); break; case DELETED: case PAUSED: case FINISHED: break; } } } }
SingularityStartup { @VisibleForTesting void checkSchedulerForInconsistentState() { final long now = System.currentTimeMillis(); final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId = getDeployKeyToPendingTaskId(); for (SingularityRequestWithState requestWithState : requestManager.getRequests()) { switch (requestWithState.getState()) { case ACTIVE: case SYSTEM_COOLDOWN: case DEPLOYING_TO_UNPAUSE: checkActiveRequest(requestWithState, deployKeyToPendingTaskId, now); break; case DELETED: case PAUSED: case FINISHED: break; } } } @Inject  SingularityStartup(MesosClient mesosClient, SingularityHealthchecker healthchecker, SingularityNewTaskChecker newTaskChecker,
      SingularitySlaveAndRackManager slaveAndRackManager, TaskManager taskManager, RequestManager requestManager, DeployManager deployManager, SingularityTaskReconciliation taskReconciliation,
      ZkDataMigrationRunner zkDataMigrationRunner); }
SingularityStartup { @VisibleForTesting void checkSchedulerForInconsistentState() { final long now = System.currentTimeMillis(); final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId = getDeployKeyToPendingTaskId(); for (SingularityRequestWithState requestWithState : requestManager.getRequests()) { switch (requestWithState.getState()) { case ACTIVE: case SYSTEM_COOLDOWN: case DEPLOYING_TO_UNPAUSE: checkActiveRequest(requestWithState, deployKeyToPendingTaskId, now); break; case DELETED: case PAUSED: case FINISHED: break; } } } @Inject  SingularityStartup(MesosClient mesosClient, SingularityHealthchecker healthchecker, SingularityNewTaskChecker newTaskChecker,
      SingularitySlaveAndRackManager slaveAndRackManager, TaskManager taskManager, RequestManager requestManager, DeployManager deployManager, SingularityTaskReconciliation taskReconciliation,
      ZkDataMigrationRunner zkDataMigrationRunner); void startup(MasterInfo masterInfo, SchedulerDriver driver); }
SingularityStartup { @VisibleForTesting void checkSchedulerForInconsistentState() { final long now = System.currentTimeMillis(); final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId = getDeployKeyToPendingTaskId(); for (SingularityRequestWithState requestWithState : requestManager.getRequests()) { switch (requestWithState.getState()) { case ACTIVE: case SYSTEM_COOLDOWN: case DEPLOYING_TO_UNPAUSE: checkActiveRequest(requestWithState, deployKeyToPendingTaskId, now); break; case DELETED: case PAUSED: case FINISHED: break; } } } @Inject  SingularityStartup(MesosClient mesosClient, SingularityHealthchecker healthchecker, SingularityNewTaskChecker newTaskChecker,
      SingularitySlaveAndRackManager slaveAndRackManager, TaskManager taskManager, RequestManager requestManager, DeployManager deployManager, SingularityTaskReconciliation taskReconciliation,
      ZkDataMigrationRunner zkDataMigrationRunner); void startup(MasterInfo masterInfo, SchedulerDriver driver);  }