@Override
  public alluxio.grpc.JobInfo toProto() {
    ByteBuffer result = null;
    try {
      result = mResult == null ? null : ByteBuffer.wrap(SerializationUtils.serialize(mResult));
    } catch (IOException e) {
      // TODO(bradley) better error handling
      LOG.error("Failed to serialize {}", mResult, e);
    }

    alluxio.grpc.JobInfo.Builder taskInfoBuilder =
        alluxio.grpc.JobInfo.newBuilder().setParentId(mJobId).setId(mTaskId)
            .setStatus(mStatus.toProto()).setErrorMessage(mErrorMessage)
            .setErrorType(mErrorType).setLastUpdated(mLastUpdated).setWorkerHost(mWorkerHost)
            .setType(JobType.TASK).setDescription(mDescription);
    if (result != null) {
      taskInfoBuilder.setResult(ByteString.copyFrom(result));
    }
    return taskInfoBuilder.build();
  }
@Test
  public void testToProto() throws IOException {
    TaskInfo taskInfo = createRandom();

    assertEquals(taskInfo, new TaskInfo(taskInfo.toProto()));
  }