Tested: hama-0.5.0
Compile:
mkdir ./class
javac -classpath "/usr/local/hadoop/hadoop-core-1.0.1.jar":"/usr/local/hadoop/lib/*":"./class":"/root/hama/hama-0.5.0/*":"/root/hama/hama-0.5.0/lib/*" -d class BSPSkeleton.java
- specify correct Path of hadoop and hama
Packaging:
jar -cvf skeleton.jar -C class/ .
run:
/root/hama/hama-0.5.0/bin/hama jar hama.jar BSPSkeleton
- specify correct Path of hama binary
Source Code:
import java.io.IOException;
import org.apache.hama.HamaConfiguration;
import org.apache.hama.bsp.BSP;
import org.apache.hama.bsp.BSPJob;
import org.apache.hama.bsp.BSPPeer;
import org.apache.hama.bsp.sync.SyncException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
public class BSPSkeleton
extends
BSP<NullWritable, NullWritable, NullWritable, NullWritable, IntWritable> {
private static final Log LOG = LogFactory.getLog(BSPSkeleton.class);
@Override
public void bsp(
BSPPeer<NullWritable, NullWritable, NullWritable, NullWritable, IntWritable> peer)
throws IOException, SyncException, InterruptedException {
LOG.info("Hello BSP world from " + peer.getPeerName());
}
public static void main(String[] args) throws IOException,
InterruptedException, ClassNotFoundException {
HamaConfiguration conf = new HamaConfiguration();
System.out.println("Start..");
BSPJob job = new BSPJob(conf);
// set the BSP class which shall be executed
job.setOutputPath(new Path("/tmp"));
job.setBspClass(BSPSkeleton.class);
// help Hama to locale the jar to be distributed
job.setJarByClass(BSPSkeleton.class);
// give it a name
job.setJobName("BSP Skeleton");
job.setNumBspTask(14);
job.waitForCompletion(true);
}
}