void stored(String refName, RefData newData) { DhtRef ref = fromData(refName, newData); RefCache oldCache, newCache; do { oldCache = cache.get(); if (oldCache == null) return; RefList<DhtRef> ids = oldCache.ids.put(ref); RefList<DhtRef> sym = oldCache.sym; if (ref.isSymbolic()) { sym = sym.put(ref); } else { int p = sym.find(refName); if (0 <= p) sym = sym.remove(p); } newCache = new RefCache(ids, sym, oldCache.hints); } while (!cache.compareAndSet(oldCache, newCache)); }
void stored(String refName, RefData newData) { DhtRef ref = fromData(refName, newData); RefCache oldCache, newCache; do { oldCache = cache.get(); if (oldCache == null) return; RefList<DhtRef> ids = oldCache.ids.put(ref); RefList<DhtRef> sym = oldCache.sym; if (ref.isSymbolic()) { sym = sym.put(ref); } else { int p = sym.find(refName); if (0 <= p) sym = sym.remove(p); } newCache = new RefCache(ids, sym, oldCache.hints); } while (!cache.compareAndSet(oldCache, newCache)); }
private RefCache read() throws DhtException, TimeoutException { RefList.Builder<DhtRef> id = new RefList.Builder<DhtRef>(); RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(); ObjectIdSubclassMap<IdWithChunk> hints = new ObjectIdSubclassMap<IdWithChunk>(); for (Map.Entry<RefKey, RefData> e : scan()) { DhtRef ref = fromData(e.getKey().getName(), e.getValue()); if (ref.isSymbolic()) sym.add(ref); id.add(ref); if (ref.getObjectId() instanceof IdWithChunk && !hints.contains(ref.getObjectId())) hints.add((IdWithChunk) ref.getObjectId()); if (ref.getPeeledObjectId() instanceof IdWithChunk && !hints.contains(ref.getPeeledObjectId())) hints.add((IdWithChunk) ref.getPeeledObjectId()); } id.sort(); sym.sort(); return new RefCache(id.toRefList(), sym.toRefList(), hints); }
private RefCache read() throws DhtException, TimeoutException { RefList.Builder<DhtRef> id = new RefList.Builder<DhtRef>(); RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(); ObjectIdSubclassMap<IdWithChunk> hints = new ObjectIdSubclassMap<IdWithChunk>(); for (Map.Entry<RefKey, RefData> e : scan()) { DhtRef ref = fromData(e.getKey().getName(), e.getValue()); if (ref.isSymbolic()) sym.add(ref); id.add(ref); if (ref.getObjectId() instanceof IdWithChunk && !hints.contains(ref.getObjectId())) hints.add((IdWithChunk) ref.getObjectId()); if (ref.getPeeledObjectId() instanceof IdWithChunk && !hints.contains(ref.getPeeledObjectId())) hints.add((IdWithChunk) ref.getPeeledObjectId()); } id.sort(); sym.sort(); return new RefCache(id.toRefList(), sym.toRefList(), hints); }