hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r933117 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/bsp/BSPConstants.java src/java/org/apache/hama/bsp/BSPPeer.java src/test/org/apache/hama/bsp/BSPPeerTest.java
Date Mon, 12 Apr 2010 07:02:30 GMT
Author: edwardyoon
Date: Mon Apr 12 07:02:30 2010
New Revision: 933117

URL: http://svn.apache.org/viewvc?rev=933117&view=rev
Log:
Wrong assignment of default setting inside BSPPeer constructor

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPConstants.java
    incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPPeer.java
    incubator/hama/trunk/src/test/org/apache/hama/bsp/BSPPeerTest.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=933117&r1=933116&r2=933117&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Mon Apr 12 07:02:30 2010
@@ -137,6 +137,8 @@ Trunk (unreleased changes)
 
   BUG FIXES
  
+    HAMA-250: Add --no-check-certificate option to 'wget' command lines (edwardyoon)
+    HAMA-242: Wrong assignment of default setting inside BSPPeer constructor (hyunsik)
     HAMA-246: Current shell scripts for bsp daemon have several problems. (hyunsik)
     HAMA-238: Example fail when performing sparse matrices addition (edwardyoon)
     HAMA-225: Jacobi iteration is in a infinite loop (edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPConstants.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPConstants.java?rev=933117&r1=933116&r2=933117&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPConstants.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPConstants.java Mon Apr 12 07:02:30
2010
@@ -40,6 +40,8 @@ public interface BSPConstants {
 
   /** zookeeper server address */
   static final String ZOOKEEPER_SERVER_ADDRS = "zookeeper.server";
+  /** zookeeper default server address */
+  static final String DEFAULT_ZOOKEEPER_SERVER_ADDR = "localhost:21810";
   /** Parameter name for number of times to retry writes to ZooKeeper. */
   static final String ZOOKEEPER_RETRIES = "zookeeper.retries";
   /** Default number of times to retry writes to ZooKeeper. */

Modified: incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPPeer.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPPeer.java?rev=933117&r1=933116&r2=933117&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPPeer.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPPeer.java Mon Apr 12 07:02:30 2010
@@ -54,6 +54,7 @@ public class BSPPeer implements DefaultB
   protected final String bindAddress;
   protected final int bindPort;
   protected final String bspRoot;
+  protected final String zookeeperAddr;
 
   protected final Map<InetSocketAddress, BSPPeerInterface> peers = new ConcurrentHashMap<InetSocketAddress,
BSPPeerInterface>();
   protected final Map<InetSocketAddress, ConcurrentLinkedQueue<BSPMessage>> outgoingQueues
= new ConcurrentHashMap<InetSocketAddress, ConcurrentLinkedQueue<BSPMessage>>();
@@ -65,26 +66,28 @@ public class BSPPeer implements DefaultB
   public BSPPeer(Configuration conf) throws IOException {
     this.conf = conf;
 
-    serverName = conf.get(PEER_HOST) + conf.get(PEER_PORT, DEFAULT_PEER_HOST);
+    serverName = conf.get(PEER_HOST,DEFAULT_PEER_HOST) +":"+ conf.getInt(PEER_PORT, DEFAULT_PEER_PORT);
     bindAddress = conf.get(PEER_HOST, DEFAULT_PEER_HOST);
-    bindPort = Integer.valueOf(conf.get(PEER_PORT, DEFAULT_PEER_HOST));
+    bindPort = conf.getInt(PEER_PORT, DEFAULT_PEER_PORT);    
     bspRoot = conf.get(ZOOKEEPER_ROOT, DEFAULT_ZOOKEEPER_ROOT);
+    zookeeperAddr = conf.get(ZOOKEEPER_SERVER_ADDRS,"localhost:21810");
 
     reinitialize();
   }
 
   public void reinitialize() {
     try {
+      System.out.println(bindAddress+":"+bindPort);
       server = RPC.getServer(this, bindAddress, bindPort, conf);
-      server.start();
-    } catch (IOException e1) {
-      e1.printStackTrace();
+      server.start();      
+    } catch (IOException e) {
+      e.printStackTrace();
     }
 
     try {
-      zk = new ZooKeeper(conf.get(ZOOKEEPER_SERVER_ADDRS), 3000, this);
-    } catch (IOException e1) {
-      e1.printStackTrace();
+      zk = new ZooKeeper(zookeeperAddr, 3000, this);
+    } catch (IOException e) {
+      e.printStackTrace();
     }
   }
 
@@ -136,6 +139,7 @@ public class BSPPeer implements DefaultB
       queue = entry.getValue();
       messages = queue.iterator();
 
+      // TODO - to be improved by collective communication and compression
       while (messages.hasNext()) {
         peer.put(messages.next());
       }

Modified: incubator/hama/trunk/src/test/org/apache/hama/bsp/BSPPeerTest.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/bsp/BSPPeerTest.java?rev=933117&r1=933116&r2=933117&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/bsp/BSPPeerTest.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/bsp/BSPPeerTest.java Mon Apr 12 07:02:30
2010
@@ -43,16 +43,17 @@ public class BSPPeerTest extends HamaClu
   private Log LOG = LogFactory.getLog(BSPPeerTest.class);
 
   private static final int NUM_PEER = 35;
-  private static final int ROUND = 10;
+  private static final int ROUND = 3;
   private static final int PAYLOAD = 1024; // 1kb in default
   List<BSPPeerThread> list = new ArrayList<BSPPeerThread>(NUM_PEER);
   Configuration conf;
+  private Random r = new Random();
 
   public BSPPeerTest() {
     this.conf = getConf();
   }
 
-  public void setUp() throws Exception {
+  public void setUp() throws Exception {    
     super.setUp();
 
     ZooKeeper zk = new ZooKeeper("localhost:21810", 3000, this);
@@ -79,8 +80,7 @@ public class BSPPeerTest extends HamaClu
 
   public class BSPPeerThread extends Thread {
     private BSPPeer peer;
-    private int MAXIMUM_DURATION = 5;
-    private Random r = new Random();
+    private int MAXIMUM_DURATION = 5;    
 
     public BSPPeerThread(Configuration conf) throws IOException {
       this.peer = new BSPPeer(conf);
@@ -144,6 +144,10 @@ public class BSPPeerTest extends HamaClu
 
       peer.localQueue.clear();
     }
+    
+    public BSPPeer getBSPPeer() {
+      return this.peer;
+    }
   }
 
   public void testSync() throws InterruptedException, IOException {
@@ -166,6 +170,38 @@ public class BSPPeerTest extends HamaClu
       list.get(i).join();
     }
   }
+  
+  /*
+   * Test method for constructors
+   */
+  public void testBSPPeer() throws IOException {
+    Configuration conf = new Configuration();    
+    BSPPeer peer = new BSPPeer(conf);
+    
+    System.out.println(peer.bindAddress+" = "+BSPConstants.DEFAULT_PEER_HOST);
+    System.out.println(peer.bindPort+" = "+BSPConstants.DEFAULT_PEER_PORT);
+    assertEquals(peer.bindAddress,BSPConstants.DEFAULT_PEER_HOST);
+    assertEquals(peer.bindPort,BSPConstants.DEFAULT_PEER_PORT);
+    assertEquals(peer.zookeeperAddr,BSPConstants.DEFAULT_ZOOKEEPER_SERVER_ADDR);
+    
+    int peerPort;
+    int zkPort;
+    conf = new Configuration();
+    conf.set(BSPConstants.PEER_HOST, "localhost");
+    do{      
+      peerPort = r.nextInt(Short.MAX_VALUE);
+    } while(peerPort == 0);    
+    conf.setInt(BSPConstants.PEER_PORT, peerPort);
+    
+    do{      
+      zkPort = r.nextInt(Short.MAX_VALUE);
+    } while(zkPort == peerPort || zkPort == 0);    
+    conf.set(BSPConstants.ZOOKEEPER_SERVER_ADDRS, "localhost:"+zkPort);
+    peer = new BSPPeer(conf);
+    assertEquals(peer.bindAddress,"localhost");
+    assertEquals(peer.bindPort,peerPort);
+    assertEquals(peer.zookeeperAddr,"localhost:"+zkPort);
+  }
 
   @Override
   public void process(WatchedEvent event) {



Mime
View raw message