You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2016/04/06 00:27:28 UTC
[1/2] aurora git commit: Remove lock-related constructs from the API.
Repository: aurora
Updated Branches:
refs/heads/master 51097889c -> a9b3df88e
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 85ca86c..2b557e2 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -53,7 +53,6 @@ import org.apache.aurora.gen.JobUpdateSettings;
import org.apache.aurora.gen.JobUpdateSummary;
import org.apache.aurora.gen.LimitConstraint;
import org.apache.aurora.gen.ListBackupsResult;
-import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
import org.apache.aurora.gen.MaintenanceMode;
import org.apache.aurora.gen.MesosContainer;
@@ -113,8 +112,6 @@ import org.easymock.IExpectationSetters;
import org.junit.Before;
import org.junit.Test;
-import static org.apache.aurora.gen.LockValidation.CHECKED;
-import static org.apache.aurora.gen.LockValidation.UNCHECKED;
import static org.apache.aurora.gen.MaintenanceMode.DRAINING;
import static org.apache.aurora.gen.MaintenanceMode.NONE;
import static org.apache.aurora.gen.MaintenanceMode.SCHEDULED;
@@ -131,7 +128,6 @@ import static org.apache.aurora.scheduler.thrift.Fixtures.INSTANCE_KEY;
import static org.apache.aurora.scheduler.thrift.Fixtures.INVALID_TASK_CONFIG;
import static org.apache.aurora.scheduler.thrift.Fixtures.JOB_KEY;
import static org.apache.aurora.scheduler.thrift.Fixtures.JOB_NAME;
-import static org.apache.aurora.scheduler.thrift.Fixtures.LOCK;
import static org.apache.aurora.scheduler.thrift.Fixtures.LOCK_KEY;
import static org.apache.aurora.scheduler.thrift.Fixtures.NOT_ENOUGH_QUOTA;
import static org.apache.aurora.scheduler.thrift.Fixtures.ROLE;
@@ -257,7 +253,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
public void testCreateJobNoLock() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeProdJob());
SanitizedConfiguration sanitized = fromUnsanitized(job);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -271,14 +267,14 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertOkResponse(thrift.createJob(makeProdJob(), null));
+ assertOkResponse(thrift.createJob(makeProdJob()));
}
@Test
public void testCreateJobWithLock() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeProdJob());
SanitizedConfiguration sanitized = fromUnsanitized(job);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -292,7 +288,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertOkResponse(thrift.createJob(job.newBuilder(), LOCK.newBuilder()));
+ assertOkResponse(thrift.createJob(job.newBuilder()));
}
@Test
@@ -301,9 +297,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertEquals(
- invalidResponse(NO_CRON),
- thrift.createJob(job.newBuilder(), LOCK.newBuilder()));
+ assertEquals(invalidResponse(NO_CRON), thrift.createJob(job.newBuilder()));
}
@Test
@@ -311,43 +305,41 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
IJobConfiguration job = IJobConfiguration.build(makeJob(INVALID_TASK_CONFIG));
control.replay();
- assertResponse(
- INVALID_REQUEST,
- thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
@Test
public void testCreateJobFailsLockCheck() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeJob());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
- expectLastCall().andThrow(new LockException("Invalid lock"));
+ lockManager.assertNotLocked(LOCK_KEY);
+ expectLastCall().andThrow(new LockException("Locked"));
control.replay();
- assertResponse(LOCK_ERROR, thrift.createJob(job.newBuilder(), LOCK.newBuilder()));
+ assertResponse(LOCK_ERROR, thrift.createJob(job.newBuilder()));
}
@Test
public void testCreateJobFailsJobExists() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeJob());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active(), buildScheduledTask());
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
@Test
public void testCreateJobFailsCronJobExists() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeJob());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectCronJob();
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
@Test
@@ -355,7 +347,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
IJobConfiguration job = IJobConfiguration.build(
makeJob(defaultTask(true), THRESHOLDS.getMaxTasksPerJob() + 1));
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(quotaManager.checkInstanceAddition(
@@ -365,14 +357,14 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
@Test
public void testCreateJobFailsTaskIdLength() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeJob());
SanitizedConfiguration sanitized = fromUnsanitized(job);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(quotaManager.checkInstanceAddition(
@@ -385,14 +377,14 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
@Test
public void testCreateJobFailsQuotaCheck() throws Exception {
IJobConfiguration job = IJobConfiguration.build(makeProdJob());
SanitizedConfiguration sanitized = fromUnsanitized(job);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -401,7 +393,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job.newBuilder()));
}
private void assertMessageMatches(Response response, String string) {
@@ -416,7 +408,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
JobConfiguration job =
new JobConfiguration().setKey(JOB_KEY.newBuilder()).setOwner(IDENTITY);
- assertResponse(INVALID_REQUEST, thrift.createJob(job, null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job));
}
@Test
@@ -426,7 +418,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- Response response = thrift.createJob(job, LOCK.newBuilder());
+ Response response = thrift.createJob(job);
assertResponse(INVALID_REQUEST, response);
// TODO(wfarner): Don't rely on a magic string here, reference a constant from the source.
assertMessageMatches(response, "Configuration may not be null");
@@ -439,7 +431,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job, null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job));
}
@Test
@@ -449,7 +441,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.createJob(job, null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(job));
}
@Test
@@ -460,7 +452,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
task.setNumCpus(0);
task.setRamMb(0);
task.setDiskMb(0);
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -468,7 +460,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
TaskConfig task = productionTask().setNumCpus(0.0);
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -476,7 +468,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
TaskConfig task = productionTask().setRamMb(-123);
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -484,7 +476,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
TaskConfig task = productionTask().setDiskMb(0);
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -516,7 +508,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
.setConstraints(ImmutableSet.of())
.setMaxTaskFailures(0);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expectNoCronJob();
expect(taskIdGenerator.generate(ITaskConfig.build(sanitized.getTaskConfig()), 1))
@@ -529,7 +521,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertOkResponse(thrift.createJob(job, null));
+ assertOkResponse(thrift.createJob(job));
}
@Test
@@ -538,7 +530,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
TaskConfig task = nonProductionTask();
task.setConstraints(ImmutableSet.of(dedicatedConstraint(ImmutableSet.of("mesos"))));
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -547,7 +539,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
TaskConfig task = nonProductionTask();
task.setConstraints(ImmutableSet.of(dedicatedConstraint(1)));
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
@Test
@@ -556,7 +548,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
TaskConfig task = nonProductionTask();
task.setConstraints(ImmutableSet.of(dedicatedConstraint(ImmutableSet.of("mesos", "test"))));
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
private IScheduledTask buildTaskForJobUpdate(int instanceId) {
@@ -601,12 +593,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
public void testKillByJobName() throws Exception {
Query.Builder query = Query.arbitrary(new TaskQuery().setJobName("job")).active();
storageUtil.expectTaskFetch(query, buildScheduledTask());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectTransitionsToKilling();
control.replay();
- Response response = thrift.killTasks(query.get().newBuilder(), null, null, null);
+ Response response = thrift.killTasks(query.get().newBuilder(), null, null);
assertOkResponse(response);
assertMessageMatches(response, "The TaskQuery field is deprecated.");
}
@@ -615,24 +607,24 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
public void testJobScopedKillsActive() throws Exception {
Query.Builder query = Query.unscoped().byJob(JOB_KEY).active();
storageUtil.expectTaskFetch(query, buildScheduledTask());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectTransitionsToKilling();
control.replay();
- assertOkResponse(thrift.killTasks(null, null, JOB_KEY.newBuilder(), null));
+ assertOkResponse(thrift.killTasks(null, JOB_KEY.newBuilder(), null));
}
@Test
public void testInstanceScoped() throws Exception {
Query.Builder query = Query.instanceScoped(JOB_KEY, ImmutableSet.of(1)).active();
storageUtil.expectTaskFetch(query, buildScheduledTask());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectTransitionsToKilling();
control.replay();
- assertOkResponse(thrift.killTasks(null, null, JOB_KEY.newBuilder(), ImmutableSet.of(1)));
+ assertOkResponse(thrift.killTasks(null, JOB_KEY.newBuilder(), ImmutableSet.of(1)));
}
@Test
@@ -642,15 +634,15 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
ILockKey key2 = ILockKey.build(LockKey.job(
JobKeys.from(ROLE, "devel", "job_bar").newBuilder()));
storageUtil.expectTaskFetch(query, buildScheduledTask(), task2);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
- lockManager.validateIfLocked(key2, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
+ lockManager.assertNotLocked(key2);
expectLastCall().andThrow(new LockException("Failed lock check."));
control.replay();
assertResponse(
LOCK_ERROR,
- thrift.killTasks(null, LOCK.newBuilder(), JOB_KEY.newBuilder(), null));
+ thrift.killTasks(null, JOB_KEY.newBuilder(), null));
}
@Test
@@ -660,12 +652,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
// This query happens twice - once for authentication (without consistency) and once again
// to perform the state change (within a write transaction).
storageUtil.expectTaskFetch(query, buildScheduledTask());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectTransitionsToKilling();
control.replay();
- assertOkResponse(thrift.killTasks(query.get().newBuilder(), null, null, null));
+ assertOkResponse(thrift.killTasks(query.get().newBuilder(), null, null));
}
@Test
@@ -674,7 +666,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.killTasks(query, null, null, null));
+ assertResponse(INVALID_REQUEST, thrift.killTasks(query, null, null));
}
@Test
@@ -684,7 +676,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- Response response = thrift.killTasks(null, null, JOB_KEY.newBuilder(), null);
+ Response response = thrift.killTasks(null, JOB_KEY.newBuilder(), null);
assertOkResponse(response);
assertMessageMatches(response, SchedulerThriftInterface.NO_TASKS_TO_KILL_MESSAGE);
}
@@ -805,7 +797,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
public void testRestartShards() throws Exception {
Set<Integer> shards = ImmutableSet.of(0);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(
Query.instanceScoped(JOB_KEY, shards).active(),
buildScheduledTask());
@@ -822,40 +814,40 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
assertOkResponse(
- thrift.restartShards(JOB_KEY.newBuilder(), shards, LOCK.newBuilder()));
+ thrift.restartShards(JOB_KEY.newBuilder(), shards));
}
@Test
public void testRestartShardsLockCheckFails() throws Exception {
Set<Integer> shards = ImmutableSet.of(1, 6);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
expectLastCall().andThrow(new LockException("test"));
control.replay();
assertResponse(
LOCK_ERROR,
- thrift.restartShards(JOB_KEY.newBuilder(), shards, LOCK.newBuilder()));
+ thrift.restartShards(JOB_KEY.newBuilder(), shards));
}
@Test
public void testRestartShardsNotFoundTasksFailure() throws Exception {
Set<Integer> shards = ImmutableSet.of(1, 6);
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.instanceScoped(JOB_KEY, shards).active());
control.replay();
assertResponse(
INVALID_REQUEST,
- thrift.restartShards(JOB_KEY.newBuilder(), shards, LOCK.newBuilder()));
+ thrift.restartShards(JOB_KEY.newBuilder(), shards));
}
@Test
public void testReplaceCronTemplate() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -864,21 +856,21 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
cronJobManager.updateJob(anyObject(SanitizedCronJob.class));
control.replay();
- assertOkResponse(thrift.replaceCronTemplate(CRON_JOB, null));
+ assertOkResponse(thrift.replaceCronTemplate(CRON_JOB));
}
@Test
public void testReplaceCronTemplateFailedLockValidation() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectLastCall().andThrow(new LockException("Failed lock."));
control.replay();
- assertResponse(LOCK_ERROR, thrift.replaceCronTemplate(CRON_JOB, null));
+ assertResponse(LOCK_ERROR, thrift.replaceCronTemplate(CRON_JOB));
}
@Test
public void testReplaceCronTemplateDoesNotExist() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -889,7 +881,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- assertResponse(INVALID_REQUEST, thrift.replaceCronTemplate(CRON_JOB, null));
+ assertResponse(INVALID_REQUEST, thrift.replaceCronTemplate(CRON_JOB));
}
@Test
@@ -909,7 +901,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testScheduleCronCreatesJob() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -920,12 +912,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
cronJobManager.createJob(SanitizedCronJob.from(sanitized));
control.replay();
- assertResponse(OK, thrift.scheduleCronJob(CRON_JOB, null));
+ assertResponse(OK, thrift.scheduleCronJob(CRON_JOB));
}
@Test
public void testScheduleCronFailsCreationDueToExistingNonCron() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -937,12 +929,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
assertEquals(
invalidResponse(jobAlreadyExistsMessage(JOB_KEY)),
- thrift.scheduleCronJob(CRON_JOB, null));
+ thrift.scheduleCronJob(CRON_JOB));
}
@Test
public void testScheduleCronUpdatesJob() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -953,24 +945,22 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
cronJobManager.updateJob(SanitizedCronJob.from(sanitized));
control.replay();
- assertResponse(OK, thrift.scheduleCronJob(CRON_JOB, null));
+ assertResponse(OK, thrift.scheduleCronJob(CRON_JOB));
}
@Test
public void testScheduleCronJobFailedTaskConfigValidation() throws Exception {
control.replay();
IJobConfiguration job = IJobConfiguration.build(makeJob(INVALID_TASK_CONFIG));
- assertResponse(
- INVALID_REQUEST,
- thrift.scheduleCronJob(job.newBuilder(), null));
+ assertResponse(INVALID_REQUEST, thrift.scheduleCronJob(job.newBuilder()));
}
@Test
public void testScheduleCronJobFailsLockValidation() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
expectLastCall().andThrow(new LockException("Failed lock"));
control.replay();
- assertResponse(LOCK_ERROR, thrift.scheduleCronJob(CRON_JOB, LOCK.newBuilder()));
+ assertResponse(LOCK_ERROR, thrift.scheduleCronJob(CRON_JOB));
}
@Test
@@ -979,12 +969,12 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
assertEquals(
invalidResponse(noCronScheduleMessage(JOB_KEY)),
- thrift.scheduleCronJob(makeJob(), null));
+ thrift.scheduleCronJob(makeJob()));
}
@Test
public void testScheduleCronFailsQuotaCheck() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
SanitizedConfiguration sanitized = fromUnsanitized(IJobConfiguration.build(CRON_JOB));
expect(taskIdGenerator.generate(sanitized.getJobConfig().getTaskConfig(), 1))
@@ -992,36 +982,36 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
expectCronQuotaCheck(sanitized.getJobConfig(), NOT_ENOUGH_QUOTA);
control.replay();
- assertResponse(INVALID_REQUEST, thrift.scheduleCronJob(CRON_JOB, null));
+ assertResponse(INVALID_REQUEST, thrift.scheduleCronJob(CRON_JOB));
}
@Test
public void testDescheduleCronJob() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expect(cronJobManager.deleteJob(JOB_KEY)).andReturn(true);
control.replay();
- assertResponse(OK, thrift.descheduleCronJob(CRON_JOB.getKey(), null));
+ assertResponse(OK, thrift.descheduleCronJob(CRON_JOB.getKey()));
}
@Test
public void testDescheduleCronJobFailsLockValidation() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectLastCall().andThrow(new LockException("Failed lock"));
control.replay();
- assertResponse(LOCK_ERROR, thrift.descheduleCronJob(CRON_JOB.getKey(), null));
+ assertResponse(LOCK_ERROR, thrift.descheduleCronJob(CRON_JOB.getKey()));
}
@Test
public void testDescheduleNotACron() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expect(cronJobManager.deleteJob(JOB_KEY)).andReturn(false);
control.replay();
assertEquals(
okEmptyResponse(notScheduledCronMessage(JOB_KEY)),
- thrift.descheduleCronJob(JOB_KEY.newBuilder(), null));
+ thrift.descheduleCronJob(JOB_KEY.newBuilder()));
}
@Test
@@ -1201,7 +1191,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
TaskConfig task = nonProductionTask();
task.setConstraints(ImmutableSet.of(dedicatedConstraint(ImmutableSet.of("mesos"))));
- assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task), null));
+ assertResponse(INVALID_REQUEST, thrift.createJob(makeJob(task)));
}
private static Set<IHostStatus> status(String host, MaintenanceMode mode) {
@@ -1297,7 +1287,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
public void testAddInstances() throws Exception {
ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expect(taskIdGenerator.generate(populatedTask, 1))
.andReturn(TASK_ID);
@@ -1310,7 +1300,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
- assertOkResponse(deprecatedAddInstances(config, LOCK.newBuilder()));
+ assertOkResponse(deprecatedAddInstances(config));
}
@Test
@@ -1318,7 +1308,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
ITaskConfig populatedTask = ITaskConfig.build(populatedTask());
AddInstancesConfig config = createInstanceConfig(populatedTask.newBuilder());
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
expect(taskIdGenerator.generate(populatedTask, 1))
.andReturn(TASK_ID);
@@ -1330,7 +1320,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
- Response response = deprecatedAddInstances(config, null);
+ Response response = deprecatedAddInstances(config);
assertOkResponse(response);
assertMessageMatches(response, "The AddInstancesConfig field is deprecated.");
}
@@ -1338,7 +1328,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testAddInstancesWithInstanceKey() throws Exception {
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
IScheduledTask activeTask = buildScheduledTask();
ITaskConfig task = activeTask.getAssignedTask().getTask();
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active(), activeTask);
@@ -1360,7 +1350,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testAddInstancesWithInstanceKeyFailsWithNoInstance() throws Exception {
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
control.replay();
@@ -1373,7 +1363,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testAddInstancesWithInstanceKeyFailsInvalidCount() throws Exception {
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
control.replay();
@@ -1388,11 +1378,11 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
AddInstancesConfig config = createInstanceConfig(INVALID_TASK_CONFIG);
expectNoCronJob();
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active());
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
control.replay();
- assertResponse(INVALID_REQUEST, deprecatedAddInstances(config, null));
+ assertResponse(INVALID_REQUEST, deprecatedAddInstances(config));
}
@Test
@@ -1416,7 +1406,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
@Test
public void testAddInstancesLockCheckFails() throws Exception {
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
expectLastCall().andThrow(new LockException("Failed lock check."));
control.replay();
@@ -1429,7 +1419,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
IScheduledTask activeTask = buildScheduledTask();
ITaskConfig task = activeTask.getAssignedTask().getTask();
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active(), activeTask);
expect(quotaManager.checkInstanceAddition(
anyObject(ITaskConfig.class),
@@ -1448,7 +1438,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
IScheduledTask activeTask = buildScheduledTask();
ITaskConfig task = activeTask.getAssignedTask().getTask();
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active(), activeTask);
expect(taskIdGenerator.generate(task, 2))
.andReturn(TASK_ID);
@@ -1464,7 +1454,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
IScheduledTask activeTask = buildScheduledTask();
ITaskConfig task = activeTask.getAssignedTask().getTask();
expectNoCronJob();
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
storageUtil.expectTaskFetch(Query.jobScoped(JOB_KEY).active(), activeTask);
expect(taskIdGenerator.generate(task, 2))
.andReturn(TASK_ID);
@@ -1481,62 +1471,11 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
}
private Response newAddInstances(InstanceKey key, int count) throws Exception {
- return thrift.addInstances(null, null, key, count);
+ return thrift.addInstances(null, key, count);
}
- private Response deprecatedAddInstances(AddInstancesConfig config, Lock lock) throws Exception {
- return thrift.addInstances(config, lock, null, 0);
- }
-
- @Test
- public void testAcquireLock() throws Exception {
- expectGetRemoteUser();
- expect(lockManager.acquireLock(LOCK_KEY, USER)).andReturn(LOCK);
-
- control.replay();
-
- Response response = thrift.acquireLock(LOCK_KEY.newBuilder());
- assertEquals(LOCK.newBuilder(), response.getResult().getAcquireLockResult().getLock());
- }
-
- @Test
- public void testAcquireLockFailed() throws Exception {
- expectGetRemoteUser();
- expect(lockManager.acquireLock(LOCK_KEY, USER))
- .andThrow(new LockException("Failed"));
-
- control.replay();
-
- assertResponse(LOCK_ERROR, thrift.acquireLock(LOCK_KEY.newBuilder()));
- }
-
- @Test
- public void testReleaseLock() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
- lockManager.releaseLock(LOCK);
-
- control.replay();
-
- assertOkResponse(thrift.releaseLock(LOCK.newBuilder(), CHECKED));
- }
-
- @Test
- public void testReleaseLockFailed() throws Exception {
- lockManager.validateIfLocked(LOCK_KEY, java.util.Optional.of(LOCK));
- expectLastCall().andThrow(new LockException("Failed"));
-
- control.replay();
-
- assertResponse(LOCK_ERROR, thrift.releaseLock(LOCK.newBuilder(), CHECKED));
- }
-
- @Test
- public void testReleaseLockUnchecked() throws Exception {
- lockManager.releaseLock(LOCK);
-
- control.replay();
-
- assertEquals(okEmptyResponse(), thrift.releaseLock(LOCK.newBuilder(), UNCHECKED));
+ private Response deprecatedAddInstances(AddInstancesConfig config) throws Exception {
+ return thrift.addInstances(config, null, 0);
}
@Test
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
index 80e8ebe..a39226c 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
@@ -175,7 +175,7 @@ public class ThriftIT extends EasyMockTest {
.setTaskConfig(task)
.setInstanceCount(1);
- assertEquals(OK, thrift.createJob(job, null).getResponseCode());
+ assertEquals(OK, thrift.createJob(job).getResponseCode());
ScheduledTask scheduledTask = Iterables.getOnlyElement(
thrift.getTasksStatus(new TaskQuery()).getResult().getScheduleStatusResult().getTasks());
assertEquals(ScheduleStatus.PENDING, scheduledTask.getStatus());
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/admin/test_admin.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/admin/test_admin.py b/src/test/python/apache/aurora/admin/test_admin.py
index 22605ec..fd3b919 100644
--- a/src/test/python/apache/aurora/admin/test_admin.py
+++ b/src/test/python/apache/aurora/admin/test_admin.py
@@ -16,7 +16,7 @@ import contextlib
from mock import PropertyMock, create_autospec, patch
-from apache.aurora.admin.admin import get_locks, get_scheduler, increase_quota, query, set_quota
+from apache.aurora.admin.admin import get_scheduler, increase_quota, query, set_quota
from apache.aurora.client.api import AuroraClientAPI
from apache.aurora.client.api.scheduler_client import SchedulerClient, SchedulerProxy
@@ -24,11 +24,8 @@ from .util import AuroraClientCommandTest
from gen.apache.aurora.api.ttypes import (
AssignedTask,
- GetLocksResult,
GetQuotaResult,
JobKey,
- Lock,
- LockKey,
ResourceAggregate,
Response,
ResponseCode,
@@ -192,46 +189,6 @@ class TestSetQuotaCommand(AuroraClientCommandTest):
assert isinstance(api.set_quota.call_args[0][3], int)
-class TestGetLocksCommand(AuroraClientCommandTest):
-
- MESSAGE = 'test message'
- USER = 'test user'
- LOCKS = [Lock(
- key=LockKey(job=JobKey('role', 'env', 'name')),
- token='test token',
- user=USER,
- timestampMs='300',
- message=MESSAGE)]
-
- @classmethod
- def create_response(cls, locks, response_code=None):
- response_code = ResponseCode.OK if response_code is None else response_code
- resp = Response(responseCode=response_code, details=[ResponseDetail(message='test')])
- resp.result = Result(getLocksResult=GetLocksResult(locks=locks))
- return resp
-
- def test_get_locks(self):
- """Tests successful execution of the get_locks command."""
- mock_options = self.setup_mock_options()
- with contextlib.nested(
- patch('twitter.common.app.get_options', return_value=mock_options),
- patch('apache.aurora.admin.admin.make_admin_client',
- return_value=create_autospec(spec=AuroraClientAPI)),
- patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS),
- patch('apache.aurora.admin.admin.print_results'),
- ) as (_, mock_make_admin_client, _, mock_print_results):
-
- api = mock_make_admin_client.return_value
- api.get_locks.return_value = self.create_response(self.LOCKS)
-
- get_locks([self.TEST_CLUSTER])
-
- assert api.get_locks.call_count == 1
- assert mock_print_results.call_count == 1
- assert "'message': '%s'" % self.MESSAGE in mock_print_results.call_args[0][0][0]
- assert "'user': '%s'" % self.USER in mock_print_results.call_args[0][0][0]
-
-
class TestGetSchedulerCommand(AuroraClientCommandTest):
def test_get_scheduler(self):
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/api_util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/api_util.py b/src/test/python/apache/aurora/api_util.py
index 4bb306f..1497332 100644
--- a/src/test/python/apache/aurora/api_util.py
+++ b/src/test/python/apache/aurora/api_util.py
@@ -70,34 +70,28 @@ class SchedulerThriftApiSpec(ReadOnlyScheduler.Iface):
def rewriteConfigs(self, request):
pass
- def createJob(self, description, lock):
+ def createJob(self, description):
pass
- def scheduleCronJob(self, description, lock):
+ def scheduleCronJob(self, description):
pass
- def descheduleCronJob(self, job, lock):
+ def descheduleCronJob(self, job):
pass
def startCronJob(self, job):
pass
- def restartShards(self, job, shardIds, lock):
+ def restartShards(self, job, shardIds):
pass
- def killTasks(self, query, lock, jobKey, instances):
+ def killTasks(self, query, jobKey, instances):
pass
- def addInstances(self, config, lock, key, count):
+ def addInstances(self, config, key, count):
pass
- def acquireLock(self, lockKey):
- pass
-
- def releaseLock(self, lock, validation):
- pass
-
- def replaceCronTemplate(self, config, lock):
+ def replaceCronTemplate(self, config):
pass
def startJobUpdate(self, request, message):
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/client/api/test_api.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_api.py b/src/test/python/apache/aurora/client/api/test_api.py
index c066ae7..0dd4b41 100644
--- a/src/test/python/apache/aurora/client/api/test_api.py
+++ b/src/test/python/apache/aurora/client/api/test_api.py
@@ -119,7 +119,6 @@ class TestJobUpdateApis(unittest.TestCase):
mock_proxy.addInstances.assert_called_once_with(
None,
- None,
InstanceKey(jobKey=job_key.to_thrift(), instanceId=1),
10)
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/client/api/test_restarter.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_restarter.py b/src/test/python/apache/aurora/client/api/test_restarter.py
index a75981c..ff2002e 100644
--- a/src/test/python/apache/aurora/client/api/test_restarter.py
+++ b/src/test/python/apache/aurora/client/api/test_restarter.py
@@ -61,7 +61,6 @@ class TestRestarter(MoxTestBase):
self.mock_scheduler = self.mox.CreateMock(scheduler_client)
self.mock_instance_watcher = self.mox.CreateMock(InstanceWatcher)
- self.lock = None
self.restarter = Restarter(
JOB,
@@ -69,11 +68,8 @@ class TestRestarter(MoxTestBase):
FakeSchedulerProxy(Cluster(name=CLUSTER), self.mock_scheduler),
self.mock_instance_watcher)
- def mock_restart_instances(self, instances, lock=None):
- self.mock_scheduler.restartShards(
- JOB.to_thrift(),
- instances,
- lock).AndReturn(make_response())
+ def mock_restart_instances(self, instances):
+ self.mock_scheduler.restartShards(JOB.to_thrift(), instances).AndReturn(make_response())
self.mock_instance_watcher.watch(instances).AndReturn([])
def test_restart_one_iteration(self):
@@ -128,10 +124,7 @@ class TestRestarter(MoxTestBase):
def mock_restart_fails(self):
response = make_response(code=ResponseCode.ERROR, message='test error')
- self.mock_scheduler.restartShards(
- JOB.to_thrift(),
- IgnoreArg(),
- self.lock).AndReturn(response)
+ self.mock_scheduler.restartShards(JOB.to_thrift(), IgnoreArg()).AndReturn(response)
def test_restart_instance_fails(self):
self.mock_status_active_tasks([0, 1])
@@ -142,10 +135,7 @@ class TestRestarter(MoxTestBase):
assert self.restarter.restart(None).responseCode == ResponseCode.ERROR
def mock_restart_watch_fails(self, instances):
- self.mock_scheduler.restartShards(
- JOB.to_thrift(),
- instances,
- self.lock).AndReturn(make_response())
+ self.mock_scheduler.restartShards(JOB.to_thrift(), instances).AndReturn(make_response())
self.mock_instance_watcher.watch(instances).AndReturn(instances)
def test_restart_instances_watch_fails(self):
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/client/api/test_scheduler_client.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_scheduler_client.py b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
index bed800d..0b14b09 100644
--- a/src/test/python/apache/aurora/client/api/test_scheduler_client.py
+++ b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
@@ -40,7 +40,6 @@ from gen.apache.aurora.api.ttypes import (
JobUpdateQuery,
JobUpdateRequest,
Lock,
- LockValidation,
ResourceAggregate,
Response,
ResponseCode,
@@ -123,11 +122,9 @@ class TestSchedulerProxyInjection(unittest.TestCase):
self.make_scheduler_proxy().populateJobConfig(JobConfiguration())
def test_restartShards(self):
- self.mock_thrift_client.restartShards(
- IsA(JobKey),
- IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
+ self.mock_thrift_client.restartShards(IsA(JobKey), IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
self.mox.ReplayAll()
- self.make_scheduler_proxy().restartShards(JOB_KEY, set([0]))
+ self.make_scheduler_proxy().restartShards(JOB_KEY, {0})
def test_getTasksStatus(self):
self.mock_thrift_client.getTasksStatus(IsA(TaskQuery)).AndReturn(DEFAULT_RESPONSE)
@@ -142,11 +139,10 @@ class TestSchedulerProxyInjection(unittest.TestCase):
def test_killTasks(self):
self.mock_thrift_client.killTasks(
IgnoreArg(),
- IgnoreArg(),
IsA(JobKey),
IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
self.mox.ReplayAll()
- self.make_scheduler_proxy().killTasks(None, None, JobKey(), set([0]))
+ self.make_scheduler_proxy().killTasks(None, JobKey(), {0})
def test_getQuota(self):
self.mock_thrift_client.getQuota(IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
@@ -161,18 +157,6 @@ class TestSchedulerProxyInjection(unittest.TestCase):
self.mox.ReplayAll()
self.make_scheduler_proxy().addInstances(JobKey(), {}, Lock())
- def test_acquireLock(self):
- self.mock_thrift_client.acquireLock(IsA(Lock)).AndReturn(DEFAULT_RESPONSE)
- self.mox.ReplayAll()
- self.make_scheduler_proxy().acquireLock(Lock())
-
- def test_releaseLock(self):
- self.mock_thrift_client.releaseLock(
- IsA(Lock),
- IsA(LockValidation)).AndReturn(DEFAULT_RESPONSE)
- self.mox.ReplayAll()
- self.make_scheduler_proxy().releaseLock(Lock(), LockValidation())
-
def test_getJobUpdateSummaries(self):
self.mock_thrift_client.getJobUpdateSummaries(IsA(JobUpdateQuery)).AndReturn(DEFAULT_RESPONSE)
self.mox.ReplayAll()
@@ -476,7 +460,7 @@ class TestSchedulerClient(unittest.TestCase):
client.get.return_value = mock_scheduler_client
proxy = scheduler_client.SchedulerProxy(Cluster(name='local'))
- proxy.killTasks(None, None, JobKey(), None)
+ proxy.killTasks(None, JobKey(), None)
assert mock_thrift_client.killTasks.call_count == 3
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/client/cli/test_restart.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_restart.py b/src/test/python/apache/aurora/client/cli/test_restart.py
index fb4afcf..54de6cf 100644
--- a/src/test/python/apache/aurora/client/cli/test_restart.py
+++ b/src/test/python/apache/aurora/client/cli/test_restart.py
@@ -154,7 +154,7 @@ class TestRestartCommand(AuroraClientCommandTest):
assert mock_scheduler_proxy.restartShards.call_count == 4
# parameters for all calls are generated by the same code, so we just check one
mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
- role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19], None)
+ role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19])
def test_restart_simple_no_config(self):
# Test the client-side restart logic in its simplest case: everything succeeds
@@ -174,7 +174,7 @@ class TestRestartCommand(AuroraClientCommandTest):
assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count >= 4
assert mock_scheduler_proxy.restartShards.call_count == 4
mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
- role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19], None)
+ role=self.TEST_ROLE, name=self.TEST_JOB), [15, 16, 17, 18, 19])
def test_restart_invalid_shards(self):
# Test the client-side restart when a shard argument is too large, and it's
@@ -272,7 +272,7 @@ class TestRestartCommand(AuroraClientCommandTest):
assert mock_scheduler_proxy.getTasksWithoutConfigs.call_count == 1
assert mock_scheduler_proxy.restartShards.call_count == 1
mock_scheduler_proxy.restartShards.assert_called_with(JobKey(environment=self.TEST_ENV,
- role=self.TEST_ROLE, name=self.TEST_JOB), [0, 1, 2, 3, 4], None)
+ role=self.TEST_ROLE, name=self.TEST_JOB), [0, 1, 2, 3, 4])
assert result == EXIT_API_ERROR
MOCK_OUT = []
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/python/apache/aurora/client/hooks/test_non_hooked_api.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/hooks/test_non_hooked_api.py b/src/test/python/apache/aurora/client/hooks/test_non_hooked_api.py
index ca20ba5..04b2257 100644
--- a/src/test/python/apache/aurora/client/hooks/test_non_hooked_api.py
+++ b/src/test/python/apache/aurora/client/hooks/test_non_hooked_api.py
@@ -41,8 +41,8 @@ class TestNonHookedAuroraClientAPI(unittest.TestCase):
class FakeAuroraClientAPI(object):
- def kill_job(self, job_key, instances=None, lock=None):
- test_obj.API_CALL = functools.partial(self.kill_job, job_key, instances, lock)
+ def kill_job(self, job_key, instances=None):
+ test_obj.API_CALL = functools.partial(self.kill_job, job_key, instances)
return test_obj.RETURN_VALUE
def restart(self, job_key, shards, restart_settings):
@@ -60,7 +60,6 @@ class TestNonHookedAuroraClientAPI(unittest.TestCase):
self.test_job_key = AuroraJobKey.from_path('a/b/c/d')
self.test_config = 'bar'
self.test_shards = 'baz'
- self.test_lock = 'lock'
self.health_check_interval_seconds = 'baa'
def tearDown(self):
@@ -82,9 +81,8 @@ class TestNonHookedAuroraClientAPI(unittest.TestCase):
return_value = self.api.kill_job(
self.test_job_key,
self.test_shards,
- self.test_lock,
config=self.test_config)
- self._verify_api_call(return_value, self.test_job_key, self.test_shards, self.test_lock)
+ self._verify_api_call(return_value, self.test_job_key, self.test_shards)
def test_restart_discards_config(self):
return_value = self.api.restart(
[2/2] aurora git commit: Remove lock-related constructs from the API.
Posted by wf...@apache.org.
Remove lock-related constructs from the API.
Bugs closed: AURORA-1581
Reviewed at https://reviews.apache.org/r/45718/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/a9b3df88
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/a9b3df88
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/a9b3df88
Branch: refs/heads/master
Commit: a9b3df88e8b03fff1f7e4dcaa501343c1feba130
Parents: 5109788
Author: Bill Farner <wf...@apache.org>
Authored: Tue Apr 5 15:27:26 2016 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Tue Apr 5 15:27:26 2016 -0700
----------------------------------------------------------------------
RELEASE-NOTES.md | 13 +
.../thrift/org/apache/aurora/gen/api.thrift | 47 +---
.../scheduler/http/JettyServerModule.java | 1 -
.../org/apache/aurora/scheduler/http/Locks.java | 93 -------
.../aurora/scheduler/state/LockManager.java | 12 +-
.../aurora/scheduler/state/LockManagerImpl.java | 26 +-
.../scheduler/thrift/ReadOnlySchedulerImpl.java | 14 +-
.../thrift/SchedulerThriftInterface.java | 93 ++-----
.../thrift/aop/AnnotatedAuroraAdmin.java | 31 +--
src/main/python/apache/aurora/admin/admin.py | 18 --
.../python/apache/aurora/client/api/__init__.py | 29 +--
.../apache/aurora/client/api/restarter.py | 6 +-
.../apache/aurora/client/hooks/hooked_api.py | 12 +-
.../apache/aurora/scheduler/http/LocksTest.java | 84 -------
.../aurora/scheduler/http/api/ApiBetaTest.java | 10 +-
.../http/api/security/HttpSecurityIT.java | 34 ++-
.../ShiroAuthorizingParamInterceptorTest.java | 12 +-
.../scheduler/state/LockManagerImplTest.java | 49 +---
.../aurora/scheduler/thrift/Fixtures.java | 4 -
.../thrift/ReadOnlySchedulerImplTest.java | 19 +-
.../thrift/SchedulerThriftInterfaceTest.java | 245 +++++++------------
.../aurora/scheduler/thrift/ThriftIT.java | 2 +-
.../python/apache/aurora/admin/test_admin.py | 45 +---
src/test/python/apache/aurora/api_util.py | 20 +-
.../python/apache/aurora/client/api/test_api.py | 1 -
.../apache/aurora/client/api/test_restarter.py | 18 +-
.../aurora/client/api/test_scheduler_client.py | 24 +-
.../apache/aurora/client/cli/test_restart.py | 6 +-
.../aurora/client/hooks/test_non_hooked_api.py | 8 +-
29 files changed, 207 insertions(+), 769 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/RELEASE-NOTES.md
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 2f935da..0e2e04b 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -35,6 +35,19 @@
- `TaskConfig.jobName`
- `TaskQuery.owner`
- Removed deprecated executor argument `-announcer-enable`, which was a no-op in 0.12.0.
+- Removed deprecated API constructs related to Locks:
+ - removed RPCs that managed locks
+ - `acquireLock`
+ - `releaseLock`
+ - `getLocks`
+ - removed `Lock` parameters to RPCs
+ - `createJob`
+ - `scheduleCronJob`
+ - `descheduleCronJob`
+ - `restartShards`
+ - `killTasks`
+ - `addInstances`
+ - `replaceCronTemplate`
- Task ID strings are no longer prefixed by a timestamp.
0.12.0
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/api/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/api/src/main/thrift/org/apache/aurora/gen/api.thrift b/api/src/main/thrift/org/apache/aurora/gen/api.thrift
index d4b8904..2412490 100644
--- a/api/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/api/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -143,14 +143,6 @@ struct Lock {
5: optional string message
}
-/** Defines the required lock validation level. */
-enum LockValidation {
- /** The lock must be valid in order to be released. */
- CHECKED = 0
- /** The lock will be released without validation (aka "force release"). */
- UNCHECKED = 1
-}
-
/** A unique identifier for the active task within a job. */
struct InstanceKey {
/** Key identifying the job. */
@@ -347,12 +339,6 @@ struct GetQuotaResult {
5: optional ResourceAggregate nonProdDedicatedConsumption
}
-/** Wraps return results for the acquireLock API. */
-struct AcquireLockResult {
- /** Acquired Lock instance. */
- 1: Lock lock
-}
-
/** States that a task may be in. */
enum ScheduleStatus {
// TODO(maxim): This state does not add much value. Consider dropping it completely.
@@ -840,10 +826,6 @@ struct JobSummaryResult {
1: set<JobSummary> summaries
}
-struct GetLocksResult {
- 1: set<Lock> locks
-}
-
struct ConfigSummaryResult {
1: ConfigSummary summary
}
@@ -905,10 +887,8 @@ union Result {
9: QueryRecoveryResult queryRecoveryResult
10: MaintenanceStatusResult maintenanceStatusResult
11: EndMaintenanceResult endMaintenanceResult
- 16: AcquireLockResult acquireLockResult
17: RoleSummaryResult roleSummaryResult
18: JobSummaryResult jobSummaryResult
- 19: GetLocksResult getLocksResult
20: ConfigSummaryResult configSummaryResult
21: GetPendingReasonResult getPendingReasonResult
22: StartJobUpdateResult startJobUpdateResult
@@ -972,9 +952,6 @@ service ReadOnlyScheduler {
*/
Response populateJobConfig(1: JobConfiguration description)
- /** Returns all stored context specific resource/operation locks. */
- Response getLocks()
-
/** Gets job update summaries. */
Response getJobUpdateSummaries(1: JobUpdateQuery jobUpdateQuery)
@@ -990,20 +967,20 @@ service AuroraSchedulerManager extends ReadOnlyScheduler {
* Creates a new job. The request will be denied if a job with the provided name already exists
* in the cluster.
*/
- Response createJob(1: JobConfiguration description, 3: Lock lock)
+ Response createJob(1: JobConfiguration description)
/**
* Enters a job into the cron schedule, without actually starting the job.
* If the job is already present in the schedule, this will update the schedule entry with the new
* configuration.
*/
- Response scheduleCronJob(1: JobConfiguration description, 3: Lock lock)
+ Response scheduleCronJob(1: JobConfiguration description)
/**
* Removes a job from the cron schedule. The request will be denied if the job was not previously
* scheduled with scheduleCronJob.
*/
- Response descheduleCronJob(4: JobKey job, 3: Lock lock)
+ Response descheduleCronJob(4: JobKey job)
/**
* Starts a cron job immediately. The request will be denied if the specified job does not
@@ -1012,10 +989,10 @@ service AuroraSchedulerManager extends ReadOnlyScheduler {
Response startCronJob(4: JobKey job)
/** Restarts a batch of shards. */
- Response restartShards(5: JobKey job, 3: set<i32> shardIds, 6: Lock lock)
+ Response restartShards(5: JobKey job, 3: set<i32> shardIds)
/** Initiates a kill on tasks. TODO(maxim): remove TaskQuery in AURORA-1591. */
- Response killTasks(1: TaskQuery query, 3: Lock lock, 4: JobKey job, 5: set<i32> instances)
+ Response killTasks(1: TaskQuery query, 4: JobKey job, 5: set<i32> instances)
/**
* Adds new instances with the TaskConfig of the existing instance pointed by the key.
@@ -1023,25 +1000,15 @@ service AuroraSchedulerManager extends ReadOnlyScheduler {
*/
Response addInstances(
1: AddInstancesConfig config,
- 2: Lock lock,
3: InstanceKey key,
4: i32 count)
- /**
- * Creates and saves a new Lock instance guarding against multiple mutating operations within the
- * context defined by LockKey.
- */
- Response acquireLock(1: LockKey lockKey)
-
- /** Releases the lock acquired earlier in acquireLock call. */
- Response releaseLock(1: Lock lock, 2: LockValidation validation)
-
// TODO(maxim): reevaluate if it's still needed when client updater is gone (AURORA-785).
/**
* Replaces the template (configuration) for the existing cron job.
* The cron job template (configuration) must exist for the call to succeed.
*/
- Response replaceCronTemplate(1: JobConfiguration config, 2: Lock lock)
+ Response replaceCronTemplate(1: JobConfiguration config)
/** Starts update of the existing service job. */
Response startJobUpdate(
@@ -1168,4 +1135,4 @@ service AuroraAdmin extends AuroraSchedulerManager {
}
// The name of the header that should be sent to bypass leader redirection in the Scheduler.
-const string BYPASS_LEADER_REDIRECT_HEADER_NAME = 'Bypass-Leader-Redirect'
\ No newline at end of file
+const string BYPASS_LEADER_REDIRECT_HEADER_NAME = 'Bypass-Leader-Redirect'
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
index a5446e3..5b5cde5 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
@@ -217,7 +217,6 @@ public class JettyServerModule extends AbstractModule {
.put(Cron.class, "cron")
.put(HealthHandler.class, "health")
.put(LeaderHealth.class, "leaderhealth")
- .put(Locks.class, "locks")
.put(LogConfig.class, "logconfig")
.put(Maintenance.class, "maintenance")
.put(Mname.class, "mname")
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/http/Locks.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/Locks.java b/src/main/java/org/apache/aurora/scheduler/http/Locks.java
deleted file mode 100644
index 0931289..0000000
--- a/src/main/java/org/apache/aurora/scheduler/http/Locks.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.http;
-
-import java.util.Objects;
-
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Maps;
-
-import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.scheduler.base.JobKeys;
-import org.apache.aurora.scheduler.state.LockManager;
-import org.apache.aurora.scheduler.storage.entities.ILock;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/**
- * Servlet that exposes existing resource/operation locks.
- */
-@Path("/locks")
-public class Locks {
-
- private final LockManager lockManager;
-
- @Inject
- Locks(LockManager lockManager) {
- this.lockManager = Objects.requireNonNull(lockManager);
- }
-
- /**
- * Dumps existing locks.
- *
- * @return HTTP response.
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getLocks() {
- return Response.ok(Maps.transformValues(
- Maps.uniqueIndex(lockManager.getLocks(), TO_LOCK_KEY), TO_BEAN)).build();
- }
-
- private static final Function<ILock, String> TO_LOCK_KEY =
- lock -> lock.getKey().getSetField() == LockKey._Fields.JOB
- ? JobKeys.canonicalString(lock.getKey().getJob())
- : "Unknown lock key type: " + lock.getKey().getSetField();
-
- private static final Function<ILock, LockBean> TO_BEAN = LockBean::new;
-
- private static final class LockBean {
- private final ILock lock;
-
- LockBean(ILock lock) {
- this.lock = lock;
- }
-
- @JsonProperty("token")
- public String getToken() {
- return lock.getToken();
- }
-
- @JsonProperty("user")
- public String getUser() {
- return lock.getUser();
- }
-
- @JsonProperty("timestampMs")
- public long getTimestampMs() {
- return lock.getTimestampMs();
- }
-
- @JsonProperty("message")
- public String getMessage() {
- return lock.getMessage();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/state/LockManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/LockManager.java b/src/main/java/org/apache/aurora/scheduler/state/LockManager.java
index 07de8fc..2723306 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/LockManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/LockManager.java
@@ -13,8 +13,6 @@
*/
package org.apache.aurora.scheduler.state;
-import java.util.Optional;
-
import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
@@ -42,16 +40,12 @@ public interface LockManager {
void releaseLock(ILock lock);
/**
- * Verifies if the provided lock instance is identical to the one stored in the scheduler
- * ONLY if the operation context represented by the {@link ILockKey} is in fact locked.
- * No validation will be performed in case there is no correspondent scheduler lock
- * found for the provided context.
+ * Asserts that an entity is not locked.
*
* @param context Operation context to validate with the provided lock.
- * @param heldLock Lock to validate.
- * @throws LockException If provided lock does not exist or not identical to the stored one.
+ * @throws LockException If provided context is locked.
*/
- void validateIfLocked(ILockKey context, Optional<ILock> heldLock) throws LockException;
+ void assertNotLocked(ILockKey context) throws LockException;
/**
* Returns all available locks stored.
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/state/LockManagerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/LockManagerImpl.java b/src/main/java/org/apache/aurora/scheduler/state/LockManagerImpl.java
index 6da6c69..632d256 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/LockManagerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/LockManagerImpl.java
@@ -82,29 +82,13 @@ public class LockManagerImpl implements LockManager {
}
@Override
- public void validateIfLocked(final ILockKey context, Optional<ILock> heldLock)
- throws LockException {
-
+ public void assertNotLocked(final ILockKey context) throws LockException {
Optional<ILock> stored = storage.read(
storeProvider -> storeProvider.getLockStore().fetchLock(context));
-
- // The implementation below assumes the following use cases:
- // +-----------+-----------------+----------+
- // | eq | held | not held |
- // +-----------+-----------------+----------+
- // |stored |(stored == held)?| invalid |
- // +-----------+-----------------+----------+
- // |not stored | invalid | valid |
- // +-----------+-----------------+----------+
- if (!stored.equals(heldLock)) {
- if (stored.isPresent()) {
- throw new LockException(String.format(
- "Unable to perform operation for %s due to active lock held",
- formatLockKey(context)));
- } else if (heldLock.isPresent()) {
- throw new LockException(
- String.format("Invalid operation context: %s", formatLockKey(context)));
- }
+ if (stored.isPresent()) {
+ throw new LockException(String.format(
+ "Unable to perform operation for %s due to active lock held",
+ formatLockKey(context)));
}
}
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
index 113af6a..bab34d8 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
@@ -48,7 +48,6 @@ import org.apache.aurora.gen.GetJobUpdateDetailsResult;
import org.apache.aurora.gen.GetJobUpdateDiffResult;
import org.apache.aurora.gen.GetJobUpdateSummariesResult;
import org.apache.aurora.gen.GetJobsResult;
-import org.apache.aurora.gen.GetLocksResult;
import org.apache.aurora.gen.GetPendingReasonResult;
import org.apache.aurora.gen.GetQuotaResult;
import org.apache.aurora.gen.JobConfiguration;
@@ -84,7 +83,6 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
import org.apache.aurora.scheduler.metadata.NearestFit;
import org.apache.aurora.scheduler.quota.QuotaInfo;
import org.apache.aurora.scheduler.quota.QuotaManager;
-import org.apache.aurora.scheduler.state.LockManager;
import org.apache.aurora.scheduler.storage.Storage;
import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
@@ -94,7 +92,6 @@ import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateQuery;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateRequest;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateSummary;
-import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.IRange;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -121,7 +118,6 @@ class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
private final NearestFit nearestFit;
private final CronPredictor cronPredictor;
private final QuotaManager quotaManager;
- private final LockManager lockManager;
@Inject
ReadOnlySchedulerImpl(
@@ -129,15 +125,13 @@ class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
Storage storage,
NearestFit nearestFit,
CronPredictor cronPredictor,
- QuotaManager quotaManager,
- LockManager lockManager) {
+ QuotaManager quotaManager) {
this.configurationManager = requireNonNull(configurationManager);
this.storage = requireNonNull(storage);
this.nearestFit = requireNonNull(nearestFit);
this.cronPredictor = requireNonNull(cronPredictor);
this.quotaManager = requireNonNull(quotaManager);
- this.lockManager = requireNonNull(lockManager);
}
@Override
@@ -299,12 +293,6 @@ class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
}
@Override
- public Response getLocks() {
- return ok(Result.getLocksResult(
- new GetLocksResult().setLocks(ILock.toBuildersSet(lockManager.getLocks()))));
- }
-
- @Override
public Response getJobUpdateSummaries(JobUpdateQuery mutableQuery) {
IJobUpdateQuery query = IJobUpdateQuery.build(requireNonNull(mutableQuery));
return ok(Result.getJobUpdateSummariesResult(
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 7eda474..9e6ea3c 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -35,7 +35,6 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Range;
-import org.apache.aurora.gen.AcquireLockResult;
import org.apache.aurora.gen.AddInstancesConfig;
import org.apache.aurora.gen.ConfigRewrite;
import org.apache.aurora.gen.DrainHostsResult;
@@ -54,9 +53,7 @@ import org.apache.aurora.gen.JobUpdateRequest;
import org.apache.aurora.gen.JobUpdateSettings;
import org.apache.aurora.gen.JobUpdateSummary;
import org.apache.aurora.gen.ListBackupsResult;
-import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.gen.LockValidation;
import org.apache.aurora.gen.MaintenanceStatusResult;
import org.apache.aurora.gen.PulseJobUpdateResult;
import org.apache.aurora.gen.QueryRecoveryResult;
@@ -108,7 +105,6 @@ import org.apache.aurora.scheduler.storage.entities.IJobUpdate;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateRequest;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateSettings;
-import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
import org.apache.aurora.scheduler.storage.entities.IRange;
import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
@@ -212,7 +208,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
}
@Override
- public Response createJob(JobConfiguration mutableJob, @Nullable Lock mutableLock) {
+ public Response createJob(JobConfiguration mutableJob) {
SanitizedConfiguration sanitized;
try {
sanitized = SanitizedConfiguration.fromUnsanitized(
@@ -230,9 +226,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
IJobConfiguration job = sanitized.getJobConfig();
try {
- lockManager.validateIfLocked(
- ILockKey.build(LockKey.job(job.getKey().newBuilder())),
- java.util.Optional.ofNullable(mutableLock).map(ILock::build));
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(job.getKey().newBuilder())));
checkJobExists(storeProvider, job.getKey());
@@ -275,7 +269,6 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
private Response createOrUpdateCronTemplate(
JobConfiguration mutableJob,
- @Nullable Lock mutableLock,
boolean updateOnly) {
IJobConfiguration job = IJobConfiguration.build(mutableJob);
@@ -294,9 +287,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
return storage.write(storeProvider -> {
try {
- lockManager.validateIfLocked(
- ILockKey.build(LockKey.job(jobKey.newBuilder())),
- java.util.Optional.ofNullable(mutableLock).map(ILock::build));
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(jobKey.newBuilder())));
ITaskConfig template = sanitized.getJobConfig().getTaskConfig();
int count = sanitized.getJobConfig().getInstanceCount();
@@ -325,22 +316,20 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
}
@Override
- public Response scheduleCronJob(JobConfiguration mutableJob, @Nullable Lock mutableLock) {
- return createOrUpdateCronTemplate(mutableJob, mutableLock, false);
+ public Response scheduleCronJob(JobConfiguration mutableJob) {
+ return createOrUpdateCronTemplate(mutableJob, false);
}
@Override
- public Response replaceCronTemplate(JobConfiguration mutableJob, @Nullable Lock mutableLock) {
- return createOrUpdateCronTemplate(mutableJob, mutableLock, true);
+ public Response replaceCronTemplate(JobConfiguration mutableJob) {
+ return createOrUpdateCronTemplate(mutableJob, true);
}
@Override
- public Response descheduleCronJob(JobKey mutableJobKey, @Nullable Lock mutableLock) {
+ public Response descheduleCronJob(JobKey mutableJobKey) {
try {
IJobKey jobKey = JobKeys.assertValid(IJobKey.build(mutableJobKey));
- lockManager.validateIfLocked(
- ILockKey.build(LockKey.job(jobKey.newBuilder())),
- java.util.Optional.ofNullable(mutableLock).map(ILock::build));
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(jobKey.newBuilder())));
if (cronJobManager.deleteJob(jobKey)) {
return ok();
@@ -410,16 +399,14 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
return readOnlyScheduler.getJobUpdateDiff(request);
}
- private void validateLockForTasks(java.util.Optional<ILock> lock, Iterable<IScheduledTask> tasks)
- throws LockException {
-
+ private void validateLockForTasks(Iterable<IScheduledTask> tasks) throws LockException {
ImmutableSet<IJobKey> uniqueKeys = FluentIterable.from(tasks)
.transform(Tasks::getJob)
.toSet();
// Validate lock against every unique job key derived from the tasks.
for (IJobKey key : uniqueKeys) {
- lockManager.validateIfLocked(ILockKey.build(LockKey.job(key.newBuilder())), lock);
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(key.newBuilder())));
}
}
@@ -431,7 +418,6 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
@Override
public Response killTasks(
@Nullable TaskQuery mutableQuery,
- @Nullable Lock mutableLock,
@Nullable JobKey mutableJob,
@Nullable Set<Integer> instances) {
@@ -458,9 +444,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
return storage.write(storeProvider -> {
Iterable<IScheduledTask> tasks = storeProvider.getTaskStore().fetchTasks(query);
try {
- validateLockForTasks(
- java.util.Optional.ofNullable(mutableLock).map(ILock::build),
- tasks);
+ validateLockForTasks(tasks);
} catch (LockException e) {
return error(LOCK_ERROR, e);
}
@@ -484,19 +468,13 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
}
@Override
- public Response restartShards(
- JobKey mutableJobKey,
- Set<Integer> shardIds,
- @Nullable Lock mutableLock) {
-
+ public Response restartShards(JobKey mutableJobKey, Set<Integer> shardIds) {
IJobKey jobKey = JobKeys.assertValid(IJobKey.build(mutableJobKey));
checkNotBlank(shardIds);
return storage.write(storeProvider -> {
try {
- lockManager.validateIfLocked(
- ILockKey.build(LockKey.job(jobKey.newBuilder())),
- java.util.Optional.ofNullable(mutableLock).map(ILock::build));
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(jobKey.newBuilder())));
} catch (LockException e) {
return error(LOCK_ERROR, e);
}
@@ -751,7 +729,6 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
@Override
public Response addInstances(
@Nullable AddInstancesConfig config,
- @Nullable Lock mutableLock,
@Nullable InstanceKey key,
int count) {
@@ -765,9 +742,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
return invalidRequest("Instances may not be added to cron jobs.");
}
- lockManager.validateIfLocked(
- ILockKey.build(LockKey.job(jobKey.newBuilder())),
- java.util.Optional.ofNullable(mutableLock).map(ILock::build));
+ lockManager.assertNotLocked(ILockKey.build(LockKey.job(jobKey.newBuilder())));
FluentIterable<IScheduledTask> currentTasks = FluentIterable.from(
storeProvider.getTaskStore().fetchTasks(Query.jobScoped(jobKey).active()));
@@ -826,44 +801,6 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin {
return storeProvider.getCronJobStore().fetchJob(jobKey);
}
- @Override
- public Response acquireLock(LockKey mutableLockKey) {
- requireNonNull(mutableLockKey);
-
- ILockKey lockKey = ILockKey.build(mutableLockKey);
-
- try {
- ILock lock = lockManager.acquireLock(lockKey, auditMessages.getRemoteUserName());
- return ok(Result.acquireLockResult(
- new AcquireLockResult().setLock(lock.newBuilder())));
- } catch (LockException e) {
- return error(LOCK_ERROR, e);
- }
- }
-
- @Override
- public Response releaseLock(Lock mutableLock, LockValidation validation) {
- requireNonNull(mutableLock);
- requireNonNull(validation);
-
- ILock lock = ILock.build(mutableLock);
-
- try {
- if (validation == LockValidation.CHECKED) {
- lockManager.validateIfLocked(lock.getKey(), java.util.Optional.of(lock));
- }
- lockManager.releaseLock(lock);
- return ok();
- } catch (LockException e) {
- return error(LOCK_ERROR, e);
- }
- }
-
- @Override
- public Response getLocks() throws TException {
- return readOnlyScheduler.getLocks();
- }
-
private static class TaskValidationException extends Exception {
TaskValidationException(String message) {
super(message);
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdmin.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdmin.java b/src/main/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdmin.java
index f2f69f9..f295992 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdmin.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/aop/AnnotatedAuroraAdmin.java
@@ -24,9 +24,6 @@ import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.JobKey;
import org.apache.aurora.gen.JobUpdateKey;
import org.apache.aurora.gen.JobUpdateRequest;
-import org.apache.aurora.gen.Lock;
-import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.gen.LockValidation;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.TaskQuery;
import org.apache.aurora.scheduler.http.api.security.AuthorizingParam;
@@ -45,19 +42,14 @@ import org.apache.thrift.TException;
*/
public interface AnnotatedAuroraAdmin extends AuroraAdmin.Iface {
@Override
- Response createJob(
- @AuthorizingParam @Nullable JobConfiguration description,
- @Nullable Lock lock) throws TException;
+ Response createJob(@AuthorizingParam @Nullable JobConfiguration description) throws TException;
@Override
Response scheduleCronJob(
- @AuthorizingParam @Nullable JobConfiguration description,
- @Nullable Lock lock) throws TException;
+ @AuthorizingParam @Nullable JobConfiguration description) throws TException;
@Override
- Response descheduleCronJob(
- @AuthorizingParam @Nullable JobKey job,
- @Nullable Lock lock) throws TException;
+ Response descheduleCronJob(@AuthorizingParam @Nullable JobKey job) throws TException;
@Override
Response startCronJob(
@@ -66,36 +58,23 @@ public interface AnnotatedAuroraAdmin extends AuroraAdmin.Iface {
@Override
Response restartShards(
@AuthorizingParam @Nullable JobKey job,
- @Nullable Set<Integer> shardIds,
- @Nullable Lock lock) throws TException;
+ @Nullable Set<Integer> shardIds) throws TException;
@Override
Response killTasks(
@AuthorizingParam @Nullable TaskQuery query,
- @Nullable Lock lock,
@AuthorizingParam @Nullable JobKey job,
@Nullable Set<Integer> instances) throws TException;
@Override
Response addInstances(
@AuthorizingParam @Nullable AddInstancesConfig config,
- @Nullable Lock lock,
@AuthorizingParam @Nullable InstanceKey key,
int count) throws TException;
@Override
- Response acquireLock(
- @AuthorizingParam @Nullable LockKey lockKey) throws TException;
-
- @Override
- Response releaseLock(
- @AuthorizingParam @Nullable Lock lock,
- @Nullable LockValidation validation) throws TException;
-
- @Override
Response replaceCronTemplate(
- @AuthorizingParam @Nullable JobConfiguration config,
- @Nullable Lock lock) throws TException;
+ @AuthorizingParam @Nullable JobConfiguration config) throws TException;
@Override
Response startJobUpdate(
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/python/apache/aurora/admin/admin.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/admin/admin.py b/src/main/python/apache/aurora/admin/admin.py
index 62a2302..e309460 100644
--- a/src/main/python/apache/aurora/admin/admin.py
+++ b/src/main/python/apache/aurora/admin/admin.py
@@ -16,7 +16,6 @@ from __future__ import print_function
import json
import optparse
-import pprint
import sys
from twitter.common import app, log
@@ -328,23 +327,6 @@ def scheduler_snapshot(cluster):
@app.command
-@requires.exactly('cluster')
-def get_locks(cluster):
- """usage: get_locks cluster
-
- Prints all context/operation locks in the scheduler.
- """
- resp = make_admin_client(cluster).get_locks()
- check_and_log_response(resp)
-
- pp = pprint.PrettyPrinter(indent=2)
- def pretty_print_lock(lock):
- return pp.pformat(vars(lock))
-
- print_results([',\n'.join(pretty_print_lock(t) for t in resp.result.getLocksResult.locks)])
-
-
-@app.command
@app.command_option('-X', '--exclude_file', dest='exclude_filename', default=None,
help='Exclusion filter. An optional text file listing host names (one per line)'
'to exclude from the result set if found.')
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/python/apache/aurora/client/api/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/__init__.py b/src/main/python/apache/aurora/client/api/__init__.py
index c5469bd..18a10e2 100644
--- a/src/main/python/apache/aurora/client/api/__init__.py
+++ b/src/main/python/apache/aurora/client/api/__init__.py
@@ -31,7 +31,6 @@ from gen.apache.aurora.api.ttypes import (
JobUpdateKey,
JobUpdateQuery,
JobUpdateRequest,
- Lock,
ResourceAggregate,
TaskQuery
)
@@ -71,21 +70,19 @@ class AuroraClientAPI(object):
def scheduler_proxy(self):
return self._scheduler_proxy
- def create_job(self, config, lock=None):
+ def create_job(self, config):
log.info('Creating job %s' % config.name())
log.debug('Full configuration: %s' % config.job())
- log.debug('Lock %s' % lock)
- return self._scheduler_proxy.createJob(config.job(), lock)
+ return self._scheduler_proxy.createJob(config.job())
- def schedule_cron(self, config, lock=None):
+ def schedule_cron(self, config):
log.info("Registering job %s with cron" % config.name())
log.debug('Full configuration: %s' % config.job())
- log.debug('Lock %s' % lock)
- return self._scheduler_proxy.scheduleCronJob(config.job(), lock)
+ return self._scheduler_proxy.scheduleCronJob(config.job())
- def deschedule_cron(self, jobkey, lock=None):
+ def deschedule_cron(self, jobkey):
log.info("Removing cron schedule for job %s" % jobkey)
- return self._scheduler_proxy.descheduleCronJob(jobkey.to_thrift(), lock)
+ return self._scheduler_proxy.descheduleCronJob(jobkey.to_thrift())
def populate_job_config(self, config):
return self._scheduler_proxy.populateJobConfig(config.job())
@@ -104,9 +101,9 @@ class AuroraClientAPI(object):
key = InstanceKey(jobKey=job_key.to_thrift(), instanceId=instance_id)
log.info("Adding %s instances to %s using the task config of instance %s"
% (count, job_key, instance_id))
- return self._scheduler_proxy.addInstances(None, None, key, count)
+ return self._scheduler_proxy.addInstances(None, key, count)
- def kill_job(self, job_key, instances=None, lock=None):
+ def kill_job(self, job_key, instances=None):
log.info("Killing tasks for job: %s" % job_key)
self._assert_valid_job_key(job_key)
@@ -114,7 +111,7 @@ class AuroraClientAPI(object):
log.info("Instances to be killed: %s" % instances)
instances = frozenset([int(s) for s in instances])
- return self._scheduler_proxy.killTasks(None, lock, job_key.to_thrift(), instances)
+ return self._scheduler_proxy.killTasks(None, job_key.to_thrift(), instances)
def check_status(self, job_key):
self._assert_valid_job_key(job_key)
@@ -322,9 +319,6 @@ class AuroraClientAPI(object):
def unsafe_rewrite_config(self, rewrite_request):
return self._scheduler_proxy.rewriteConfigs(rewrite_request)
- def get_locks(self):
- return self._scheduler_proxy.getLocks()
-
def sla_get_job_uptime_vector(self, job_key):
self._assert_valid_job_key(job_key)
return Sla(self._scheduler_proxy).get_job_uptime_vector(job_key)
@@ -335,11 +329,6 @@ class AuroraClientAPI(object):
min_instance_count,
hosts)
- def _assert_valid_lock(self, lock):
- if not isinstance(lock, Lock):
- raise TypeError('Invalid lock %r: expected %s but got %s'
- % (lock, AuroraJobKey.__name__, lock.__class__.__name__))
-
def _assert_valid_job_key(self, job_key):
if not isinstance(job_key, AuroraJobKey):
raise TypeError('Invalid job_key %r: expected %s but got %s'
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/python/apache/aurora/client/api/restarter.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/restarter.py b/src/main/python/apache/aurora/client/api/restarter.py
index cd63311..fbe8f20 100644
--- a/src/main/python/apache/aurora/client/api/restarter.py
+++ b/src/main/python/apache/aurora/client/api/restarter.py
@@ -48,12 +48,10 @@ class Restarter(object):
job_key,
restart_settings,
scheduler,
- instance_watcher=None,
- lock=None):
+ instance_watcher=None):
self._job_key = job_key
self._restart_settings = restart_settings
self._scheduler = scheduler
- self._lock = lock
self._instance_watcher = instance_watcher or InstanceWatcher(
scheduler,
job_key.to_thrift(),
@@ -90,7 +88,7 @@ class Restarter(object):
log.info("Restarting instances: %s", batch)
- resp = self._scheduler.restartShards(self._job_key.to_thrift(), batch, self._lock)
+ resp = self._scheduler.restartShards(self._job_key.to_thrift(), batch)
if resp.responseCode != ResponseCode.OK:
log.error('Error restarting instances: %s', combine_messages(resp))
return resp
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/main/python/apache/aurora/client/hooks/hooked_api.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/hooks/hooked_api.py b/src/main/python/apache/aurora/client/hooks/hooked_api.py
index 300071f..542f165 100644
--- a/src/main/python/apache/aurora/client/hooks/hooked_api.py
+++ b/src/main/python/apache/aurora/client/hooks/hooked_api.py
@@ -52,8 +52,8 @@ class NonHookedAuroraClientAPI(AuroraClientAPI):
def add_instances(self, job_key, instance_id, count, config=None):
return super(NonHookedAuroraClientAPI, self).add_instances(job_key, instance_id, count)
- def kill_job(self, job_key, instances=None, lock=None, config=None):
- return super(NonHookedAuroraClientAPI, self).kill_job(job_key, instances=instances, lock=lock)
+ def kill_job(self, job_key, instances=None, config=None):
+ return super(NonHookedAuroraClientAPI, self).kill_job(job_key, instances=instances)
def restart(self, job_key, shards, restart_settings, config=None):
return super(NonHookedAuroraClientAPI, self).restart(job_key, shards, restart_settings)
@@ -153,19 +153,19 @@ class HookedAuroraClientAPI(NonHookedAuroraClientAPI):
return resp
- def create_job(self, config, lock=None):
+ def create_job(self, config):
return self._hooked_call(config, None,
- _partial(super(HookedAuroraClientAPI, self).create_job, config, lock))
+ _partial(super(HookedAuroraClientAPI, self).create_job, config))
def add_instances(self, job_key, instance_id, count, config=None):
return self._hooked_call(config, job_key,
_partial(super(HookedAuroraClientAPI, self).add_instances,
job_key, instance_id, count, config=config))
- def kill_job(self, job_key, instances=None, lock=None, config=None):
+ def kill_job(self, job_key, instances=None, config=None):
return self._hooked_call(config, job_key,
_partial(super(HookedAuroraClientAPI, self).kill_job,
- job_key, instances=instances, lock=lock, config=config))
+ job_key, instances=instances, config=config))
def restart(self, job_key, shards, restart_settings, config=None):
return self._hooked_call(config, job_key,
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/http/LocksTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/LocksTest.java b/src/test/java/org/apache/aurora/scheduler/http/LocksTest.java
deleted file mode 100644
index 94c3c29..0000000
--- a/src/test/java/org/apache/aurora/scheduler/http/LocksTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aurora.scheduler.http;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.Response;
-
-import com.google.common.collect.ImmutableSet;
-
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.gen.Lock;
-import org.apache.aurora.gen.LockKey;
-import org.apache.aurora.scheduler.base.JobKeys;
-import org.apache.aurora.scheduler.state.LockManager;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.aurora.scheduler.storage.entities.ILock;
-import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class LocksTest extends EasyMockTest {
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
- private static final IJobKey JOB_KEY = JobKeys.from("role", "env", "job");
- private static final ILockKey LOCK_KEY = ILockKey.build(LockKey.job(JOB_KEY.newBuilder()));
-
- private Locks locks;
- private LockManager lockManager;
-
- @Before
- public void setUp() {
- lockManager = createMock(LockManager.class);
- locks = new Locks(lockManager);
- }
-
- @Test
- public void testDumpContents() throws Exception {
- ILock lock = ILock.build(new Lock()
- .setKey(LOCK_KEY.newBuilder())
- .setToken("test token")
- .setMessage("test msg")
- .setUser("test usr")
- .setTimestampMs(325));
- expect(lockManager.getLocks()).andReturn(ImmutableSet.of(lock));
-
- control.replay();
-
- Response response = locks.getLocks();
- assertEquals(HttpServletResponse.SC_OK, response.getStatus());
-
- String result = OBJECT_MAPPER.writeValueAsString(response.getEntity());
- assertTrue(result.contains("role/env/job"));
- assertTrue(result.contains("test token"));
- assertTrue(result.contains("test msg"));
- assertTrue(result.contains("test usr"));
- assertTrue(result.contains("325"));
- }
-
- @Test
- public void testDumpEmptyContents() throws Exception {
- expect(lockManager.getLocks()).andReturn(ImmutableSet.of());
-
- control.replay();
-
- Response response = locks.getLocks();
- assertEquals(HttpServletResponse.SC_OK, response.getStatus());
- assertEquals("{}", OBJECT_MAPPER.writeValueAsString(response.getEntity()));
- }
-}
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/http/api/ApiBetaTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/ApiBetaTest.java b/src/test/java/org/apache/aurora/scheduler/http/api/ApiBetaTest.java
index f14d405..ccef4ab 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/ApiBetaTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/ApiBetaTest.java
@@ -33,8 +33,6 @@ import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.JobKey;
import org.apache.aurora.gen.JobSummary;
import org.apache.aurora.gen.JobSummaryResult;
-import org.apache.aurora.gen.Lock;
-import org.apache.aurora.gen.LockKey;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.Result;
import org.apache.aurora.gen.RoleSummary;
@@ -54,7 +52,6 @@ import org.junit.Test;
import static org.apache.aurora.gen.ResponseCode.OK;
import static org.apache.aurora.gen.ScheduleStatus.RUNNING;
import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
@@ -88,20 +85,17 @@ public class ApiBetaTest extends AbstractJettyTest {
@Test
public void testCreateJob() throws Exception {
- Lock lock = new Lock()
- .setKey(LockKey.job(new JobKey("role", "env", "name")))
- .setToken("token");
Response response = new Response()
.setResponseCode(OK);
JobConfiguration job = JOB_CONFIG.newBuilder();
- expect(thrift.createJob(anyObject(), eq(lock))).andReturn(response);
+ expect(thrift.createJob(anyObject())).andReturn(response);
replayAndStart();
Response actualResponse = getRequestBuilder("/apibeta/createJob")
.entity(
- ImmutableMap.of("description", job, "lock", lock),
+ ImmutableMap.of("description", job),
MediaType.APPLICATION_JSON)
.post(Response.class);
assertEquals(IResponse.build(response), IResponse.build(actualResponse));
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
index dbec26f..9031217 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
@@ -35,7 +35,6 @@ import com.sun.jersey.api.client.ClientResponse;
import org.apache.aurora.gen.AuroraAdmin;
import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.ResponseCode;
import org.apache.aurora.scheduler.base.JobKeys;
@@ -228,7 +227,7 @@ public class HttpSecurityIT extends AbstractJettyTest {
private void assertKillTasksFails(AuroraAdmin.Client client) throws TException {
try {
- client.killTasks(null, null, null, null);
+ client.killTasks(null, null, null);
fail("killTasks should fail.");
} catch (TTransportException e) {
// Expected.
@@ -237,14 +236,14 @@ public class HttpSecurityIT extends AbstractJettyTest {
@Test
public void testAuroraSchedulerManager() throws TException, ServletException, IOException {
- expect(auroraAdmin.killTasks(null, new Lock().setMessage("1"), null, null)).andReturn(OK);
- expect(auroraAdmin.killTasks(null, new Lock().setMessage("2"), null, null)).andReturn(OK);
+ expect(auroraAdmin.killTasks(null, null, null)).andReturn(OK);
+ expect(auroraAdmin.killTasks(null, null, null)).andReturn(OK);
JobKey job = JobKeys.from("role", "env", "name").newBuilder();
ITaskQuery jobScopedQuery = Query.jobScoped(IJobKey.build(job)).get();
ITaskQuery adsScopedQuery = Query.jobScoped(ADS_STAGING_JOB).get();
- expect(auroraAdmin.killTasks(adsScopedQuery.newBuilder(), null, null, null)).andReturn(OK);
- expect(auroraAdmin.killTasks(null, null, ADS_STAGING_JOB.newBuilder(), null)).andReturn(OK);
+ expect(auroraAdmin.killTasks(adsScopedQuery.newBuilder(), null, null)).andReturn(OK);
+ expect(auroraAdmin.killTasks(null, ADS_STAGING_JOB.newBuilder(), null)).andReturn(OK);
expectShiroAfterAuthFilter().times(24);
@@ -252,56 +251,55 @@ public class HttpSecurityIT extends AbstractJettyTest {
assertEquals(
OK,
- getAuthenticatedClient(WFARNER).killTasks(null, new Lock().setMessage("1"), null, null));
+ getAuthenticatedClient(WFARNER).killTasks(null, null, null));
assertEquals(
OK,
- getAuthenticatedClient(ROOT).killTasks(null, new Lock().setMessage("2"), null, null));
+ getAuthenticatedClient(ROOT).killTasks(null, null, null));
assertEquals(
ResponseCode.INVALID_REQUEST,
- getAuthenticatedClient(UNPRIVILEGED).killTasks(null, null, null, null).getResponseCode());
+ getAuthenticatedClient(UNPRIVILEGED).killTasks(null, null, null).getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(UNPRIVILEGED)
- .killTasks(jobScopedQuery.newBuilder(), null, null, null)
+ .killTasks(jobScopedQuery.newBuilder(), null, null)
.getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(UNPRIVILEGED)
- .killTasks(null, null, job, null)
+ .killTasks(null, job, null)
.getResponseCode());
assertEquals(
ResponseCode.INVALID_REQUEST,
- getAuthenticatedClient(BACKUP_SERVICE).killTasks(null, null, null, null).getResponseCode());
+ getAuthenticatedClient(BACKUP_SERVICE).killTasks(null, null, null).getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(BACKUP_SERVICE)
- .killTasks(jobScopedQuery.newBuilder(), null, null, null)
+ .killTasks(jobScopedQuery.newBuilder(), null, null)
.getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(BACKUP_SERVICE)
- .killTasks(null, null, job, null)
+ .killTasks(null, job, null)
.getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(DEPLOY_SERVICE)
- .killTasks(jobScopedQuery.newBuilder(), null, null, null)
+ .killTasks(jobScopedQuery.newBuilder(), null, null)
.getResponseCode());
assertEquals(
ResponseCode.AUTH_FAILED,
getAuthenticatedClient(DEPLOY_SERVICE)
- .killTasks(null, null, job, null)
+ .killTasks(null, job, null)
.getResponseCode());
assertEquals(
OK,
getAuthenticatedClient(DEPLOY_SERVICE)
- .killTasks(adsScopedQuery.newBuilder(), null, null, null));
+ .killTasks(adsScopedQuery.newBuilder(), null, null));
assertEquals(
OK,
getAuthenticatedClient(DEPLOY_SERVICE).killTasks(
null,
- null,
ADS_STAGING_JOB.newBuilder(),
null));
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/http/api/security/ShiroAuthorizingParamInterceptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/security/ShiroAuthorizingParamInterceptorTest.java b/src/test/java/org/apache/aurora/scheduler/http/api/security/ShiroAuthorizingParamInterceptorTest.java
index a704730..503f0c3 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/security/ShiroAuthorizingParamInterceptorTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/security/ShiroAuthorizingParamInterceptorTest.java
@@ -115,12 +115,11 @@ public class ShiroAuthorizingParamInterceptorTest extends EasyMockTest {
expect(subject
.isPermitted(interceptor.makeTargetPermission("createJob", JOB_KEY)))
.andReturn(true);
- expect(thrift.createJob(jobConfiguration, null))
- .andReturn(response);
+ expect(thrift.createJob(jobConfiguration)).andReturn(response);
replayAndInitialize();
- assertSame(response, decoratedThrift.createJob(jobConfiguration, null));
+ assertSame(response, decoratedThrift.createJob(jobConfiguration));
}
@Test
@@ -131,12 +130,12 @@ public class ShiroAuthorizingParamInterceptorTest extends EasyMockTest {
// AURORA-1592.
expect(subject.isPermitted(interceptor.makeWildcardPermission("killTasks")))
.andReturn(true);
- expect(thrift.killTasks(new TaskQuery(), null, null, null))
+ expect(thrift.killTasks(new TaskQuery(), null, null))
.andReturn(response);
replayAndInitialize();
- assertSame(response, decoratedThrift.killTasks(new TaskQuery(), null, null, null));
+ assertSame(response, decoratedThrift.killTasks(new TaskQuery(), null, null));
}
@Test
@@ -151,7 +150,7 @@ public class ShiroAuthorizingParamInterceptorTest extends EasyMockTest {
assertEquals(
ResponseCode.AUTH_FAILED,
- decoratedThrift.killTasks(null, null, JOB_KEY.newBuilder(), null).getResponseCode());
+ decoratedThrift.killTasks(null, JOB_KEY.newBuilder(), null).getResponseCode());
}
@Test
@@ -165,7 +164,6 @@ public class ShiroAuthorizingParamInterceptorTest extends EasyMockTest {
ResponseCode.INVALID_REQUEST,
decoratedThrift.killTasks(
null,
- null,
JOB_KEY.newBuilder().setName(null),
null).getResponseCode());
}
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
index a146e40..19f9de3 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/LockManagerImplTest.java
@@ -106,51 +106,6 @@ public class LockManagerImplTest extends EasyMockTest {
}
@Test
- public void testValidateLockStoredEqualHeld() throws Exception {
- control.replay();
-
- ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
- lockManager.validateIfLocked(LOCK_KEY, Optional.of(lock));
- }
-
- @Test
- public void testValidateLockNotStoredNotHeld() throws Exception {
- control.replay();
-
- lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
- }
-
- @Test
- public void testValidateLockStoredNotEqualHeld() throws Exception {
- control.replay();
-
- expectLockException(JOB_KEY);
- ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
- lock = ILock.build(lock.newBuilder().setUser("bob"));
- lockManager.validateIfLocked(LOCK_KEY, Optional.of(lock));
- }
-
- @Test
- public void testValidateLockStoredNotEqualHeldWithHeldNull() throws Exception {
- control.replay();
-
- expectLockException(JOB_KEY);
- lockManager.acquireLock(LOCK_KEY, USER);
- lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
- }
-
- @Test
- public void testValidateLockNotStoredHeld() throws Exception {
- control.replay();
-
- IJobKey jobKey = JobKeys.from("r", "e", "n");
- expectLockException(jobKey);
- ILock lock = lockManager.acquireLock(LOCK_KEY, USER);
- ILockKey key = ILockKey.build(LockKey.job(jobKey.newBuilder()));
- lockManager.validateIfLocked(key, Optional.of(lock));
- }
-
- @Test
public void testGetLocks() throws Exception {
control.replay();
@@ -190,14 +145,14 @@ public class LockManagerImplTest extends EasyMockTest {
.build()
.newThread(() -> {
try {
- lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
} catch (LockException e) {
throw Throwables.propagate(e);
}
})
.start();
- lockManager.validateIfLocked(LOCK_KEY, Optional.empty());
+ lockManager.assertNotLocked(LOCK_KEY);
}
private void expectLockException(IJobKey key) {
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
index be98f38..fd6a40c 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
@@ -34,7 +34,6 @@ import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.JobSummary;
import org.apache.aurora.gen.JobSummaryResult;
import org.apache.aurora.gen.JobUpdateKey;
-import org.apache.aurora.gen.Lock;
import org.apache.aurora.gen.LockKey;
import org.apache.aurora.gen.MesosContainer;
import org.apache.aurora.gen.ResourceAggregate;
@@ -48,7 +47,6 @@ import org.apache.aurora.scheduler.base.JobKeys;
import org.apache.aurora.scheduler.quota.QuotaCheckResult;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
-import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IResult;
@@ -66,8 +64,6 @@ final class Fixtures {
static final String JOB_NAME = "job_foo";
static final IJobKey JOB_KEY = JobKeys.from(ROLE, "devel", JOB_NAME);
static final ILockKey LOCK_KEY = ILockKey.build(LockKey.job(JOB_KEY.newBuilder()));
- static final ILock LOCK =
- ILock.build(new Lock().setKey(LOCK_KEY.newBuilder()).setToken("token"));
static final JobConfiguration CRON_JOB = makeJob().setCronSchedule("* * * * *");
static final String TASK_ID = "task_id";
static final String UPDATE_ID = "82d6d790-3212-11e3-aa6e-0800200c9a74";
http://git-wip-us.apache.org/repos/asf/aurora/blob/a9b3df88/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
index fcb5c22..c3240cd 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
@@ -74,7 +74,6 @@ import org.apache.aurora.scheduler.filter.SchedulingFilter.Veto;
import org.apache.aurora.scheduler.metadata.NearestFit;
import org.apache.aurora.scheduler.quota.QuotaInfo;
import org.apache.aurora.scheduler.quota.QuotaManager;
-import org.apache.aurora.scheduler.state.LockManager;
import org.apache.aurora.scheduler.storage.entities.IConfigSummaryResult;
import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
@@ -100,7 +99,6 @@ import static org.apache.aurora.scheduler.thrift.Fixtures.CRON_JOB;
import static org.apache.aurora.scheduler.thrift.Fixtures.CRON_SCHEDULE;
import static org.apache.aurora.scheduler.thrift.Fixtures.IDENTITY;
import static org.apache.aurora.scheduler.thrift.Fixtures.JOB_KEY;
-import static org.apache.aurora.scheduler.thrift.Fixtures.LOCK;
import static org.apache.aurora.scheduler.thrift.Fixtures.QUOTA;
import static org.apache.aurora.scheduler.thrift.Fixtures.ROLE;
import static org.apache.aurora.scheduler.thrift.Fixtures.UPDATE_KEY;
@@ -123,7 +121,6 @@ public class ReadOnlySchedulerImplTest extends EasyMockTest {
private NearestFit nearestFit;
private CronPredictor cronPredictor;
private QuotaManager quotaManager;
- private LockManager lockManager;
private ReadOnlyScheduler.Iface thrift;
@@ -134,15 +131,13 @@ public class ReadOnlySchedulerImplTest extends EasyMockTest {
nearestFit = createMock(NearestFit.class);
cronPredictor = createMock(CronPredictor.class);
quotaManager = createMock(QuotaManager.class);
- lockManager = createMock(LockManager.class);
thrift = new ReadOnlySchedulerImpl(
TaskTestUtil.CONFIGURATION_MANAGER,
storageUtil.storage,
nearestFit,
cronPredictor,
- quotaManager,
- lockManager);
+ quotaManager);
}
@Test
@@ -317,18 +312,6 @@ public class ReadOnlySchedulerImplTest extends EasyMockTest {
}
@Test
- public void testGetLocks() throws Exception {
- expect(lockManager.getLocks()).andReturn(ImmutableSet.of(LOCK));
-
- control.replay();
-
- Response response = thrift.getLocks();
- assertEquals(
- LOCK.newBuilder(),
- Iterables.getOnlyElement(response.getResult().getGetLocksResult().getLocks()));
- }
-
- @Test
public void testGetQuota() throws Exception {
QuotaInfo infoMock = createMock(QuotaInfo.class);
expect(quotaManager.getQuotaInfo(ROLE, storageUtil.storeProvider)).andReturn(infoMock);