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 02:15:54 UTC

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

Author: maja
Date: Tue Nov  6 01:15:53 2012
New Revision: 1406023

URL: http://svn.apache.org/viewvc?rev=1406023&view=rev
Log:
GIRAPH-406: Enforce partition ids in [0, n-1]

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

Modified: giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/giraph/trunk/CHANGELOG?rev=1406023&r1=1406022&r2=1406023&view=diff
==============================================================================
--- giraph/trunk/CHANGELOG (original)
+++ giraph/trunk/CHANGELOG Tue Nov  6 01:15:53 2012
@@ -1,6 +1,8 @@
 Giraph Change Log
 
 Release 0.2.0 - unreleased
+  GIRAPH-406: Enforce partition ids in [0, n-1] (majakabiljo)
+
   GIRAPH-402: slf4j dependency bug (nitay via apresta)
 
   GIRAPH-401: Metrics should be disabled by default (apresta)

Modified: giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/BspServiceMaster.java
URL: http://svn.apache.org/viewvc/giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/BspServiceMaster.java?rev=1406023&r1=1406022&r2=1406023&view=diff
==============================================================================
--- giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/BspServiceMaster.java (original)
+++ giraph/trunk/giraph/src/main/java/org/apache/giraph/graph/BspServiceMaster.java Tue Nov  6 01:15:53 2012
@@ -977,6 +977,7 @@ public class BspServiceMaster<I extends 
       PartitionUtils.analyzePartitionStats(partitionOwners,
           allPartitionStatsList);
     }
+    checkPartitions(masterGraphPartitioner.getCurrentPartitionOwners());
 
     // If restarted, prepare the checkpoint restart
     if (getRestartedSuperstep() == getSuperstep()) {
@@ -1032,6 +1033,22 @@ public class BspServiceMaster<I extends 
   }
 
   /**
+   * Check if partition ids are valid
+   *
+   * @param partitionOwners List of partition ids for current superstep
+   */
+  private void checkPartitions(Collection<PartitionOwner> partitionOwners) {
+    for (PartitionOwner partitionOwner : partitionOwners) {
+      int partitionId = partitionOwner.getPartitionId();
+      if (partitionId < 0 || partitionId >= partitionOwners.size()) {
+        throw new IllegalStateException("checkPartitions: " +
+            "Invalid partition id " + partitionId +
+            " - partition ids must be values from 0 to (numPartitions - 1)");
+      }
+    }
+  }
+
+  /**
    * Check whether the workers chosen for this superstep are still alive
    *
    * @param chosenWorkerInfoHealthPath Path to the healthy workers in ZooKeeper