chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r822381 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java
Date Tue, 06 Oct 2009 17:56:35 GMT
Author: asrabkin
Date: Tue Oct  6 17:56:35 2009
New Revision: 822381

URL: http://svn.apache.org/viewvc?rev=822381&view=rev
Log:
CHUKWA-398. Make ConstRateAdaptor more deterministic.

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=822381&r1=822380&r2=822381&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Tue Oct  6 17:56:35 2009
@@ -144,6 +144,8 @@
 
   BUG FIXES
 
+    CHUKWA-398. Make ConstRateAdaptor more deterministic. (asrabkin)
+
     CHUKWA-386. Fix a bug in echo id to the browser for the iframe servlet. (Eric Yang)
 
     CHUKWA-380. FTA shouldn't emit empty chunks. (asrabkin)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java?rev=822381&r1=822380&r2=822381&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateAdaptor.java Tue Oct
 6 17:56:35 2009
@@ -49,6 +49,8 @@
   private long offset;
   private int bytesPerSec;
   private ChunkReceiver dest;
+
+  Random timeCoin;
   long seed;
   
   private volatile boolean stopping = false;
@@ -67,6 +69,12 @@
     Configuration conf = c.getConfiguration();
     MIN_SLEEP = conf.getInt("constAdaptor.minSleep", MIN_SLEEP);
     SLEEP_VARIANCE = conf.getInt("constAdaptor.sleepVariance", SLEEP_VARIANCE);
+    
+    timeCoin = new Random(seed);
+    long o =0;
+    while(o < offset)
+      o += (int) ((timeCoin.nextInt(SLEEP_VARIANCE) + MIN_SLEEP) *
+          (long) bytesPerSec / 1000L) + 8;
     super.start(); // this is a Thread.start
   }
 
@@ -89,12 +97,11 @@
   }
 
   public void run() {
-    Random timeCoin = new Random(seed);
     try {
       while (!stopping) {
         int MSToSleep = timeCoin.nextInt(SLEEP_VARIANCE) + MIN_SLEEP; 
-        int arraySize = (int) (MSToSleep * (long) bytesPerSec / 1000L);
-        ChunkImpl evt = nextChunk(arraySize + 8);
+        int arraySize = (int) (MSToSleep * (long) bytesPerSec / 1000L) + 8;
+        ChunkImpl evt = nextChunk(arraySize );
 
         dest.add(evt);
 

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java?rev=822381&r1=822380&r2=822381&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/ConstRateValidator.java Tue
Oct  6 17:56:35 2009
@@ -156,6 +156,7 @@
             msg =" dupchunk of length " + b.len + " at " + b.start;
           } else {
             duplicatedBytes = b.start + b.len - nextExpectedStart;
+            ok += b.len - duplicatedBytes;
             msg = "  overlap of " + duplicatedBytes+ " starting at " + b.start +
             " (total chunk len ="+b.len+")";
           }



Mime
View raw message