incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject svn commit: r951667 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/bsp/ClusterStatus.java src/test/org/apache/hama/bsp/TestClusterStatus.java
Date Sat, 05 Jun 2010 07:45:28 GMT
Author: hyunsik
Date: Sat Jun  5 07:45:28 2010
New Revision: 951667

URL: http://svn.apache.org/viewvc?rev=951667&view=rev
Log:
HAMA-270 : wrong sequence of readFields() of ClusterStatus

Added:
    incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java   (with props)
Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/bsp/ClusterStatus.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=951667&r1=951666&r2=951667&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Sat Jun  5 07:45:28 2010
@@ -142,7 +142,8 @@ Trunk (unreleased changes)
     HAMA-9: Upgrade dependencies (edwardyoon)
 
   BUG FIXES
- 
+  
+    HAMA-270: wrong sequence of readFields() of ClusterStatus (hyunsik)
     HAMA-260: Current version command of script is linked unknown class (edwardyoon)
     HAMA-250: Add --no-check-certificate option to 'wget' command lines (edwardyoon)
     HAMA-242: Wrong assignment of default setting inside BSPPeer constructor (hyunsik)

Modified: incubator/hama/trunk/src/java/org/apache/hama/bsp/ClusterStatus.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/bsp/ClusterStatus.java?rev=951667&r1=951666&r2=951667&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/bsp/ClusterStatus.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/bsp/ClusterStatus.java Sat Jun  5 07:45:28
2010
@@ -86,7 +86,7 @@ public class ClusterStatus implements Wr
    * @return the number of groom servers in the cluster.
    */
   public int getGroomServers() {
-    return tasks;
+    return numActiveGrooms;
   }
   
   /**
@@ -152,8 +152,10 @@ public class ClusterStatus implements Wr
     int numGroomNames = in.readInt();
     String name;
     if (numGroomNames > 0) {
-      name = Text.readString(in);
-      activeGrooms.add(name);
+      for(int i=0; i < numGroomNames; i++) {
+        name = Text.readString(in);
+        activeGrooms.add(name);
+      }
     }
     tasks = in.readInt();
     maxTasks = in.readInt();

Added: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java?rev=951667&view=auto
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java (added)
+++ incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java Sat Jun  5 07:45:28
2010
@@ -0,0 +1,56 @@
+package org.apache.hama.bsp;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.hadoop.io.DataInputBuffer;
+import org.apache.hadoop.io.DataOutputBuffer;
+
+import junit.framework.TestCase;
+
+public class TestClusterStatus extends TestCase {
+  Random rnd = new Random();
+  
+  protected void setUp() throws Exception {
+    super.setUp();
+  }
+
+  public final void testWriteAndReadFields() throws IOException {
+    DataOutputBuffer out = new DataOutputBuffer();
+    DataInputBuffer in = new DataInputBuffer();
+    
+    ClusterStatus status1;
+    List<String> grooms = new ArrayList<String>();
+        
+    for(int i=0;i< 10;i++) {
+      grooms.add("groom_"+rnd.nextInt());
+    }
+    
+    int tasks = rnd.nextInt(100);
+    int maxTasks = rnd.nextInt(100);
+    BSPMaster.State state = BSPMaster.State.RUNNING;
+    
+    status1 = new ClusterStatus(grooms, tasks, maxTasks, state);    
+    status1.write(out);
+    
+    in.reset(out.getData(), out.getLength());
+   
+    ClusterStatus status2 = new ClusterStatus();
+    status2.readFields(in);
+    
+    Set<String> grooms_s = new HashSet<String>(status1.getActiveGroomNames());
+    Set<String> grooms_o = new HashSet<String>(status2.getActiveGroomNames());
    
+    
+    assertEquals(status1.getGroomServers(), status2.getGroomServers());
+    
+    assertTrue(grooms_s.containsAll(grooms_o));
+    assertTrue(grooms_o.containsAll(grooms_s));    
+    
+    assertEquals(status1.getTasks(),status2.getTasks());
+    assertEquals(status1.getMaxTasks(), status2.getMaxTasks());
+  }
+}

Propchange: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestClusterStatus.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message