Ejemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestGetGroups()
        {
            Org.Mockito.Mockito.When(admin.GetGroupsForUser(Matchers.Eq("admin"))).ThenReturn
                (new string[] { "group1", "group2" });
            TextWriter origOut = System.Console.Out;
            TextWriter @out    = Org.Mockito.Mockito.Mock <TextWriter>();

            Runtime.SetOut(@out);
            try
            {
                string[] args = new string[] { "-getGroups", "admin" };
                NUnit.Framework.Assert.AreEqual(0, rmAdminCLI.Run(args));
                Org.Mockito.Mockito.Verify(admin).GetGroupsForUser(Matchers.Eq("admin"));
                Org.Mockito.Mockito.Verify(@out).WriteLine(Matchers.ArgThat(new _ArgumentMatcher_190
                                                                                ()));
            }
            finally
            {
                Runtime.SetOut(origOut);
            }
        }
Ejemplo n.º 2
0
        /// <exception cref="System.IO.IOException"/>
        private int GetGroups(string[] usernames)
        {
            // Get groups users belongs to
            ResourceManagerAdministrationProtocol adminProtocol = CreateAdminProtocol();

            if (usernames.Length == 0)
            {
                usernames = new string[] { UserGroupInformation.GetCurrentUser().GetUserName() };
            }
            foreach (string username in usernames)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(username + " :");
                foreach (string group in adminProtocol.GetGroupsForUser(username))
                {
                    sb.Append(" ");
                    sb.Append(group);
                }
                System.Console.Out.WriteLine(sb);
            }
            return(0);
        }
        GetGroupsForUser(RpcController controller, YarnServerResourceManagerServiceProtos.GetGroupsForUserRequestProto
                         request)
        {
            string user = request.GetUser();

            try
            {
                string[] groups = real.GetGroupsForUser(user);
                YarnServerResourceManagerServiceProtos.GetGroupsForUserResponseProto.Builder responseBuilder
                    = YarnServerResourceManagerServiceProtos.GetGroupsForUserResponseProto.NewBuilder
                          ();
                foreach (string group in groups)
                {
                    responseBuilder.AddGroups(group);
                }
                return((YarnServerResourceManagerServiceProtos.GetGroupsForUserResponseProto)responseBuilder
                       .Build());
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
        }