@Override public void initialize() { ByteBuffer payload = context.getUserPayload().getPayload(); LOG.info("Initializing the edge, payload: " + payload); if (payload == null) { throw new RuntimeException("Invalid payload"); } // De-serialization code DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); conf = new CustomEdgeConfiguration(); try { conf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } LOG.info("Routing table: " + conf.getRoutingTable() + " num Buckets: " + conf.getNumBuckets()); }
@Override public void initialize() { ByteBuffer payload = context.getUserPayload().getPayload(); LOG.info("Initializing the edge, payload: " + payload); if (payload == null) { throw new RuntimeException("Invalid payload"); } // De-serialization code DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); conf = new CustomEdgeConfiguration(); try { conf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } LOG.info("Routing table: " + conf.getRoutingTable() + " num Buckets: " + conf.getNumBuckets()); }
@Override public void initialize() { this.context = getContext(); ByteBuffer payload = context.getUserPayload().getPayload(); CustomVertexConfiguration vertexConf = new CustomVertexConfiguration(); DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); try { vertexConf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } this.numBuckets = vertexConf.getNumBuckets(); this.mainWorkName = vertexConf.getInputName(); this.vertexType = vertexConf.getVertexType(); this.numInputsAffectingRootInputSpecUpdate = vertexConf.getNumInputs(); }
@Override public void initialize() { this.context = getContext(); ByteBuffer payload = context.getUserPayload().getPayload(); CustomVertexConfiguration vertexConf = new CustomVertexConfiguration(); DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); try { vertexConf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } this.numBuckets = vertexConf.getNumBuckets(); this.mainWorkName = vertexConf.getInputName(); this.vertexType = vertexConf.getVertexType(); this.numInputsAffectingRootInputSpecUpdate = vertexConf.getNumInputs(); this.inputToBucketMap = vertexConf.getInputToBucketMap(); }
@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()); } }
@Override public void initialize() { ByteBuffer payload = context.getUserPayload().getPayload(); LOG.info("Initializing the edge, payload: " + payload); if (payload == null) { throw new RuntimeException("Invalid payload"); } // De-serialization code DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); conf = new CustomEdgeConfiguration(); try { conf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } LOG.info("Routing table: " + conf.getRoutingTable() + " num Buckets: " + conf.getNumBuckets()); }
@Override public void initialize() { this.context = getContext(); ByteBuffer payload = context.getUserPayload().getPayload(); CustomVertexConfiguration vertexConf = new CustomVertexConfiguration(); DataInputByteBuffer dibb = new DataInputByteBuffer(); dibb.reset(payload); try { vertexConf.readFields(dibb); } catch (IOException e) { throw new RuntimeException(e); } this.numBuckets = vertexConf.getNumBuckets(); this.mainWorkName = vertexConf.getInputName(); this.vertexType = vertexConf.getVertexType(); this.numInputsAffectingRootInputSpecUpdate = vertexConf.getNumInputs(); }