hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1349747 - in /incubator/hama/trunk/core/src: main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java
Date Wed, 13 Jun 2012 10:53:56 GMT
Author: edwardyoon
Date: Wed Jun 13 10:53:55 2012
New Revision: 1349747

URL: http://svn.apache.org/viewvc?rev=1349747&view=rev
Log:
Uncomment test cases

Modified:
    incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
    incubator/hama/trunk/core/src/test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java?rev=1349747&r1=1349746&r2=1349747&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
(original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/sync/ZooKeeperSyncClientImpl.java
Wed Jun 13 10:53:55 2012
@@ -165,7 +165,7 @@ public class ZooKeeperSyncClientImpl imp
           try {
             zk.delete(getNodeName(taskId, superstep), 0);
           } catch (KeeperException.NoNodeException nne) {
-            LOG.warn(
+            LOG.debug(
                 "+++ (znode size is 1). Ignore because znode may disconnect.",
                 nne);
           }
@@ -205,7 +205,7 @@ public class ZooKeeperSyncClientImpl imp
               try {
                 zk.delete(getNodeName(taskId, superstep), 0);
               } catch (KeeperException.NoNodeException nne) {
-                LOG.warn("++++ Ignore because node may be dleted.", nne);
+                LOG.debug("++++ Ignore because node may be dleted.", nne);
               }
             }
 
@@ -404,7 +404,7 @@ public class ZooKeeperSyncClientImpl imp
         try {
           zk.create(path, null, Ids.OPEN_ACL_UNSAFE, mode);
         } catch (KeeperException.NodeExistsException nee) {
-          LOG.warn("Ignore because znode may be already created at " + path,
+          LOG.debug("Ignore because znode may be already created at " + path,
               nee);
         }
       }

Modified: incubator/hama/trunk/core/src/test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java?rev=1349747&r1=1349746&r2=1349747&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java
(original)
+++ incubator/hama/trunk/core/src/test/java/org/apache/hama/bsp/TestBSPMasterGroomServer.java
Wed Jun 13 10:53:55 2012
@@ -19,6 +19,9 @@
  */
 package org.apache.hama.bsp;
 
+import java.io.IOException;
+import java.util.ArrayList;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -33,6 +36,12 @@ import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
 import org.apache.hama.bsp.message.DiskQueue;
 import org.apache.hama.examples.ClassSerializePrinting;
+import org.apache.hama.zookeeper.QuorumPeer;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.data.Stat;
 
 public class TestBSPMasterGroomServer extends HamaCluster {
 
@@ -102,8 +111,8 @@ public class TestBSPMasterGroomServer ex
     assertEquals(listStatus.length, tasks);
     for (FileStatus status : listStatus) {
       if (!status.isDir()) {
-        SequenceFile.Reader reader = new SequenceFile.Reader(fileSys,
-            status.getPath(), conf);
+        SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, status
+            .getPath(), conf);
         int superStep = 0;
         int taskstep = 0;
         IntWritable key = new IntWritable();
@@ -132,35 +141,45 @@ public class TestBSPMasterGroomServer ex
    */
 
   /*
-   * BEGIN: ZooKeeper tests. public void testClearZKNodes() throws IOException,
-   * KeeperException, InterruptedException { // Clear any existing znode with
-   * the same path as bspRoot. bspCluster.getBSPMaster().clearZKNodes(); int
-   * timeout = configuration.getInt(Constants.ZOOKEEPER_SESSION_TIMEOUT, 6000);
-   * String connectStr = QuorumPeer.getZKQuorumServersString(configuration);
-   * String bspRoot = configuration.get(Constants.ZOOKEEPER_ROOT,
-   * Constants.DEFAULT_ZOOKEEPER_ROOT); // Establishing a zk session. ZooKeeper
-   * zk = new ZooKeeper(connectStr, timeout, new Watcher() {
-   * @Override public void process(WatchedEvent event) { // Do nothing.(Dummy
-   * Watcher) } }); // Creating dummy bspRoot if it doesn't already exist. Stat
-   * s = zk.exists(bspRoot, false); if (s == null) { zk.create(bspRoot, new
-   * byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } // Creating dummy
-   * child nodes at depth 1. String node1 = bspRoot + "/task1"; String node2 =
-   * bspRoot + "/task2"; zk.create(node1, new byte[0], Ids.OPEN_ACL_UNSAFE,
-   * CreateMode.PERSISTENT); zk.create(node2, new byte[0], Ids.OPEN_ACL_UNSAFE,
-   * CreateMode.PERSISTENT); // Creating dummy child node at depth 2. String
-   * node11 = node1 + "/superstep1"; zk.create(node11, new byte[0],
-   * Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); ArrayList<String> list =
-   * (ArrayList<String>) zk.getChildren(bspRoot, false); assertEquals(2,
-   * list.size()); System.out.println(list.size());
-   * bspCluster.getBSPMaster().clearZKNodes(); list = (ArrayList<String>)
-   * zk.getChildren(bspRoot, false); System.out.println(list.size());
-   * assertEquals(0, list.size()); try { zk.getData(node11, false, null);
-   * fail(); } catch (KeeperException.NoNodeException e) {
-   * System.out.println("Node has been removed correctly!"); } }
-   */
-
-  /*
-   * END: ZooKeeper tests.
+   * BEGIN: ZooKeeper tests.
    */
-
+  public void testClearZKNodes() throws IOException, KeeperException,
+      InterruptedException {
+    // Clear any existing znode with the same path as bspRoot.
+    bspCluster.getBSPMaster().clearZKNodes();
+    int timeout = configuration.getInt(Constants.ZOOKEEPER_SESSION_TIMEOUT,
+        6000);
+    String connectStr = QuorumPeer.getZKQuorumServersString(configuration);
+    String bspRoot = configuration.get(Constants.ZOOKEEPER_ROOT,
+        Constants.DEFAULT_ZOOKEEPER_ROOT); // Establishing a zk session.
+    ZooKeeper zk = new ZooKeeper(connectStr, timeout, null);
+    // Creating dummy bspRoot if it doesn't already exist.
+
+    Stat s = zk.exists(bspRoot, false);
+    if (s == null) {
+      zk.create(bspRoot, new byte[0], Ids.OPEN_ACL_UNSAFE,
+          CreateMode.PERSISTENT);
+    }
+    // Creating dummy child nodes at depth 1.
+    String node1 = bspRoot + "/task1";
+    String node2 = bspRoot + "/task2";
+    zk.create(node1, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+    zk.create(node2, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+    // Creating dummy child node at depth 2.
+    String node11 = node1 + "/superstep1";
+    zk.create(node11, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+    ArrayList<String> list = (ArrayList<String>) zk.getChildren(bspRoot, false);
+    assertEquals(2, list.size());
+    System.out.println(list.size());
+    bspCluster.getBSPMaster().clearZKNodes();
+    list = (ArrayList<String>) zk.getChildren(bspRoot, false);
+    System.out.println(list.size());
+    assertEquals(0, list.size());
+    try {
+      zk.getData(node11, false, null);
+      fail();
+    } catch (KeeperException.NoNodeException e) {
+      System.out.println("Node has been removed correctly!");
+    }
+  }
 }



Mime
View raw message