aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmclaugh...@apache.org
Subject aurora git commit: AURORA-1842 Expose stats on garbage collected rows in RowGarbageCollector
Date Thu, 22 Dec 2016 10:56:45 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 38b9311c3 -> 61e6bc6c4


AURORA-1842 Expose stats on garbage collected rows in RowGarbageCollector

Bugs closed: AURORA-1842

Reviewed at https://reviews.apache.org/r/54959/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/61e6bc6c
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/61e6bc6c
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/61e6bc6c

Branch: refs/heads/master
Commit: 61e6bc6c4516b3c0c7b601485b133097cb70ab78
Parents: 38b9311
Author: Mehrdad Nurolahzade <mehrdad@nurolahzade.com>
Authored: Thu Dec 22 02:55:51 2016 -0800
Committer: David McLaughlin <dmclaughlin@twitter.com>
Committed: Thu Dec 22 02:55:51 2016 -0800

----------------------------------------------------------------------
 .../scheduler/storage/db/RowGarbageCollector.java       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/61e6bc6c/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
b/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
index 8cd7bfe..d29bcf3 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollector.java
@@ -22,6 +22,8 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.AbstractScheduledService;
 
+import org.apache.aurora.common.inject.TimedInterceptor.Timed;
+import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.ibatis.exceptions.PersistenceException;
@@ -44,6 +46,7 @@ class RowGarbageCollector extends AbstractScheduledService {
   private static final List<Class<? extends GarbageCollectedTableMapper>> TABLES
=
       ImmutableList.of(TaskConfigMapper.class, JobKeyMapper.class);
 
+  private final AtomicLong deletedCount;
   private final Scheduler iterationScheduler;
   private final SqlSessionFactory sessionFactory;
 
@@ -55,11 +58,13 @@ class RowGarbageCollector extends AbstractScheduledService {
   RowGarbageCollector(
       Scheduler iterationScheduler,
       SqlSessionFactory sessionFactory,
-      Storage storage) {
+      Storage storage,
+      StatsProvider statsProvider) {
 
     this.iterationScheduler = requireNonNull(iterationScheduler);
     this.sessionFactory = requireNonNull(sessionFactory);
     this.storage = requireNonNull(storage);
+    this.deletedCount = statsProvider.makeCounter("row_garbage_collector_deleted");
   }
 
   @Override
@@ -67,12 +72,13 @@ class RowGarbageCollector extends AbstractScheduledService {
     return iterationScheduler;
   }
 
+  @Timed("row_garbage_collector_run")
   @VisibleForTesting
   @Override
   public void runOneIteration() {
     LOG.info("Scanning database tables for unreferenced rows.");
 
-    final AtomicLong deletedCount = new AtomicLong();
+    long startCount = deletedCount.get();
     for (Class<? extends GarbageCollectedTableMapper> tableClass : TABLES) {
       storage.write((NoResult.Quiet) storeProvider -> {
         try (SqlSession session = sessionFactory.openSession(true)) {
@@ -88,6 +94,6 @@ class RowGarbageCollector extends AbstractScheduledService {
         }
       });
     }
-    LOG.info("Deleted " + deletedCount.get() + " unreferenced rows.");
+    LOG.info("Deleted {} unreferenced rows.", Long.valueOf(deletedCount.get() - startCount));
   }
 }


Mime
View raw message