|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2>
org.apache.hadoop.mrunit.PipelineMapReduceDriver<K1,V1,K2,V2>
public class PipelineMapReduceDriver<K1,V1,K2,V2>
Harness that allows you to test a dataflow through a set of Mappers and Reducers. You provide a set of (Mapper, Reducer) "jobs" that make up a workflow, as well as a set of (key, value) pairs to pass in to the first Mapper. You can also specify the outputs you expect to be sent to the final Reducer in the pipeline. By calling runTest(), the harness will deliver the input to the first Mapper, feed the intermediate results to the first Reducer (without checking them), and proceed to forward this data along to subsequent Mapper/Reducer jobs in the pipeline until the final Reducer. The last Reducer's outputs are checked against the expected results. This is designed for slightly more complicated integration tests than the MapReduceDriver, which is for smaller unit tests. (K1, V1) in the type signature refer to the types associated with the inputs to the first Mapper. (K2, V2) refer to the types associated with the final Reducer's output. No intermediate types are specified.
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
Fields inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
configuration, expectedOutputs |
Constructor Summary | |
---|---|
PipelineMapReduceDriver()
|
|
PipelineMapReduceDriver(List<Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer>> pipeline)
|
Method Summary | |
---|---|
void |
addInput(K1 key,
V1 val)
Adds an input to send to the mapper |
void |
addInput(Pair<K1,V1> input)
Adds an input to send to the Mapper |
void |
addInputFromString(String input)
Expects an input of the form "key \t val" Forces the Mapper input types to Text. |
void |
addMapReduce(org.apache.hadoop.mapred.Mapper m,
org.apache.hadoop.mapred.Reducer r)
Add a Mapper and Reducer instance to the pipeline to use with this test driver |
void |
addMapReduce(Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer> p)
Add a Mapper and Reducer instance to the pipeline to use with this test driver |
void |
addOutput(K2 key,
V2 val)
Adds a (k, v) pair we expect as output from the Reducer |
void |
addOutput(Pair<K2,V2> outputRecord)
Adds an output (k, v) pair we expect from the Reducer |
void |
addOutputFromString(String output)
Expects an input of the form "key \t val" Forces the Reducer output types to Text. |
org.apache.hadoop.mapred.Counters |
getCounters()
|
List<Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer>> |
getMapReducePipeline()
|
List<Pair<K2,V2>> |
run()
Runs the test but returns the result set instead of validating it (ignores any addOutput(), etc calls made before this) |
void |
runTest()
Runs the test and validates the results |
void |
setCounters(org.apache.hadoop.mapred.Counters ctrs)
Sets the counters object to use for this test. |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withCounters(org.apache.hadoop.mapred.Counters ctrs)
Sets the counters to use and returns self for fluent style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withInput(K1 key,
V1 val)
Identical to addInput() but returns self for fluent programming style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withInput(Pair<K1,V1> input)
Identical to addInput() but returns self for fluent programming style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withInputFromString(String input)
Identical to addInputFromString, but with a fluent programming style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withMapReduce(org.apache.hadoop.mapred.Mapper m,
org.apache.hadoop.mapred.Reducer r)
Add a Mapper and Reducer instance to the pipeline to use with this test driver using fluent style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withMapReduce(Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer> p)
Add a Mapper and Reducer instance to the pipeline to use with this test driver using fluent style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withOutput(K2 key,
V2 val)
Functions like addOutput() but returns self for fluent programming style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withOutput(Pair<K2,V2> outputRecord)
Works like addOutput(), but returns self for fluent style |
PipelineMapReduceDriver<K1,V1,K2,V2> |
withOutputFromString(String output)
Identical to addOutputFromString, but with a fluent programming style |
Methods inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
formatValueList, getConfiguration, getExpectedOutputs, parseCommaDelimitedList, parseTabbedPair, resetOutput, setConfiguration, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public PipelineMapReduceDriver(List<Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer>> pipeline)
public PipelineMapReduceDriver()
Method Detail |
---|
public org.apache.hadoop.mapred.Counters getCounters()
public void setCounters(org.apache.hadoop.mapred.Counters ctrs)
ctrs
- The counters object to use.public PipelineMapReduceDriver<K1,V1,K2,V2> withCounters(org.apache.hadoop.mapred.Counters ctrs)
public void addMapReduce(org.apache.hadoop.mapred.Mapper m, org.apache.hadoop.mapred.Reducer r)
m
- The Mapper instance to add to the pipeliner
- The Reducer instance to add to the pipelinepublic void addMapReduce(Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer> p)
p
- The Mapper and Reducer instances to add to the pipelinepublic PipelineMapReduceDriver<K1,V1,K2,V2> withMapReduce(org.apache.hadoop.mapred.Mapper m, org.apache.hadoop.mapred.Reducer r)
m
- The Mapper instance to user
- The Reducer instance to usepublic PipelineMapReduceDriver<K1,V1,K2,V2> withMapReduce(Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer> p)
p
- The Mapper and Reducer instances to add to the pipelinepublic List<Pair<org.apache.hadoop.mapred.Mapper,org.apache.hadoop.mapred.Reducer>> getMapReducePipeline()
public void addInput(K1 key, V1 val)
key
- val
- public PipelineMapReduceDriver<K1,V1,K2,V2> withInput(K1 key, V1 val)
key
- val
-
public void addInput(Pair<K1,V1> input)
input
- The (k, v) pair to add to the input list.public PipelineMapReduceDriver<K1,V1,K2,V2> withInput(Pair<K1,V1> input)
input
- The (k, v) pair to add
public void addOutput(Pair<K2,V2> outputRecord)
outputRecord
- The (k, v) pair to addpublic PipelineMapReduceDriver<K1,V1,K2,V2> withOutput(Pair<K2,V2> outputRecord)
outputRecord
-
public void addOutput(K2 key, V2 val)
key
- val
- public PipelineMapReduceDriver<K1,V1,K2,V2> withOutput(K2 key, V2 val)
key
- val
-
public void addInputFromString(String input)
input
- A string of the form "key \t val". Trims any whitespace.public PipelineMapReduceDriver<K1,V1,K2,V2> withInputFromString(String input)
input
- A string of the form "key \t val". Trims any whitespace.
public void addOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.public PipelineMapReduceDriver<K1,V1,K2,V2> withOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.
public List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class TestDriver<K1,V1,K2,V2>
IOException
public void runTest() throws RuntimeException
TestDriver
runTest
in class TestDriver<K1,V1,K2,V2>
RuntimeException
- if they don't
*
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |