Search in sources :

Example 21 with InputDataInformationEvent

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"));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) SequenceFileInputFormat(org.apache.hadoop.mapred.SequenceFileInputFormat) InputContext(org.apache.tez.runtime.api.InputContext) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) IOException(java.io.IOException) AtomicLong(java.util.concurrent.atomic.AtomicLong) Event(org.apache.tez.runtime.api.Event) InputDataInformationEvent(org.apache.tez.runtime.api.events.InputDataInformationEvent) LongWritable(org.apache.hadoop.io.LongWritable) JobConf(org.apache.hadoop.mapred.JobConf) InputSplit(org.apache.hadoop.mapred.InputSplit) MRSplitProto(org.apache.tez.mapreduce.protos.MRRuntimeProtos.MRSplitProto) InputDataInformationEvent(org.apache.tez.runtime.api.events.InputDataInformationEvent) Test(org.junit.Test)

Example 22 with InputDataInformationEvent

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();
    }
}
Also used : Event(org.apache.tez.runtime.api.Event) InputDataInformationEvent(org.apache.tez.runtime.api.events.InputDataInformationEvent) MRReader(org.apache.tez.mapreduce.lib.MRReader)

Aggregations

InputDataInformationEvent (org.apache.tez.runtime.api.events.InputDataInformationEvent)22 Event (org.apache.tez.runtime.api.Event)16 MRSplitProto (org.apache.tez.mapreduce.protos.MRRuntimeProtos.MRSplitProto)10 Test (org.junit.Test)10 Configuration (org.apache.hadoop.conf.Configuration)8 InputSplit (org.apache.hadoop.mapred.InputSplit)7 JobConf (org.apache.hadoop.mapred.JobConf)5 InputContext (org.apache.tez.runtime.api.InputContext)5 InputConfigureVertexTasksEvent (org.apache.tez.runtime.api.events.InputConfigureVertexTasksEvent)5 LinkedList (java.util.LinkedList)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 Path (org.apache.hadoop.fs.Path)4 LongWritable (org.apache.hadoop.io.LongWritable)4 Text (org.apache.hadoop.io.Text)4 SequenceFileInputFormat (org.apache.hadoop.mapred.SequenceFileInputFormat)4 UserPayload (org.apache.tez.dag.api.UserPayload)4 MRInputUserPayloadProto (org.apache.tez.mapreduce.protos.MRRuntimeProtos.MRInputUserPayloadProto)4 MRSplitsProto (org.apache.tez.mapreduce.protos.MRRuntimeProtos.MRSplitsProto)4 ByteString (com.google.protobuf.ByteString)3 ArrayList (java.util.ArrayList)3