Search in sources :

Example 6 with FetchedInputAllocator

use of org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator in project tez by apache.

the class TestShuffleInputEventHandlerImpl method createShuffleManager.

private ShuffleManager createShuffleManager(InputContext inputContext) throws IOException {
    Path outDirBase = new Path(".", "outDir");
    String[] outDirs = new String[] { outDirBase.toString() };
    doReturn(outDirs).when(inputContext).getWorkDirs();
    conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS, inputContext.getWorkDirs());
    DataOutputBuffer out = new DataOutputBuffer();
    Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(new JobTokenIdentifier(), new JobTokenSecretManager(null));
    token.write(out);
    doReturn(ByteBuffer.wrap(out.getData())).when(inputContext).getServiceConsumerMetaData(conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT));
    FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
    ShuffleManager realShuffleManager = new ShuffleManager(inputContext, conf, 2, 1024, false, -1, null, inputAllocator);
    ShuffleManager shuffleManager = spy(realShuffleManager);
    return shuffleManager;
}
Also used : Path(org.apache.hadoop.fs.Path) FetchedInputAllocator(org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator) JobTokenSecretManager(org.apache.tez.common.security.JobTokenSecretManager) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) JobTokenIdentifier(org.apache.tez.common.security.JobTokenIdentifier) Token(org.apache.hadoop.security.token.Token) Matchers.anyString(org.mockito.Matchers.anyString) ByteString(com.google.protobuf.ByteString)

Example 7 with FetchedInputAllocator

use of org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator in project tez by apache.

the class TestShuffleInputEventHandlerImpl method testMultipleEvents1.

@Test(timeout = 5000)
public void testMultipleEvents1() throws IOException {
    InputContext inputContext = mock(InputContext.class);
    ShuffleManager shuffleManager = mock(ShuffleManager.class);
    FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
    ShuffleInputEventHandlerImpl handler = new ShuffleInputEventHandlerImpl(inputContext, shuffleManager, inputAllocator, null, false, 0, false);
    int taskIndex1 = 1;
    Event dme1 = createDataMovementEvent(0, taskIndex1, createEmptyPartitionByteString(0));
    int taskIndex2 = 2;
    Event dme2 = createDataMovementEvent(0, taskIndex2, null);
    List<Event> eventList = new LinkedList<Event>();
    eventList.add(dme1);
    eventList.add(dme2);
    handler.handleEvents(eventList);
    InputAttemptIdentifier expectedIdentifier1 = new InputAttemptIdentifier(taskIndex1, 0);
    CompositeInputAttemptIdentifier expectedIdentifier2 = new CompositeInputAttemptIdentifier(taskIndex2, 0, PATH_COMPONENT, 1);
    verify(shuffleManager).addCompletedInputWithNoData(eq(expectedIdentifier1));
    verify(shuffleManager).addKnownInput(eq(HOST), eq(PORT), eq(expectedIdentifier2), eq(0));
}
Also used : FetchedInputAllocator(org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator) CompositeInputAttemptIdentifier(org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier) InputContext(org.apache.tez.runtime.api.InputContext) Event(org.apache.tez.runtime.api.Event) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) CompositeInputAttemptIdentifier(org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier) InputAttemptIdentifier(org.apache.tez.runtime.library.common.InputAttemptIdentifier) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 8 with FetchedInputAllocator

use of org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator in project tez by apache.

the class TestShuffleInputEventHandlerImpl method testOtherPartitionEmpty.

@Test(timeout = 5000)
public void testOtherPartitionEmpty() throws IOException {
    InputContext inputContext = mock(InputContext.class);
    ShuffleManager shuffleManager = mock(ShuffleManager.class);
    FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
    ShuffleInputEventHandlerImpl handler = new ShuffleInputEventHandlerImpl(inputContext, shuffleManager, inputAllocator, null, false, 0, false);
    int taskIndex = 1;
    Event dme = createDataMovementEvent(0, taskIndex, createEmptyPartitionByteString(1));
    List<Event> eventList = new LinkedList<Event>();
    eventList.add(dme);
    handler.handleEvents(eventList);
    CompositeInputAttemptIdentifier expectedIdentifier = new CompositeInputAttemptIdentifier(taskIndex, 0, PATH_COMPONENT, 1);
    verify(shuffleManager).addKnownInput(eq(HOST), eq(PORT), eq(expectedIdentifier), eq(0));
}
Also used : FetchedInputAllocator(org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator) CompositeInputAttemptIdentifier(org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier) InputContext(org.apache.tez.runtime.api.InputContext) Event(org.apache.tez.runtime.api.Event) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with FetchedInputAllocator

use of org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator in project tez by apache.

the class TestShuffleManager method testMultiplePartitions.

