Class GuaguaMapper<MASTER_RESULT extends ml.shifu.guagua.io.Bytable,WORKER_RESULT extends ml.shifu.guagua.io.Bytable>
- java.lang.Object
-
- org.apache.hadoop.mapreduce.Mapper<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text>
-
- ml.shifu.guagua.mapreduce.GuaguaMapper<MASTER_RESULT,WORKER_RESULT>
-
public class GuaguaMapper<MASTER_RESULT extends ml.shifu.guagua.io.Bytable,WORKER_RESULT extends ml.shifu.guagua.io.Bytable> extends org.apache.hadoop.mapreduce.Mapper<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text>GuaguaMapperis the Hadoop Mapper implementation for both guagua master and guagua workers.Use
(GuaguaInputSplit) context.getInputSplit()to check whether this task is guagua master or guagua worker.guaguaServiceis the interface for both guagua Master and Worker implementation. According toisMaster, master service and worker service will be determined.Only mapper, no reducer for guagua MapReduce implementation. And in this mapper
run(org.apache.hadoop.mapreduce.Mapper.Context)is override whileMapper.map(Object, Object, org.apache.hadoop.mapreduce.Mapper.Context)is not since we don't need to iterate mapper raw input.
-
-
Constructor Summary
Constructors Constructor Description GuaguaMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanup(org.apache.hadoop.mapreduce.Mapper.Context context)ml.shifu.guagua.GuaguaServicegetGuaguaService()booleanisMaster()voidrun(org.apache.hadoop.mapreduce.Mapper.Context context)Run guagua service accordingisMastersetting.voidsetGuaguaService(ml.shifu.guagua.GuaguaService guaguaService)voidsetMaster(boolean isMaster)protected voidsetup(org.apache.hadoop.mapreduce.Mapper.Context context)
-
-
-
Method Detail
-
setup
protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException- Overrides:
setupin classorg.apache.hadoop.mapreduce.Mapper<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text>- Throws:
IOExceptionInterruptedException
-
run
public void run(org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedExceptionRun guagua service accordingisMastersetting. Iteration, coordination will be included in service running.cleanup(org.apache.hadoop.mapreduce.Mapper.Context)is called in finally block to make sure resources can be cleaned.Guagua try best to update progress for each iteration. And also task status will be updated in each iteration in hadoop job web ui.
- Overrides:
runin classorg.apache.hadoop.mapreduce.Mapper<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text>- Throws:
IOExceptionInterruptedException
-
cleanup
protected void cleanup(org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException- Overrides:
cleanupin classorg.apache.hadoop.mapreduce.Mapper<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,org.apache.hadoop.io.Text>- Throws:
IOExceptionInterruptedException
-
isMaster
public boolean isMaster()
-
setMaster
public void setMaster(boolean isMaster)
-
getGuaguaService
public ml.shifu.guagua.GuaguaService getGuaguaService()
-
setGuaguaService
public void setGuaguaService(ml.shifu.guagua.GuaguaService guaguaService)
-
-