public CacheDirectiveIterator(ClientProtocol namenode, CacheDirectiveInfo filter, Sampler <object> traceSampler) : base(0L) { this.namenode = namenode; this.filter = filter; this.traceSampler = traceSampler; }
/// <summary> /// Creates a builder with all elements set to the same values as the /// given CacheDirectiveInfo. /// </summary> public Builder(CacheDirectiveInfo directive) { this.id = directive.GetId(); this.path = directive.GetPath(); this.replication = directive.GetReplication(); this.pool = directive.GetPool(); this.expiration = directive.GetExpiration(); }
public override bool Equals(object o) { if (o == null) { return(false); } if (GetType() != o.GetType()) { return(false); } CacheDirectiveInfo other = (CacheDirectiveInfo)o; return(new EqualsBuilder().Append(GetId(), other.GetId()).Append(GetPath(), other .GetPath()).Append(GetReplication(), other.GetReplication()).Append(GetPool(), other .GetPool()).Append(GetExpiration(), other.GetExpiration()).IsEquals()); }
/// <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); }
public CacheDirectiveEntry(CacheDirectiveInfo info, CacheDirectiveStats stats) { this.info = info; this.stats = stats; }
private static CacheDirectiveInfo RemoveIdFromFilter(CacheDirectiveInfo filter) { CacheDirectiveInfo.Builder builder = new CacheDirectiveInfo.Builder(filter); builder.SetId(null); return(builder.Build()); }
public CacheDirective(CacheDirectiveInfo info) : this(info.GetId(), info.GetPath().ToUri().GetPath(), info.GetReplication(), info .GetExpiration().GetAbsoluteMillis()) { }