Beispiel #1
0
        /// <summary>Create a new cache pool based on a CachePoolInfo object and the defaults.
        ///     </summary>
        /// <remarks>
        /// Create a new cache pool based on a CachePoolInfo object and the defaults.
        /// We will fill in information that was not supplied according to the
        /// defaults.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        internal static CachePool CreateFromInfoAndDefaults(CachePoolInfo info)
        {
            UserGroupInformation ugi = null;
            string ownerName         = info.GetOwnerName();

            if (ownerName == null)
            {
                ugi       = NameNode.GetRemoteUser();
                ownerName = ugi.GetShortUserName();
            }
            string groupName = info.GetGroupName();

            if (groupName == null)
            {
                if (ugi == null)
                {
                    ugi = NameNode.GetRemoteUser();
                }
                groupName = ugi.GetPrimaryGroupName();
            }
            FsPermission mode = (info.GetMode() == null) ? FsPermission.GetCachePoolDefault()
                                 : info.GetMode();
            long limit = info.GetLimit() == null ? CachePoolInfo.DefaultLimit : info.GetLimit
                             ();
            long maxRelativeExpiry = info.GetMaxRelativeExpiryMs() == null ? CachePoolInfo.DefaultMaxRelativeExpiry
                                 : info.GetMaxRelativeExpiryMs();

            return(new CachePool(info.GetPoolName(), ownerName, groupName, mode, limit, maxRelativeExpiry
                                 ));
        }