/// <exception cref="System.IO.IOException"/>
 private void MakeRequest()
 {
     idx     = 0;
     entries = null;
     entries = MakeRequest(prevKey);
     if (entries.Size() == 0)
     {
         entries = null;
     }
 }
        /// <exception cref="System.IO.IOException"/>
        public override BatchedRemoteIterator.BatchedEntries <CacheDirectiveEntry> MakeRequest
            (long prevKey)
        {
            BatchedRemoteIterator.BatchedEntries <CacheDirectiveEntry> entries = null;
            TraceScope scope = Trace.StartSpan("listCacheDirectives", traceSampler);

            try
            {
                entries = namenode.ListCacheDirectives(prevKey, filter);
            }
            catch (IOException e)
            {
                if (e.Message.Contains("Filtering by ID is unsupported"))
                {
                    // Retry case for old servers, do the filtering client-side
                    long id = filter.GetId();
                    filter = RemoveIdFromFilter(filter);
                    // Using id - 1 as prevId should get us a window containing the id
                    // This is somewhat brittle, since it depends on directives being
                    // returned in order of ascending ID.
                    entries = namenode.ListCacheDirectives(id - 1, filter);
                    for (int i = 0; i < entries.Size(); i++)
                    {
                        CacheDirectiveEntry entry = entries.Get(i);
                        if (entry.GetInfo().GetId().Equals((long)id))
                        {
                            return(new CacheDirectiveIterator.SingleEntry(entry));
                        }
                    }
                    throw new RemoteException(typeof(InvalidRequestException).FullName, "Did not find requested id "
                                              + id);
                }
                throw;
            }
            finally
            {
                scope.Close();
            }
            Preconditions.CheckNotNull(entries);
            return(entries);
        }
 /// <exception cref="System.IO.IOException"/>
 private void MakeRequestIfNeeded()
 {
     if (idx == -1)
     {
         MakeRequest();
     }
     else
     {
         if ((entries != null) && (idx >= entries.Size()))
         {
             if (!entries.HasMore())
             {
                 // Last time, we got fewer entries than requested.
                 // So we should be at the end.
                 entries = null;
             }
             else
             {
                 MakeRequest();
             }
         }
     }
 }
 public BatchedRemoteIterator(K prevKey)
 {
     this.prevKey = prevKey;
     this.entries = null;
     this.idx     = -1;
 }