| 45 | // have not changed across versions. |
| 46 | template <typename T> |
| 47 | static T evolve(const google::protobuf::Message& message) |
| 48 | { |
| 49 | T t; |
| 50 | |
| 51 | string data; |
| 52 | |
| 53 | // NOTE: We need to use 'SerializePartialToString' instead of |
| 54 | // 'SerializeToString' because some required fields might not be set |
| 55 | // and we don't want an exception to get thrown. |
| 56 | CHECK(message.SerializePartialToString(&data)) |
| 57 | << "Failed to serialize " << message.GetTypeName() |
| 58 | << " while evolving to " << t.GetTypeName(); |
| 59 | |
| 60 | // NOTE: We need to use 'ParsePartialFromString' instead of |
| 61 | // 'ParseFromString' because some required fields might not |
| 62 | // be set and we don't want an exception to get thrown. |
| 63 | CHECK(t.ParsePartialFromString(data)) |
| 64 | << "Failed to parse " << t.GetTypeName() |
| 65 | << " while evolving from " << message.GetTypeName(); |
| 66 | |
| 67 | return t; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | v1::AgentID evolve(const SlaveID& slaveId) |