public static LockServiceProtos.LockedResource
    convertToProtoLockedResource(LockedResource lockedResource) throws IOException {
    LockServiceProtos.LockedResource.Builder builder =
      LockServiceProtos.LockedResource.newBuilder();

    builder.setResourceType(convertToProtoResourceType(lockedResource.getResourceType()))
      .setResourceName(lockedResource.getResourceName())
      .setLockType(convertToProtoLockType(lockedResource.getLockType()));

    Procedure<?> exclusiveLockOwnerProcedure = lockedResource.getExclusiveLockOwnerProcedure();

    if (exclusiveLockOwnerProcedure != null) {
      ProcedureProtos.Procedure exclusiveLockOwnerProcedureProto =
        convertToProtoProcedure(exclusiveLockOwnerProcedure);
      builder.setExclusiveLockOwnerProcedure(exclusiveLockOwnerProcedureProto);
    }

    builder.setSharedLockCount(lockedResource.getSharedLockCount());

    for (Procedure<?> waitingProcedure : lockedResource.getWaitingProcedures()) {
      ProcedureProtos.Procedure waitingProcedureProto = convertToProtoProcedure(waitingProcedure);
      builder.addWaitingProcedures(waitingProcedureProto);
    }

    return builder.build();
  }
Helper to convert the protobuf procedure.
<p/>
Used by ProcedureStore implementations.
<p/>
TODO: OPTIMIZATION: some of the field never change during the execution (e.g. className,
procId, parentId, ...). We can split in 'data' and 'state', and the store may take advantage of
it by storing the data only on insert().
hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureUtil.java