Search in sources :

Example 1 with SummaryEventProto

use of org.apache.tez.dag.recovery.records.RecoveryProtos.SummaryEventProto in project tez by apache.

the class TestHistoryEventsProtoConversion method testSummaryProtoConversion.

private HistoryEvent testSummaryProtoConversion(HistoryEvent historyEvent) throws IOException, TezException {
    SummaryEvent event = (SummaryEvent) historyEvent;
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    HistoryEvent deserializedEvent = null;
    event.toSummaryProtoStream(os);
    os.flush();
    os.close();
    LOG.info("Serialized event to byte array" + ", eventType=" + historyEvent.getEventType() + ", bufLen=" + os.toByteArray().length);
    SummaryEventProto summaryEventProto = SummaryEventProto.parseDelimitedFrom(new ByteArrayInputStream(os.toByteArray()));
    deserializedEvent = ReflectionUtils.createClazzInstance(event.getClass().getName());
    ((SummaryEvent) deserializedEvent).fromSummaryProtoStream(summaryEventProto);
    return deserializedEvent;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SummaryEvent(org.apache.tez.dag.history.SummaryEvent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HistoryEvent(org.apache.tez.dag.history.HistoryEvent) SummaryEventProto(org.apache.tez.dag.recovery.records.RecoveryProtos.SummaryEventProto)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HistoryEvent (org.apache.tez.dag.history.HistoryEvent)1 SummaryEvent (org.apache.tez.dag.history.SummaryEvent)1 SummaryEventProto (org.apache.tez.dag.recovery.records.RecoveryProtos.SummaryEventProto)1