use of org.apache.tez.runtime.api.events.InputDataInformationEvent in project tez by apache.
the class TestMultiMRInput method testExtraEvents.
@Test(timeout = 5000)
public void testExtraEvents() throws Exception {
Path workDir = new Path(TEST_ROOT_DIR, "testExtraEvents");
JobConf jobConf = new JobConf(defaultConf);
jobConf.setInputFormat(org.apache.hadoop.mapred.SequenceFileInputFormat.class);
FileInputFormat.setInputPaths(jobConf, workDir);
InputContext inputContext = createTezInputContext(jobConf);
MultiMRInput input = new MultiMRInput(inputContext, 1);
input.initialize();
createSplits(1, workDir, jobConf, new AtomicLong());
SequenceFileInputFormat<LongWritable, Text> format = new SequenceFileInputFormat<LongWritable, Text>();
InputSplit[] splits = format.getSplits(jobConf, 1);
assertEquals(1, splits.length);
MRSplitProto splitProto = MRInputHelpers.createSplitProto(splits[0]);
InputDataInformationEvent event1 = InputDataInformationEvent.createWithSerializedPayload(0, splitProto.toByteString().asReadOnlyByteBuffer());
InputDataInformationEvent event2 = InputDataInformationEvent.createWithSerializedPayload(1, splitProto.toByteString().asReadOnlyByteBuffer());
List<Event> eventList = new ArrayList<Event>();
eventList.add(event1);
eventList.add(event2);
try {
input.handleEvents(eventList);
fail("Expecting Exception due to too many events");
} catch (Exception e) {
assertTrue(e.getMessage().contains("Unexpected event. All physical sources already initialized"));
}
}
use of org.apache.tez.runtime.api.events.InputDataInformationEvent in project tez by apache.
the class MultiMRInput method handleEvents.
@Override
public void handleEvents(List<Event> inputEvents) throws Exception {
lock.lock();
try {
if (getNumPhysicalInputs() == 0) {
throw new IllegalStateException("Unexpected event. MultiMRInput has been setup to receive 0 events");
}
Preconditions.checkState(eventCount.get() + inputEvents.size() <= getNumPhysicalInputs(), "Unexpected event. All physical sources already initialized");
for (Event event : inputEvents) {
MRReader reader = initFromEvent((InputDataInformationEvent) event);
readers.add(reader);
if (eventCount.incrementAndGet() == getNumPhysicalInputs()) {
getContext().inputIsReady();
condition.signal();
}
}
} finally {
lock.unlock();
}
}
Aggregations