You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ma...@apache.org on 2012/11/06 05:51:55 UTC

svn commit: r1406041 - in /giraph/trunk: CHANGELOG giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java

Author: maja
Date: Tue Nov  6 04:51:54 2012
New Revision: 1406041

URL: http://svn.apache.org/viewvc?rev=1406041&view=rev
Log:
GIRAPH-403: GraphMapper.notiftySentMessages need to be thread-safe

Modified:
    giraph/trunk/CHANGELOG
    giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java

Modified: giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1406041&r1=1406040&r2=1406041&view=diff
==============================================================================
--- giraph/trunk/CHANGELOG (original)
+++ giraph/trunk/CHANGELOG Tue Nov  6 04:51:54 2012
@@ -1,6 +1,9 @@
 Giraph Change Log
 
 Release 0.2.0 - unreleased
+  GIRAPH-403: GraphMapper.notiftySentMessages need to be thread-safe 
+  (nitay via majakabiljo)
+
   GIRAPH-397: We should have copies of aggregators per thread
   to avoid synchronizing on aggregate() (majakabiljo)
 

Modified: giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java
URL: http://svn.apache.org/viewvc/giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java?rev=1406041&r1=1406040&r2=1406041&view=diff
==============================================================================
--- giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java (original)
+++ giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/GraphMapper.java Tue Nov  6 04:51:54 2012
@@ -117,6 +117,8 @@ public class GraphMapper<I extends Writa
   private Timer communicationTimer;
   /** Timer context for communication timer. */
   private TimerContext communicationTimerContext;
+  /** Lock for notifySentMessages() to make it thread safe */
+  private Object notifySentMsgLock = new Object();
 
   /** What kinds of functions to run on this mapper */
   public enum MapFunctions {
@@ -442,10 +444,14 @@ public class GraphMapper<I extends Writa
     // We are tracking the time between when the compute started and the first
     // message get sent. We use null to flag that we have already recorded it.
     if (timeToFirstMessageContext != null) {
-      timeToFirstMessageContext.stop();
-      timeToFirstMessageContext = null;
+      synchronized (notifySentMsgLock) {
+        if (timeToFirstMessageContext != null) {
+          timeToFirstMessageContext.stop();
+          timeToFirstMessageContext = null;
+          communicationTimerContext = communicationTimer.time();
+        }
+      }
     }
-    communicationTimerContext = communicationTimer.time();
   }
 
   /**