Search in sources :

Example 1 with VertexManagerPluginContext

use of org.apache.tez.dag.api.VertexManagerPluginContext in project hive by apache.

the class TestCustomPartitionVertex method testGetBytePayload.

@Test(timeout = 5000)
public void testGetBytePayload() throws IOException {
    int numBuckets = 10;
    VertexManagerPluginContext context = mock(VertexManagerPluginContext.class);
    CustomVertexConfiguration vertexConf = new CustomVertexConfiguration(numBuckets, TezWork.VertexType.INITIALIZED_EDGES);
    DataOutputBuffer dob = new DataOutputBuffer();
    vertexConf.write(dob);
    UserPayload payload = UserPayload.create(ByteBuffer.wrap(dob.getData()));
    when(context.getUserPayload()).thenReturn(payload);
    CustomPartitionVertex vm = new CustomPartitionVertex(context);
    vm.initialize();
    // prepare empty routing table
    Multimap<Integer, Integer> routingTable = HashMultimap.<Integer, Integer>create();
    payload = vm.getBytePayload(routingTable);
    // get conf from user payload
    CustomEdgeConfiguration edgeConf = new CustomEdgeConfiguration();
    DataInputByteBuffer dibb = new DataInputByteBuffer();
    dibb.reset(payload.getPayload());
    edgeConf.readFields(dibb);
    assertEquals(numBuckets, edgeConf.getNumBuckets());
}
Also used : VertexManagerPluginContext(org.apache.tez.dag.api.VertexManagerPluginContext) UserPayload(org.apache.tez.dag.api.UserPayload) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) Test(org.junit.Test)

Aggregations

DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)1 UserPayload (org.apache.tez.dag.api.UserPayload)1 VertexManagerPluginContext (org.apache.tez.dag.api.VertexManagerPluginContext)1 Test (org.junit.Test)1