@Test public void testScheduledTasksDontGetRescheduledDuringRun() { initScheduledRequest(); initFirstDeploy(); startTask(firstDeploy); startup.checkSchedulerForInconsistentState(); scheduler.drainPendingQueue(stateCacheProvider.get()); Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); Assert.assertTrue(requestManager.getPendingRequests().isEmpty()); boolean caughtException = false; try { requestResource.scheduleImmediately(requestId); } catch (Exception e) { caughtException = true; } Assert.assertTrue(caughtException); Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty()); Assert.assertTrue(requestManager.getPendingRequests().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);  }