Skip to content

Commit

Permalink
TEZ-3224. User payload is not initialized before creating vertex mana…
Browse files Browse the repository at this point in the history
…ger plugin. (Zhiyuan Yang via hitesh)
  • Loading branch information
hiteshs committed Apr 22, 2016
1 parent 8c59eb8 commit 014d7c4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release 0.8.4: Unreleased
INCOMPATIBLE CHANGES

ALL CHANGES:
TEZ-3224. User payload is not initialized before creating vertex manager plugin.
TEZ-3226. Tez UI 2: All DAGs UX improvements.
TEZ-3077. TezClient.waitTillReady should support timeout.
TEZ-3202. Reduce the memory need for jobs with high number of segments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ public VertexManager(VertexManagerPluginDescriptor pluginDesc, UserGroupInformat

pluginContext = new VertexManagerPluginContextImpl();
Preconditions.checkArgument(pluginDesc != null);
payload = pluginDesc.getUserPayload();
pluginFailed = new AtomicBoolean(false);
plugin = ReflectionUtils.createClazzInstance(pluginDesc.getClassName(),
new Class[] { VertexManagerPluginContext.class }, new Object[] { pluginContext });
payload = pluginDesc.getUserPayload();
execService = appContext.getExecService();
eventQueue = new LinkedBlockingQueue<VertexManagerEvent>();
eventInFlight = new AtomicBoolean(false);
pluginFailed = new AtomicBoolean(false);
}

public VertexManagerPlugin getPlugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.tez.dag.app.dag.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doReturn;
Expand All @@ -27,6 +28,8 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
Expand All @@ -38,6 +41,8 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.tez.dag.api.InputDescriptor;
import org.apache.tez.dag.api.TezException;
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.VertexManagerPlugin;
import org.apache.tez.dag.api.VertexManagerPluginContext;
import org.apache.tez.dag.api.VertexManagerPluginDescriptor;
Expand Down Expand Up @@ -95,6 +100,35 @@ public ListenableFuture<Void> answer(InvocationOnMock invocation) {
requestCaptor = ArgumentCaptor.forClass(VertexEventInputDataInformation.class);

}

public static class CheckUserPayloadVertexManagerPlugin extends VertexManagerPlugin {
public CheckUserPayloadVertexManagerPlugin(VertexManagerPluginContext context) {
super(context);
assertNotNull(context.getUserPayload());
}

@Override
public void initialize() throws Exception {}

@Override
public void onVertexManagerEventReceived(VertexManagerEvent vmEvent) throws Exception {}

@Override
public void onRootVertexInitialized(String inputName, InputDescriptor inputDescriptor,
List<Event> events) throws Exception {}
}

@Test(timeout = 5000)
public void testVertexManagerPluginCtorAccessUserPayload() throws IOException, TezException {
byte[] randomUserPayload = {1,2,3};
UserPayload userPayload = UserPayload.create(ByteBuffer.wrap(randomUserPayload));
VertexManager vm =
new VertexManager(
VertexManagerPluginDescriptor.create(CheckUserPayloadVertexManagerPlugin.class
.getName()).setUserPayload(userPayload), UserGroupInformation.getCurrentUser(),
mockVertex, mockAppContext, mock(StateChangeNotifier.class));
}


@Test(timeout = 5000)
public void testOnRootVertexInitialized() throws Exception {
Expand Down

0 comments on commit 014d7c4

Please sign in to comment.