@@ -424,6 +424,40 @@ void FromProto(
424424 result->EventTime = TInstant::FromValue (proto.event_time ());
425425}
426426
427+ void ToProto (
428+ NProto::TOperationEvent* proto,
429+ const NApi::TOperationEvent& result)
430+ {
431+ proto->set_timestamp (ToProto (result.Timestamp ));
432+ proto->set_event_type (ConvertOperationEventTypeToProto (result.EventType ));
433+
434+ YT_OPTIONAL_TO_PROTO (proto, incarnation, result.Incarnation );
435+
436+ if (result.IncarnationSwitchReason ) {
437+ proto->set_incarnation_switch_reason (ConvertIncarnationSwitchReasonToProto (*result.IncarnationSwitchReason ));
438+ }
439+
440+ if (result.IncarnationSwitchInfo ) {
441+ proto->set_incarnation_switch_info (result.IncarnationSwitchInfo ->ToString ());
442+ }
443+ }
444+
445+
446+ void FromProto (
447+ NApi::TOperationEvent* result,
448+ const NProto::TOperationEvent& proto)
449+ {
450+ FromProto (&result->Timestamp , proto.timestamp ());
451+ result->EventType = ConvertOperationEventTypeFromProto (proto.event_type ());
452+ result->Incarnation = YT_OPTIONAL_FROM_PROTO (proto, incarnation);
453+ if (proto.has_incarnation_switch_reason ()) {
454+ result->IncarnationSwitchReason = ConvertIncarnationSwitchReasonFromProto (proto.incarnation_switch_reason ());
455+ }
456+ if (proto.has_incarnation_switch_info ()) {
457+ result->IncarnationSwitchInfo = TYsonString (proto.incarnation_switch_info ());
458+ }
459+ }
460+
427461// //////////////////////////////////////////////////////////////////////////////
428462// MISC
429463// //////////////////////////////////////////////////////////////////////////////
@@ -1478,6 +1512,54 @@ NScheduler::EOperationState ConvertOperationStateFromProto(
14781512 YT_ABORT ();
14791513}
14801514
1515+ NProto::EOperationEventType ConvertOperationEventTypeToProto (
1516+ NApi::EOperationEventType operationEventType)
1517+ {
1518+ switch (operationEventType) {
1519+ case NApi::EOperationEventType::IncarnationStarted:
1520+ return NProto::EOperationEventType::OET_INCARNATION_STARTED;
1521+ }
1522+ }
1523+
1524+ NApi::EOperationEventType ConvertOperationEventTypeFromProto (
1525+ NProto::EOperationEventType proto)
1526+ {
1527+ switch (proto) {
1528+ case NProto::EOperationEventType::OET_INCARNATION_STARTED:
1529+ return NApi::EOperationEventType::IncarnationStarted;
1530+ }
1531+ }
1532+
1533+ NProto::EIncarnationSwitchReason ConvertIncarnationSwitchReasonToProto (
1534+ NControllerAgent::EOperationIncarnationSwitchReason operationEventType)
1535+ {
1536+ switch (operationEventType) {
1537+ case NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobAborted:
1538+ return NProto::EIncarnationSwitchReason::ISR_JOB_ABORTED;
1539+ case NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobFailed:
1540+ return NProto::EIncarnationSwitchReason::ISR_JOB_FAILED;
1541+ case NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobInterrupted:
1542+ return NProto::EIncarnationSwitchReason::ISR_JOB_INTERRUPTED;
1543+ case NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobLackAfterRevival:
1544+ return NProto::EIncarnationSwitchReason::ISR_JOB_LACK_AFTER_REVIVAL;
1545+ }
1546+ }
1547+
1548+ NControllerAgent::EOperationIncarnationSwitchReason ConvertIncarnationSwitchReasonFromProto (
1549+ NProto::EIncarnationSwitchReason proto)
1550+ {
1551+ switch (proto) {
1552+ case NProto::EIncarnationSwitchReason::ISR_JOB_ABORTED:
1553+ return NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobAborted;
1554+ case NProto::EIncarnationSwitchReason::ISR_JOB_FAILED:
1555+ return NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobFailed;
1556+ case NProto::EIncarnationSwitchReason::ISR_JOB_INTERRUPTED:
1557+ return NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobInterrupted;
1558+ case NProto::EIncarnationSwitchReason::ISR_JOB_LACK_AFTER_REVIVAL:
1559+ return NYT::NControllerAgent::EOperationIncarnationSwitchReason::JobLackAfterRevival;
1560+ }
1561+ }
1562+
14811563NProto::EJobType ConvertJobTypeToProto (
14821564 NJobTrackerClient::EJobType jobType)
14831565{
0 commit comments