Example #1
0
 /// <summary>Return true if this CachedBlock is present on the given list.</summary>
 public bool IsPresent(DatanodeDescriptor.CachedBlocksList cachedBlocksList)
 {
     for (int i = 0; i < triplets.Length; i += 3)
     {
         DatanodeDescriptor.CachedBlocksList list = (DatanodeDescriptor.CachedBlocksList)triplets
                                                    [i];
         if (list == cachedBlocksList)
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
        /// <summary>
        /// Get a list of the datanodes which this block is cached,
        /// planned to be cached, or planned to be uncached on.
        /// </summary>
        /// <param name="type">
        /// If null, this parameter is ignored.
        /// If it is non-null, we match only datanodes which
        /// have it on this list.
        /// See
        /// <see cref="Org.Apache.Hadoop.Hdfs.Server.Blockmanagement.DatanodeDescriptor.CachedBlocksList.Type
        ///     "/>
        /// for a description of all the lists.
        /// </param>
        /// <returns>
        /// The list of datanodes.  Modifying this list does not
        /// alter the state of the CachedBlock.
        /// </returns>
        public IList <DatanodeDescriptor> GetDatanodes(DatanodeDescriptor.CachedBlocksList.Type
                                                       type)
        {
            IList <DatanodeDescriptor> nodes = new List <DatanodeDescriptor>();

            for (int i = 0; i < triplets.Length; i += 3)
            {
                DatanodeDescriptor.CachedBlocksList list = (DatanodeDescriptor.CachedBlocksList)triplets
                                                           [i];
                if ((type == null) || (list.GetType() == type))
                {
                    nodes.AddItem(list.GetDatanode());
                }
            }
            return(nodes);
        }