예제 #1
0
        public virtual void TestRefreshUserToGroupsMappings()
        {
            RefreshUserToGroupsMappingsRequest request = recordFactory.NewRecordInstance <RefreshUserToGroupsMappingsRequest
                                                                                          >();
            RefreshUserToGroupsMappingsResponse response = client.RefreshUserToGroupsMappings
                                                               (request);

            NUnit.Framework.Assert.IsNotNull(response);
        }
예제 #2
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        private int RefreshUserToGroupsMappings()
        {
            // Refresh the user-to-groups mappings
            ResourceManagerAdministrationProtocol adminProtocol = CreateAdminProtocol();
            RefreshUserToGroupsMappingsRequest    request       = recordFactory.NewRecordInstance <RefreshUserToGroupsMappingsRequest
                                                                                                   >();

            adminProtocol.RefreshUserToGroupsMappings(request);
            return(0);
        }
예제 #3
0
        public virtual void TestRefreshUserToGroupsMappingsWithFileSystemBasedConfigurationProvider
            ()
        {
            configuration.Set(YarnConfiguration.RmConfigurationProviderClass, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"
                              );
            string[]             defaultTestUserGroups = new string[] { "dummy_group1", "dummy_group2" };
            UserGroupInformation ugi = UserGroupInformation.CreateUserForTesting("dummyUser",
                                                                                 defaultTestUserGroups);
            string         user          = ugi.GetUserName();
            IList <string> groupWithInit = new AList <string>(2);

            for (int i = 0; i < ugi.GetGroupNames().Length; i++)
            {
                groupWithInit.AddItem(ugi.GetGroupNames()[i]);
            }
            // upload default configurations
            UploadDefaultConfiguration();
            Configuration conf = new Configuration();

            conf.SetClass(CommonConfigurationKeys.HadoopSecurityGroupMapping, typeof(TestRMAdminService.MockUnixGroupsMapping
                                                                                     ), typeof(GroupMappingServiceProvider));
            UploadConfiguration(conf, "core-site.xml");
            try
            {
                rm = new MockRM(configuration);
                rm.Init(configuration);
                rm.Start();
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("Should not get any exceptions");
            }
            // Make sure RM will use the updated GroupMappingServiceProvider
            IList <string> groupBefore = new AList <string>(Groups.GetUserToGroupsMappingService
                                                                (configuration).GetGroups(user));

            NUnit.Framework.Assert.IsTrue(groupBefore.Contains("test_group_A") && groupBefore
                                          .Contains("test_group_B") && groupBefore.Contains("test_group_C") && groupBefore
                                          .Count == 3);
            NUnit.Framework.Assert.IsTrue(groupWithInit.Count != groupBefore.Count);
            NUnit.Framework.Assert.IsFalse(groupWithInit.Contains("test_group_A") || groupWithInit
                                           .Contains("test_group_B") || groupWithInit.Contains("test_group_C"));
            // update the groups
            TestRMAdminService.MockUnixGroupsMapping.UpdateGroups();
            rm.adminService.RefreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest.NewInstance
                                                            ());
            IList <string> groupAfter = Groups.GetUserToGroupsMappingService(configuration).GetGroups
                                            (user);

            // should get the updated groups
            NUnit.Framework.Assert.IsTrue(groupAfter.Contains("test_group_D") && groupAfter.Contains
                                              ("test_group_E") && groupAfter.Contains("test_group_F") && groupAfter.Count == 3
                                          );
        }
예제 #4
0
 public virtual void TestRefreshUserToGroupsMappingsWithLocalConfigurationProvider
     ()
 {
     rm = new MockRM(configuration);
     rm.Init(configuration);
     rm.Start();
     try
     {
         rm.adminService.RefreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest.NewInstance
                                                         ());
     }
     catch (Exception)
     {
         NUnit.Framework.Assert.Fail("Using localConfigurationProvider. Should not get any exception."
                                     );
     }
 }
예제 #5
0
 /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException"/>
 private void RefreshAll()
 {
     try
     {
         RefreshQueues(RefreshQueuesRequest.NewInstance());
         RefreshNodes(RefreshNodesRequest.NewInstance());
         RefreshSuperUserGroupsConfiguration(RefreshSuperUserGroupsConfigurationRequest.NewInstance
                                                 ());
         RefreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest.NewInstance());
         if (GetConfig().GetBoolean(CommonConfigurationKeysPublic.HadoopSecurityAuthorization
                                    , false))
         {
             RefreshServiceAcls(RefreshServiceAclsRequest.NewInstance());
         }
     }
     catch (Exception ex)
     {
         throw new ServiceFailedException(ex.Message);
     }
 }
예제 #6
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public virtual RefreshUserToGroupsMappingsResponse RefreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest
                                                                                       request)
        {
            string argName            = "refreshUserToGroupsMappings";
            UserGroupInformation user = CheckAcls(argName);

            CheckRMStatus(user.GetShortUserName(), argName, "refresh user-groups.");
            Groups.GetUserToGroupsMappingService(GetConfiguration(new Configuration(false), YarnConfiguration
                                                                  .CoreSiteConfigurationFile)).Refresh();
            RMAuditLogger.LogSuccess(user.GetShortUserName(), argName, "AdminService");
            return(recordFactory.NewRecordInstance <RefreshUserToGroupsMappingsResponse>());
        }
예제 #7
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 public virtual RefreshUserToGroupsMappingsResponse RefreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest
                                                                                request)
 {
     YarnServerResourceManagerServiceProtos.RefreshUserToGroupsMappingsRequestProto requestProto
         = ((RefreshUserToGroupsMappingsRequestPBImpl)request).GetProto();
     try
     {
         return(new RefreshUserToGroupsMappingsResponsePBImpl(proxy.RefreshUserToGroupsMappings
                                                                  (null, requestProto)));
     }
     catch (ServiceException e)
     {
         RPCUtil.UnwrapAndThrowException(e);
         return(null);
     }
 }