/**
 * One reducer fetches multiple partitions from each mapper.
 * For a given mapper, the reducer sends DataMovementEvents for several
 * partitions, wait for some time and then send DataMovementEvents for the
 * rest of the partitions. Then do the same thing for the next mapper.
 * Verify ShuffleManager is able to get all the events.
 */
@Test(timeout = 50000)
public void testMultiplePartitions() throws Exception {
    final int numOfMappers = 3;
    final int numOfPartitions = 5;
    final int firstPart = 2;
    InputContext inputContext = createInputContext();
    ShuffleManagerForTest shuffleManager = createShuffleManager(inputContext, numOfMappers * numOfPartitions);
    FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
    ShuffleInputEventHandlerImpl handler = new ShuffleInputEventHandlerImpl(inputContext, shuffleManager, inputAllocator, null, false, 0, false);
    shuffleManager.run();
    List<Event> eventList = new LinkedList<Event>();
    // The physical input index within the reduce task
    int targetIndex = 0;
    for (int i = 0; i < numOfMappers; i++) {
        String mapperHost = "host" + i;
        // The physical output index within the map task
        int srcIndex = 20;
        // Send the first batch of DataMovementEvents
        eventList.clear();
        for (int j = 0; j < firstPart; j++) {
            Event dme = createDataMovementEvent(mapperHost, srcIndex++, targetIndex++);
            eventList.add(dme);
        }
        handler.handleEvents(eventList);
        Thread.sleep(500);
        // Send the second batch of DataMovementEvents
        eventList.clear();
        for (int j = 0; j < numOfPartitions - firstPart; j++) {
            Event dme = createDataMovementEvent(mapperHost, srcIndex++, targetIndex++);
            eventList.add(dme);
        }
        handler.handleEvents(eventList);
    }
    int waitCount = 100;
    while (waitCount-- > 0 && !(shuffleManager.isFetcherExecutorShutdown() && numOfMappers * numOfPartitions == shuffleManager.getNumOfCompletedInputs())) {
        Thread.sleep(100);
    }
    assertTrue(shuffleManager.isFetcherExecutorShutdown());
    assertEquals(numOfMappers * numOfPartitions, shuffleManager.getNumOfCompletedInputs());
}
Also used : FetchedInputAllocator(org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator) InputContext(org.apache.tez.runtime.api.InputContext) Event(org.apache.tez.runtime.api.Event) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) Matchers.anyString(org.mockito.Matchers.anyString) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 10 with FetchedInputAllocator

use of org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator in project tez by apache.

the class TestShuffleInputEventHandlerImpl method testCurrentPartitionEmpty.

@Test(timeout = 5000)
public void testCurrentPartitionEmpty() throws IOException {
    InputContext inputContext = mock(InputContext.class);
    ShuffleManager shuffleManager = mock(ShuffleManager.class);
    FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
    ShuffleInputEventHandlerImpl handler = new ShuffleInputEventHandlerImpl(inputContext, shuffleManager, inputAllocator, null, false, 0, false);
    int taskIndex = 1;
    Event dme = createDataMovementEvent(0, taskIndex, createEmptyPartitionByteString(0));
    List<Event> eventList = new LinkedList<Event>();
    eventList.add(dme);
    handler.handleEvents(eventList);
    InputAttemptIdentifier expectedIdentifier = new InputAttemptIdentifier(taskIndex, 0);
    verify(shuffleManager).addCompletedInputWithNoData(eq(expectedIdentifier));
}
Also used : FetchedInputAllocator(org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator) InputContext(org.apache.tez.runtime.api.InputContext) Event(org.apache.tez.runtime.api.Event) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) CompositeInputAttemptIdentifier(org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier) InputAttemptIdentifier(org.apache.tez.runtime.library.common.InputAttemptIdentifier) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

FetchedInputAllocator (org.apache.tez.runtime.library.common.shuffle.FetchedInputAllocator)10 Event (org.apache.tez.runtime.api.Event)8 InputContext (org.apache.tez.runtime.api.InputContext)8 DataMovementEvent (org.apache.tez.runtime.api.events.DataMovementEvent)8 Test (org.junit.Test)8 CompositeInputAttemptIdentifier (org.apache.tez.runtime.library.common.CompositeInputAttemptIdentifier)7 LinkedList (java.util.LinkedList)5 BitSet (java.util.BitSet)3 InputAttemptIdentifier (org.apache.tez.runtime.library.common.InputAttemptIdentifier)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Path (org.apache.hadoop.fs.Path)2 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)2 Token (org.apache.hadoop.security.token.Token)2 JobTokenIdentifier (org.apache.tez.common.security.JobTokenIdentifier)2 JobTokenSecretManager (org.apache.tez.common.security.JobTokenSecretManager)2 ByteString (com.google.protobuf.ByteString)1