Пример #1
0
        /// <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);
        }