@Test(expected = IllegalArgumentException.class) public void updateMinionType_jobNotIdle() throws Exception { Job job = new Job(); job.setState(JobState.RUNNING); job.setMinionType("oldMinion"); when(spawn.getJob("job_id")).thenReturn(job); impl.updateMinionType("job_id", "newMinion", username, token, sudo); }
@Override public Job updateMinionType(String jobId, String minionType, String username, String token, String sudo) throws Exception { checkUserCredentials(username, token); spawn.acquireJobLock(); try { Job job = spawn.getJob(jobId); if (job != null) { checkJobWritePrivileges(job, username, token, sudo); checkMinionTypeUpdatePrerequisite(job, job.getState() == JobState.IDLE, "Job is not idle"); checkMinionTypeUpdatePrerequisite(job, isJobOnMinionType(job, minionType), "Not all tasks and replicas are on " + minionType); job.setMinionType(minionType); spawn.updateJob(job); log.info("User {} updated job {} minion type to {}", username, jobId, minionType); } return job; } finally { spawn.releaseJobLock(); } }
JobRequestHandlerImpl implements JobRequestHandler { @Override public Job updateMinionType(String jobId, String minionType, String username, String token, String sudo) throws Exception { checkUserCredentials(username, token); spawn.acquireJobLock(); try { Job job = spawn.getJob(jobId); if (job != null) { checkJobWritePrivileges(job, username, token, sudo); checkMinionTypeUpdatePrerequisite(job, job.getState() == JobState.IDLE, "Job is not idle"); checkMinionTypeUpdatePrerequisite(job, isJobOnMinionType(job, minionType), "Not all tasks and replicas are on " + minionType); job.setMinionType(minionType); spawn.updateJob(job); log.info("User {} updated job {} minion type to {}", username, jobId, minionType); } return job; } finally { spawn.releaseJobLock(); } } }
JobRequestHandlerImpl implements JobRequestHandler { @Override public Job updateMinionType(String jobId, String minionType, String username, String token, String sudo) throws Exception { checkUserCredentials(username, token); spawn.acquireJobLock(); try { Job job = spawn.getJob(jobId); if (job != null) { checkJobWritePrivileges(job, username, token, sudo); checkMinionTypeUpdatePrerequisite(job, job.getState() == JobState.IDLE, "Job is not idle"); checkMinionTypeUpdatePrerequisite(job, isJobOnMinionType(job, minionType), "Not all tasks and replicas are on " + minionType); job.setMinionType(minionType); spawn.updateJob(job); log.info("User {} updated job {} minion type to {}", username, jobId, minionType); } return job; } finally { spawn.releaseJobLock(); } } JobRequestHandlerImpl(Spawn spawn); }
JobRequestHandlerImpl implements JobRequestHandler { @Override public Job updateMinionType(String jobId, String minionType, String username, String token, String sudo) throws Exception { checkUserCredentials(username, token); spawn.acquireJobLock(); try { Job job = spawn.getJob(jobId); if (job != null) { checkJobWritePrivileges(job, username, token, sudo); checkMinionTypeUpdatePrerequisite(job, job.getState() == JobState.IDLE, "Job is not idle"); checkMinionTypeUpdatePrerequisite(job, isJobOnMinionType(job, minionType), "Not all tasks and replicas are on " + minionType); job.setMinionType(minionType); spawn.updateJob(job); log.info("User {} updated job {} minion type to {}", username, jobId, minionType); } return job; } finally { spawn.releaseJobLock(); } } JobRequestHandlerImpl(Spawn spawn); @Override Job createOrUpdateJob(KVPairs kv, String username, String token, String sudo, boolean defaults); @Override Job updateMinionType(String jobId, String minionType, String username, String token, String sudo); @Override boolean maybeKickJobOrTask(KVPairs kv, Job job); }
JobRequestHandlerImpl implements JobRequestHandler { @Override public Job updateMinionType(String jobId, String minionType, String username, String token, String sudo) throws Exception { checkUserCredentials(username, token); spawn.acquireJobLock(); try { Job job = spawn.getJob(jobId); if (job != null) { checkJobWritePrivileges(job, username, token, sudo); checkMinionTypeUpdatePrerequisite(job, job.getState() == JobState.IDLE, "Job is not idle"); checkMinionTypeUpdatePrerequisite(job, isJobOnMinionType(job, minionType), "Not all tasks and replicas are on " + minionType); job.setMinionType(minionType); spawn.updateJob(job); log.info("User {} updated job {} minion type to {}", username, jobId, minionType); } return job; } finally { spawn.releaseJobLock(); } } JobRequestHandlerImpl(Spawn spawn); @Override Job createOrUpdateJob(KVPairs kv, String username, String token, String sudo, boolean defaults); @Override Job updateMinionType(String jobId, String minionType, String username, String token, String sudo); @Override boolean maybeKickJobOrTask(KVPairs kv, Job job);  }