Index: conf/hama-env.sh =================================================================== --- conf/hama-env.sh (리비전 958436) +++ conf/hama-env.sh (작업 사본) @@ -22,7 +22,7 @@ # Set environment variables here. # The java implementation to use. Required. -export JAVA_HOME=/usr/lib/jvm/java-6-sun +# export JAVA_HOME=/usr/java/jdk1.6.0_20 # hadoop conf dir. to find the mapreduce cluster. # export HADOOP_CONF_DIR=/usr/local/src/hadoop-0.20.1/conf @@ -43,4 +43,4 @@ # export HAMA_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HAMA_CONF_DIR" # Tell Hama whether it should manage it's own instance of Zookeeper or not. -# export HAMA_MANAGES_ZK=true \ No newline at end of file +# export HAMA_MANAGES_ZK=true Index: src/examples/org/apache/hama/examples/PiEstimator.java =================================================================== --- src/examples/org/apache/hama/examples/PiEstimator.java (리비전 958436) +++ src/examples/org/apache/hama/examples/PiEstimator.java (작업 사본) @@ -66,7 +66,7 @@ } if (pi != 0.0) - System.out.println("Estimated value of PI is " + pi); + System.out.println("\nEstimated value of PI is " + pi); } Index: src/java/org/apache/hama/Constants.java =================================================================== --- src/java/org/apache/hama/Constants.java (리비전 958436) +++ src/java/org/apache/hama/Constants.java (작업 사본) @@ -41,6 +41,9 @@ public static final long ATLEAST_WAIT_TIME = 100; + /////////////////////////////////////// + // Constants for ZooKeeper + /////////////////////////////////////// /** zookeeper root */ public static final String ZOOKEEPER_ROOT = "bsp.zookeeper.root"; /** zookeeper default root */ @@ -58,10 +61,7 @@ public static final String ZOOKEEPER_PAUSE = "zookeeper.pause"; /** Default ZooKeeper pause value. In milliseconds. */ public static final int DEFAULT_ZOOKEEPER_PAUSE = 2 * 1000; - - /////////////////////////////////////// - // Constants for ZooKeeper - /////////////////////////////////////// + static final String ZOOKEEPER_CONFIG_NAME = "zoo.cfg"; static final int DEFAULT_ZOOKEPER_CLIENT_PORT = 21810; static final String ZOOKEEPER_QUORUM = "hama.zookeeper.quorum"; Index: src/java/org/apache/hama/bsp/LocalJobRunner.java =================================================================== --- src/java/org/apache/hama/bsp/LocalJobRunner.java (리비전 958436) +++ src/java/org/apache/hama/bsp/LocalJobRunner.java (작업 사본) @@ -30,7 +30,6 @@ private HashMap jobs = new HashMap(); public LocalJobRunner(Configuration conf) throws IOException { - // TODO Auto-generated constructor stub this.fs = FileSystem.get(conf); this.conf = conf; } @@ -49,7 +48,6 @@ @Override public String getFilesystemName() throws IOException { - // TODO Auto-generated method stub return fs.getUri().toString(); } @@ -72,15 +70,13 @@ @Override public String getSystemDir() { - // TODO Auto-generated method stub Path sysDir = new Path(conf.get("bsp.system.dir", "/tmp/hadoop/bsp/system")); return fs.makeQualified(sysDir).toString(); } @Override public void killJob(BSPJobID jobid) throws IOException { - // TODO Auto-generated method stub - + jobs.get(jobid).done(); } @Override @@ -116,12 +112,13 @@ /** * Local Job */ - private class Job implements Watcher { + private class Job extends Thread implements Watcher { private JobStatus status = new JobStatus(); private Configuration conf; private int NUM_PEER; private BSPJob job; private List list; + private boolean threadDone = false; public Job(BSPJobID jobID, String jobFile, Configuration conf) throws IOException { @@ -133,7 +130,8 @@ LOG.info("Number of BSP tasks: " + NUM_PEER); jobs.put(jobID.toString(), this); - ZooKeeper zk = new ZooKeeper("localhost:21810", 3000, this); + ZooKeeper zk = new ZooKeeper(Constants.DEFAULT_ZOOKEEPER_SERVER_ADDR, + 3000, this); Stat s = null; if (zk != null) { try { @@ -153,39 +151,41 @@ } } } + this.start(); + } - list = new ArrayList(); - for (int i = 0; i < NUM_PEER; i++) { - this.conf.setInt("bsp.peers.num", NUM_PEER); - this.conf.set(Constants.PEER_HOST, "localhost"); - this.conf.set(Constants.PEER_PORT, String.valueOf(30000 + i)); - this.conf.set(Constants.ZOOKEEPER_SERVER_ADDRS, "localhost:21810"); - this.conf.setInt("NUM_PEER", NUM_PEER); - BSPRunner runner = (BSPRunner) ReflectionUtils.newInstance( - BSPRunner.class, this.conf); + public void run() { + while (!threadDone) { + list = new ArrayList(); + for (int i = 0; i < NUM_PEER; i++) { + this.conf.set(Constants.PEER_PORT, String.valueOf(30000 + i)); + BSPRunner runner = (BSPRunner) ReflectionUtils.newInstance( + BSPRunner.class, this.conf); + list.add(runner); + } - list.add(runner); - } + for (int i = 0; i < NUM_PEER; i++) { + list.get(i).start(); + } - for (int i = 0; i < NUM_PEER; i++) { - list.get(i).start(); - } - - for (int i = 0; i < NUM_PEER; i++) { - try { - list.get(i).join(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + for (int i = 0; i < NUM_PEER; i++) { + try { + list.get(i).join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } } + done(); } + } + public void done() { + threadDone = true; } @Override public void process(WatchedEvent event) { // TODO Auto-generated method stub - } } }