fixes #69 make sleep time a function of compact time 72/head
authorKeith Turner <kturner@apache.org>
Mon, 9 May 2016 21:02:30 +0000 (17:02 -0400)
committerKeith Turner <kturner@apache.org>
Mon, 9 May 2016 21:02:30 +0000 (17:02 -0400)
modules/accumulo/src/main/java/io/fluo/recipes/accumulo/cmds/CompactTransient.java
modules/accumulo/src/main/java/io/fluo/recipes/accumulo/ops/TableOperations.java

index 89c6291..af58564 100644 (file)
@@ -18,6 +18,7 @@ import javax.inject.Inject;
 
 import io.fluo.api.config.FluoConfiguration;
 import io.fluo.recipes.accumulo.ops.TableOperations;
+import org.slf4j.LoggerFactory;
 
 public class CompactTransient {
 
@@ -46,16 +47,18 @@ public class CompactTransient {
       }
     }
 
-    System.out.print("Compacting transient ranges ... ");
+    long t1 = System.currentTimeMillis();
     TableOperations.compactTransient(fluoConfig);
-    System.out.println("done.");
+    long t2 = System.currentTimeMillis();
     count--;
 
     while (count > 0) {
-      Thread.sleep(interval * 1000);
-      System.out.print("Compacting transient ranges ... ");
+      long sleepTime = Math.max(3 * (t2 - t1), interval * 1000);
+      LoggerFactory.getLogger(CompactTransient.class).info("Sleeping {}ms", sleepTime);
+      Thread.sleep(sleepTime);
+      t1 = System.currentTimeMillis();
       TableOperations.compactTransient(fluoConfig);
-      System.out.println("done.");
+      t2 = System.currentTimeMillis();
       count--;
     }
   }
index 4e7b794..25a5a85 100644 (file)
@@ -110,9 +110,11 @@ public class TableOperations {
       List<RowRange> ranges = transientRegistry.getTransientRanges();
 
       for (RowRange r : ranges) {
-        logger.debug("Compacting {} {}", r.getStart(), r.getEnd());
+        long t1 = System.currentTimeMillis();
         conn.tableOperations().compact(fluoConfig.getAccumuloTable(),
             new Text(r.getStart().toArray()), new Text(r.getEnd().toArray()), true, true);
+        long t2 = System.currentTimeMillis();
+        logger.info("Compacted {} {} in {}ms", r.getStart(), r.getEnd(), (t2 - t1));
       }
     }
   }