private void PublishApplicationFinishedEvent(ApplicationFinishedEvent @event) { TimelineEntity entity = CreateApplicationEntity(@event.GetApplicationId()); TimelineEvent tEvent = new TimelineEvent(); tEvent.SetEventType(ApplicationMetricsConstants.FinishedEventType); tEvent.SetTimestamp(@event.GetTimestamp()); IDictionary <string, object> eventInfo = new Dictionary <string, object>(); eventInfo[ApplicationMetricsConstants.DiagnosticsInfoEventInfo] = @event.GetDiagnosticsInfo (); eventInfo[ApplicationMetricsConstants.FinalStatusEventInfo] = @event.GetFinalApplicationStatus ().ToString(); eventInfo[ApplicationMetricsConstants.StateEventInfo] = @event.GetYarnApplicationState ().ToString(); if (@event.GetLatestApplicationAttemptId() != null) { eventInfo[ApplicationMetricsConstants.LatestAppAttemptEventInfo] = @event.GetLatestApplicationAttemptId ().ToString(); } RMAppMetrics appMetrics = @event.GetAppMetrics(); entity.AddOtherInfo(ApplicationMetricsConstants.AppCpuMetrics, appMetrics.GetVcoreSeconds ()); entity.AddOtherInfo(ApplicationMetricsConstants.AppMemMetrics, appMetrics.GetMemorySeconds ()); tEvent.SetEventInfo(eventInfo); entity.AddEvent(tEvent); PutEntity(entity); }
private static TimelineEntity GenerateEntity() { TimelineEntity entity = new TimelineEntity(); entity.SetEntityId("entity id"); entity.SetEntityType("entity type"); entity.SetStartTime(Runtime.CurrentTimeMillis()); for (int i = 0; i < 2; ++i) { TimelineEvent @event = new TimelineEvent(); @event.SetTimestamp(Runtime.CurrentTimeMillis()); @event.SetEventType("test event type " + i); @event.AddEventInfo("key1", "val1"); @event.AddEventInfo("key2", "val2"); entity.AddEvent(@event); } entity.AddRelatedEntity("test ref type 1", "test ref id 1"); entity.AddRelatedEntity("test ref type 2", "test ref id 2"); entity.AddPrimaryFilter("pkey1", "pval1"); entity.AddPrimaryFilter("pkey2", "pval2"); entity.AddOtherInfo("okey1", "oval1"); entity.AddOtherInfo("okey2", "oval2"); entity.SetDomainId("domain id 1"); return(entity); }
private static TimelineEntity MaskFields(TimelineEntity entity, EnumSet <TimelineReader.Field > fields) { // Conceal the fields that are not going to be exposed TimelineEntity entityToReturn = new TimelineEntity(); entityToReturn.SetEntityId(entity.GetEntityId()); entityToReturn.SetEntityType(entity.GetEntityType()); entityToReturn.SetStartTime(entity.GetStartTime()); entityToReturn.SetDomainId(entity.GetDomainId()); // Deep copy if (fields.Contains(TimelineReader.Field.Events)) { entityToReturn.AddEvents(entity.GetEvents()); } else { if (fields.Contains(TimelineReader.Field.LastEventOnly)) { entityToReturn.AddEvent(entity.GetEvents()[0]); } else { entityToReturn.SetEvents(null); } } if (fields.Contains(TimelineReader.Field.RelatedEntities)) { entityToReturn.AddRelatedEntities(entity.GetRelatedEntities()); } else { entityToReturn.SetRelatedEntities(null); } if (fields.Contains(TimelineReader.Field.PrimaryFilters)) { entityToReturn.AddPrimaryFilters(entity.GetPrimaryFilters()); } else { entityToReturn.SetPrimaryFilters(null); } if (fields.Contains(TimelineReader.Field.OtherInfo)) { entityToReturn.AddOtherInfo(entity.GetOtherInfo()); } else { entityToReturn.SetOtherInfo(null); } return(entityToReturn); }
public virtual void TestUpdatingOldEntityWithoutDomainId() { // Set the domain to the default domain when updating TimelineEntity entity = new TimelineEntity(); entity.SetEntityType("OLD_ENTITY_TYPE_1"); entity.SetEntityId("OLD_ENTITY_ID_1"); entity.SetDomainId(TimelineDataManager.DefaultDomainId); entity.AddOtherInfo("NEW_OTHER_INFO_KEY", "NEW_OTHER_INFO_VALUE"); TimelineEntities entities = new TimelineEntities(); entities.AddEntity(entity); TimelinePutResponse response = dataManaer.PostEntities(entities, UserGroupInformation .GetCurrentUser()); NUnit.Framework.Assert.AreEqual(0, response.GetErrors().Count); entity = store.GetEntity("OLD_ENTITY_ID_1", "OLD_ENTITY_TYPE_1", null); NUnit.Framework.Assert.IsNotNull(entity); // Even in leveldb, the domain is updated to the default domain Id NUnit.Framework.Assert.AreEqual(TimelineDataManager.DefaultDomainId, entity.GetDomainId ()); NUnit.Framework.Assert.AreEqual(1, entity.GetOtherInfo().Count); NUnit.Framework.Assert.AreEqual("NEW_OTHER_INFO_KEY", entity.GetOtherInfo().Keys. GetEnumerator().Next()); NUnit.Framework.Assert.AreEqual("NEW_OTHER_INFO_VALUE", entity.GetOtherInfo().Values .GetEnumerator().Next()); // Set the domain to the non-default domain when updating entity = new TimelineEntity(); entity.SetEntityType("OLD_ENTITY_TYPE_1"); entity.SetEntityId("OLD_ENTITY_ID_2"); entity.SetDomainId("NON_DEFAULT"); entity.AddOtherInfo("NEW_OTHER_INFO_KEY", "NEW_OTHER_INFO_VALUE"); entities = new TimelineEntities(); entities.AddEntity(entity); response = dataManaer.PostEntities(entities, UserGroupInformation.GetCurrentUser( )); NUnit.Framework.Assert.AreEqual(1, response.GetErrors().Count); NUnit.Framework.Assert.AreEqual(TimelinePutResponse.TimelinePutError.AccessDenied , response.GetErrors()[0].GetErrorCode()); entity = store.GetEntity("OLD_ENTITY_ID_2", "OLD_ENTITY_TYPE_1", null); NUnit.Framework.Assert.IsNotNull(entity); // In leveldb, the domain Id is still null NUnit.Framework.Assert.IsNull(entity.GetDomainId()); // Updating is not executed NUnit.Framework.Assert.AreEqual(0, entity.GetOtherInfo().Count); }