Repository: aurora Updated Branches: refs/heads/master 5e008ff7f -> 89338dd7f
Expose thrift workload stats on pruneTasks() invocations Bugs closed: AURORA-1901 Reviewed at https://reviews.apache.org/r/64284/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/89338dd7 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/89338dd7 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/89338dd7 Branch: refs/heads/master Commit: 89338dd7f4814b48da75ebb6125aca9cc4158a13 Parents: 5e008ff Author: Jing Chen <milantr...@gmail.com> Authored: Sun Dec 3 18:29:20 2017 +0100 Committer: Stephan Erb <s...@apache.org> Committed: Sun Dec 3 18:29:20 2017 +0100 ---------------------------------------------------------------------- .../aurora/scheduler/thrift/SchedulerThriftInterface.java | 8 +++++++- .../scheduler/thrift/SchedulerThriftInterfaceTest.java | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/89338dd7/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 a519b07..159fb29 100644 --- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java +++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java @@ -162,6 +162,8 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin { static final String ADD_INSTANCES = STAT_PREFIX + "addInstances"; @VisibleForTesting static final String START_JOB_UPDATE = STAT_PREFIX + "startJobUpdate"; + @VisibleForTesting + static final String PRUNE_TASKS = STAT_PREFIX + "pruneTasks"; private static final Logger LOG = LoggerFactory.getLogger(SchedulerThriftInterface.class); @@ -191,6 +193,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin { private final AtomicLong endMaintenanceCounter; private final AtomicLong addInstancesCounter; private final AtomicLong startJobUpdateCounter; + private final AtomicLong pruneTasksCounter; @Inject SchedulerThriftInterface( @@ -237,6 +240,7 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin { this.endMaintenanceCounter = statsProvider.makeCounter(END_MAINTENANCE); this.addInstancesCounter = statsProvider.makeCounter(ADD_INSTANCES); this.startJobUpdateCounter = statsProvider.makeCounter(START_JOB_UPDATE); + this.pruneTasksCounter = statsProvider.makeCounter(PRUNE_TASKS); } @Override @@ -972,7 +976,9 @@ class SchedulerThriftInterface implements AnnotatedAuroraAdmin { task -> task.getAssignedTask().getTaskId()); return storage.write(storeProvider -> { - stateManager.deleteTasks(storeProvider, Sets.newHashSet(taskIds)); + Set<String> taskIdsSet = Sets.newHashSet(taskIds); + stateManager.deleteTasks(storeProvider, taskIdsSet); + pruneTasksCounter.addAndGet(taskIdsSet.size()); return ok(); }); } http://git-wip-us.apache.org/repos/asf/aurora/blob/89338dd7/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 8837384..919ac14 100644 --- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java +++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java @@ -151,6 +151,7 @@ import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.KILL_T import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.MAINTENANCE_STATUS; import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.NOOP_JOB_UPDATE_MESSAGE; import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.NO_CRON; +import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.PRUNE_TASKS; import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.RESTART_SHARDS; import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.START_JOB_UPDATE; import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.START_MAINTENANCE; @@ -663,6 +664,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest { control.replay(); Response rsp = thrift.pruneTasks(new TaskQuery().setStatuses(Tasks.ACTIVE_STATES)); assertResponse(ResponseCode.ERROR, rsp); + assertEquals(0L, statsProvider.getLongValue(PRUNE_TASKS)); } @Test @@ -671,6 +673,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest { Response rsp = thrift.pruneTasks(new TaskQuery().setStatuses( ImmutableSet.of(ScheduleStatus.FINISHED, ScheduleStatus.KILLING))); assertResponse(ResponseCode.ERROR, rsp); + assertEquals(0L, statsProvider.getLongValue(PRUNE_TASKS)); } @Test @@ -684,6 +687,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest { control.replay(); assertOkResponse(thrift.pruneTasks(new TaskQuery())); + assertEquals(1L, statsProvider.getLongValue(PRUNE_TASKS)); } @Test @@ -698,6 +702,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest { assertOkResponse(thrift.pruneTasks( new TaskQuery().setStatuses(ImmutableSet.of(ScheduleStatus.FAILED)))); + assertEquals(1L, statsProvider.getLongValue(PRUNE_TASKS)); } @Test @@ -716,6 +721,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest { control.replay(); assertOkResponse(thrift.pruneTasks(query)); + assertEquals(3L, statsProvider.getLongValue(PRUNE_TASKS)); } @Test