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 CreateApplicationTimelineEntity(ApplicationId appId , bool emptyACLs, bool noAttemptId, bool wrongAppId) { TimelineEntity entity = new TimelineEntity(); entity.SetEntityType(ApplicationMetricsConstants.EntityType); if (wrongAppId) { entity.SetEntityId("wrong_app_id"); } else { entity.SetEntityId(appId.ToString()); } entity.SetDomainId(TimelineDataManager.DefaultDomainId); entity.AddPrimaryFilter(TimelineStore.SystemFilter.EntityOwner.ToString(), "yarn" ); IDictionary <string, object> entityInfo = new Dictionary <string, object>(); entityInfo[ApplicationMetricsConstants.NameEntityInfo] = "test app"; entityInfo[ApplicationMetricsConstants.TypeEntityInfo] = "test app type"; entityInfo[ApplicationMetricsConstants.UserEntityInfo] = "user1"; entityInfo[ApplicationMetricsConstants.QueueEntityInfo] = "test queue"; entityInfo[ApplicationMetricsConstants.SubmittedTimeEntityInfo] = int.MaxValue + 1L; entityInfo[ApplicationMetricsConstants.AppMemMetrics] = 123; entityInfo[ApplicationMetricsConstants.AppCpuMetrics] = 345; if (emptyACLs) { entityInfo[ApplicationMetricsConstants.AppViewAclsEntityInfo] = string.Empty; } else { entityInfo[ApplicationMetricsConstants.AppViewAclsEntityInfo] = "user2"; } entity.SetOtherInfo(entityInfo); TimelineEvent tEvent = new TimelineEvent(); tEvent.SetEventType(ApplicationMetricsConstants.CreatedEventType); tEvent.SetTimestamp(int.MaxValue + 2L + appId.GetId()); entity.AddEvent(tEvent); tEvent = new TimelineEvent(); tEvent.SetEventType(ApplicationMetricsConstants.FinishedEventType); tEvent.SetTimestamp(int.MaxValue + 3L + appId.GetId()); IDictionary <string, object> eventInfo = new Dictionary <string, object>(); eventInfo[ApplicationMetricsConstants.DiagnosticsInfoEventInfo] = "test diagnostics info"; eventInfo[ApplicationMetricsConstants.FinalStatusEventInfo] = FinalApplicationStatus .Undefined.ToString(); eventInfo[ApplicationMetricsConstants.StateEventInfo] = YarnApplicationState.Finished .ToString(); if (!noAttemptId) { eventInfo[ApplicationMetricsConstants.LatestAppAttemptEventInfo] = ApplicationAttemptId .NewInstance(appId, 1); } tEvent.SetEventInfo(eventInfo); entity.AddEvent(tEvent); return(entity); }
private static TimelineEntity CreateContainerEntity(ContainerId containerId) { TimelineEntity entity = new TimelineEntity(); entity.SetEntityType(ContainerMetricsConstants.EntityType); entity.SetEntityId(containerId.ToString()); entity.AddPrimaryFilter(ContainerMetricsConstants.ParentPrimariyFilter, containerId .GetApplicationAttemptId().ToString()); return(entity); }
private static TimelineEntity CreateAppAttemptEntity(ApplicationAttemptId appAttemptId ) { TimelineEntity entity = new TimelineEntity(); entity.SetEntityType(AppAttemptMetricsConstants.EntityType); entity.SetEntityId(appAttemptId.ToString()); entity.AddPrimaryFilter(AppAttemptMetricsConstants.ParentPrimaryFilter, appAttemptId .GetApplicationId().ToString()); return(entity); }
private static TimelineEntity CreateAppAttemptTimelineEntity(ApplicationAttemptId appAttemptId) { TimelineEntity entity = new TimelineEntity(); entity.SetEntityType(AppAttemptMetricsConstants.EntityType); entity.SetEntityId(appAttemptId.ToString()); entity.SetDomainId(TimelineDataManager.DefaultDomainId); entity.AddPrimaryFilter(AppAttemptMetricsConstants.ParentPrimaryFilter, appAttemptId .GetApplicationId().ToString()); entity.AddPrimaryFilter(TimelineStore.SystemFilter.EntityOwner.ToString(), "yarn" ); TimelineEvent tEvent = new TimelineEvent(); tEvent.SetEventType(AppAttemptMetricsConstants.RegisteredEventType); tEvent.SetTimestamp(int.MaxValue + 1L); IDictionary <string, object> eventInfo = new Dictionary <string, object>(); eventInfo[AppAttemptMetricsConstants.TrackingUrlEventInfo] = "test tracking url"; eventInfo[AppAttemptMetricsConstants.OriginalTrackingUrlEventInfo] = "test original tracking url"; eventInfo[AppAttemptMetricsConstants.HostEventInfo] = "test host"; eventInfo[AppAttemptMetricsConstants.RpcPortEventInfo] = 100; eventInfo[AppAttemptMetricsConstants.MasterContainerEventInfo] = ContainerId.NewContainerId (appAttemptId, 1); tEvent.SetEventInfo(eventInfo); entity.AddEvent(tEvent); tEvent = new TimelineEvent(); tEvent.SetEventType(AppAttemptMetricsConstants.FinishedEventType); tEvent.SetTimestamp(int.MaxValue + 2L); eventInfo = new Dictionary <string, object>(); eventInfo[AppAttemptMetricsConstants.TrackingUrlEventInfo] = "test tracking url"; eventInfo[AppAttemptMetricsConstants.OriginalTrackingUrlEventInfo] = "test original tracking url"; eventInfo[AppAttemptMetricsConstants.DiagnosticsInfoEventInfo] = "test diagnostics info"; eventInfo[AppAttemptMetricsConstants.FinalStatusEventInfo] = FinalApplicationStatus .Undefined.ToString(); eventInfo[AppAttemptMetricsConstants.StateEventInfo] = YarnApplicationAttemptState .Finished.ToString(); tEvent.SetEventInfo(eventInfo); entity.AddEvent(tEvent); return(entity); }
private static TimelineEntity CreateContainerEntity(ContainerId containerId) { TimelineEntity entity = new TimelineEntity(); entity.SetEntityType(ContainerMetricsConstants.EntityType); entity.SetEntityId(containerId.ToString()); entity.SetDomainId(TimelineDataManager.DefaultDomainId); entity.AddPrimaryFilter(ContainerMetricsConstants.ParentPrimariyFilter, containerId .GetApplicationAttemptId().ToString()); entity.AddPrimaryFilter(TimelineStore.SystemFilter.EntityOwner.ToString(), "yarn" ); IDictionary <string, object> entityInfo = new Dictionary <string, object>(); entityInfo[ContainerMetricsConstants.AllocatedMemoryEntityInfo] = -1; entityInfo[ContainerMetricsConstants.AllocatedVcoreEntityInfo] = -1; entityInfo[ContainerMetricsConstants.AllocatedHostEntityInfo] = "test host"; entityInfo[ContainerMetricsConstants.AllocatedPortEntityInfo] = 100; entityInfo[ContainerMetricsConstants.AllocatedPriorityEntityInfo] = -1; entity.SetOtherInfo(entityInfo); TimelineEvent tEvent = new TimelineEvent(); tEvent.SetEventType(ContainerMetricsConstants.CreatedEventType); tEvent.SetTimestamp(int.MaxValue + 1L); entity.AddEvent(tEvent); tEvent = new TimelineEvent(); tEvent.SetEventType(ContainerMetricsConstants.FinishedEventType); tEvent.SetTimestamp(int.MaxValue + 2L); IDictionary <string, object> eventInfo = new Dictionary <string, object>(); eventInfo[ContainerMetricsConstants.DiagnosticsInfoEventInfo] = "test diagnostics info"; eventInfo[ContainerMetricsConstants.ExitStatusEventInfo] = -1; eventInfo[ContainerMetricsConstants.StateEventInfo] = ContainerState.Complete.ToString (); tEvent.SetEventInfo(eventInfo); entity.AddEvent(tEvent); return(entity); }
public virtual void TestYarnACLsNotEnabledForEntity() { Configuration conf = new YarnConfiguration(); conf.SetBoolean(YarnConfiguration.YarnAclEnable, false); TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf); timelineACLsManager.SetTimelineStore(new TestTimelineACLsManager.TestTimelineStore ()); TimelineEntity entity = new TimelineEntity(); entity.AddPrimaryFilter(TimelineStore.SystemFilter.EntityOwner.ToString(), "owner" ); entity.SetDomainId("domain_id_1"); NUnit.Framework.Assert.IsTrue("Always true when ACLs are not enabled", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("user"), ApplicationAccessType .ViewApp, entity)); NUnit.Framework.Assert.IsTrue("Always true when ACLs are not enabled", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("user"), ApplicationAccessType .ModifyApp, entity)); }
public virtual void TestYarnACLsEnabledForEntity() { Configuration conf = new YarnConfiguration(); conf.SetBoolean(YarnConfiguration.YarnAclEnable, true); conf.Set(YarnConfiguration.YarnAdminAcl, "admin"); TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf); timelineACLsManager.SetTimelineStore(new TestTimelineACLsManager.TestTimelineStore ()); TimelineEntity entity = new TimelineEntity(); entity.AddPrimaryFilter(TimelineStore.SystemFilter.EntityOwner.ToString(), "owner" ); entity.SetDomainId("domain_id_1"); NUnit.Framework.Assert.IsTrue("Owner should be allowed to view", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("owner"), ApplicationAccessType .ViewApp, entity)); NUnit.Framework.Assert.IsTrue("Reader should be allowed to view", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("reader"), ApplicationAccessType .ViewApp, entity)); NUnit.Framework.Assert.IsFalse("Other shouldn't be allowed to view", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("other"), ApplicationAccessType .ViewApp, entity)); NUnit.Framework.Assert.IsTrue("Admin should be allowed to view", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("admin"), ApplicationAccessType .ViewApp, entity)); NUnit.Framework.Assert.IsTrue("Owner should be allowed to modify", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("owner"), ApplicationAccessType .ModifyApp, entity)); NUnit.Framework.Assert.IsTrue("Writer should be allowed to modify", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("writer"), ApplicationAccessType .ModifyApp, entity)); NUnit.Framework.Assert.IsFalse("Other shouldn't be allowed to modify", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("other"), ApplicationAccessType .ModifyApp, entity)); NUnit.Framework.Assert.IsTrue("Admin should be allowed to modify", timelineACLsManager .CheckAccess(UserGroupInformation.CreateRemoteUser("admin"), ApplicationAccessType .ModifyApp, entity)); }