public static ContainerState ConvertFromProtoFormat(YarnProtos.ContainerStateProto e) { return(ContainerState.ValueOf(e.ToString().Replace(ContainerStatePrefix, string.Empty ))); }
private static ContainerReport ConvertToContainerReport(TimelineEntity entity, string serverHttpAddress, string user) { int allocatedMem = 0; int allocatedVcore = 0; string allocatedHost = null; int allocatedPort = -1; int allocatedPriority = 0; long createdTime = 0; long finishedTime = 0; string diagnosticsInfo = null; int exitStatus = ContainerExitStatus.Invalid; ContainerState state = null; string nodeHttpAddress = null; IDictionary <string, object> entityInfo = entity.GetOtherInfo(); if (entityInfo != null) { if (entityInfo.Contains(ContainerMetricsConstants.AllocatedMemoryEntityInfo)) { allocatedMem = (int)entityInfo[ContainerMetricsConstants.AllocatedMemoryEntityInfo ]; } if (entityInfo.Contains(ContainerMetricsConstants.AllocatedVcoreEntityInfo)) { allocatedVcore = (int)entityInfo[ContainerMetricsConstants.AllocatedVcoreEntityInfo ]; } if (entityInfo.Contains(ContainerMetricsConstants.AllocatedHostEntityInfo)) { allocatedHost = entityInfo[ContainerMetricsConstants.AllocatedHostEntityInfo].ToString (); } if (entityInfo.Contains(ContainerMetricsConstants.AllocatedPortEntityInfo)) { allocatedPort = (int)entityInfo[ContainerMetricsConstants.AllocatedPortEntityInfo ]; } if (entityInfo.Contains(ContainerMetricsConstants.AllocatedPriorityEntityInfo)) { allocatedPriority = (int)entityInfo[ContainerMetricsConstants.AllocatedPriorityEntityInfo ]; } if (entityInfo.Contains(ContainerMetricsConstants.AllocatedHostHttpAddressEntityInfo )) { nodeHttpAddress = (string)entityInfo[ContainerMetricsConstants.AllocatedHostHttpAddressEntityInfo ]; } } IList <TimelineEvent> events = entity.GetEvents(); if (events != null) { foreach (TimelineEvent @event in events) { if (@event.GetEventType().Equals(ContainerMetricsConstants.CreatedEventType)) { createdTime = @event.GetTimestamp(); } else { if (@event.GetEventType().Equals(ContainerMetricsConstants.FinishedEventType)) { finishedTime = @event.GetTimestamp(); IDictionary <string, object> eventInfo = @event.GetEventInfo(); if (eventInfo == null) { continue; } if (eventInfo.Contains(ContainerMetricsConstants.DiagnosticsInfoEventInfo)) { diagnosticsInfo = eventInfo[ContainerMetricsConstants.DiagnosticsInfoEventInfo].ToString (); } if (eventInfo.Contains(ContainerMetricsConstants.ExitStatusEventInfo)) { exitStatus = (int)eventInfo[ContainerMetricsConstants.ExitStatusEventInfo]; } if (eventInfo.Contains(ContainerMetricsConstants.StateEventInfo)) { state = ContainerState.ValueOf(eventInfo[ContainerMetricsConstants.StateEventInfo ].ToString()); } } } } } NodeId allocatedNode = NodeId.NewInstance(allocatedHost, allocatedPort); ContainerId containerId = ConverterUtils.ToContainerId(entity.GetEntityId()); string logUrl = WebAppUtils.GetAggregatedLogURL(serverHttpAddress, allocatedNode. ToString(), containerId.ToString(), containerId.ToString(), user); return(ContainerReport.NewInstance(ConverterUtils.ToContainerId(entity.GetEntityId ()), Resource.NewInstance(allocatedMem, allocatedVcore), NodeId.NewInstance(allocatedHost , allocatedPort), Priority.NewInstance(allocatedPriority), createdTime, finishedTime , diagnosticsInfo, logUrl, exitStatus, state, nodeHttpAddress)); }