accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ctubbsii commented on a change in pull request #15: Added random pausing to continuous ingest
Date Wed, 27 Jun 2018 20:33:00 GMT
ctubbsii commented on a change in pull request #15: Added random pausing to continuous ingest
URL: https://github.com/apache/accumulo-testing/pull/15#discussion_r198631322
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/testing/core/continuous/ContinuousIngest.java
 ##########
 @@ -45,11 +45,43 @@
   private static final byte[] EMPTY_BYTES = new byte[0];
 
   private static List<ColumnVisibility> visibilities;
+  private static long lastPause;
+  private static long pauseWaitMs;
 
   private static ColumnVisibility getVisibility(Random rand) {
     return visibilities.get(rand.nextInt(visibilities.size()));
   }
 
+  private static boolean pauseEnabled(Properties props) {
+    String value = props.getProperty(TestProps.CI_INGEST_PAUSE_ENABLED);
+    return value != null && value.equals("true");
+  }
+
+  private static int getPauseWaitMs(Properties props, Random rand) {
+    int waitMin = Integer.parseInt(props.getProperty(TestProps.CI_INGEST_PAUSE_WAIT_MIN));
+    int waitMax = Integer.parseInt(props.getProperty(TestProps.CI_INGEST_PAUSE_WAIT_MAX));
+    return (rand.nextInt(waitMax - waitMin) + waitMin) * 1000;
+  }
+
+  private static int getPauseDurationMs(Properties props, Random rand) {
+    int durationMin = Integer.parseInt(props.getProperty(TestProps.CI_INGEST_PAUSE_DURATION_MIN));
+    int durationMax = Integer.parseInt(props.getProperty(TestProps.CI_INGEST_PAUSE_DURATION_MAX));
+    return (rand.nextInt(durationMax - durationMin) + durationMin) * 1000;
+  }
+
+  private static void pauseCheck(Properties props, Random rand) throws InterruptedException
{
+    if (pauseEnabled(props)) {
+      if (System.currentTimeMillis() > (lastPause + pauseWaitMs)) {
+        long pauseDurationMs = getPauseDurationMs(props, rand);
+        System.out.println("Pausing ingest for " + pauseDurationMs + " ms - " + System.currentTimeMillis());
+        Thread.sleep(pauseDurationMs);
+        lastPause = System.currentTimeMillis();
 
 Review comment:
   Should use nanoTime for time durations.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message