public void get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(objects.size()); for (ObjectIndexKey k : objects) toFind.add(ns.key(k)); client.get(toFind, new LoaderFromCache(options, objects, callback)); }
@Override protected void startQueuedOperations(int bytes) throws DhtException { client.modify(pending, wrap(none, bytes)); pending = null; }
public RepositoryKey get(RepositoryName name) throws DhtException, TimeoutException { CacheKey memKey = ns.key(name); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); Map<CacheKey, byte[]> result; try { result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } catch (TimeoutException timeout) { // Fall through and read the database directly. result = emptyMap(); } byte[] data = result.get(memKey); if (data != null) { if (data.length == 0) return null; return RepositoryKey.fromBytes(data); } RepositoryKey key = db.get(name); data = key != null ? key.asBytes() : new byte[0]; client.modify(singleton(Change.put(memKey, data)), none); return key; }
public RepositoryKey get(RepositoryName name) throws DhtException, TimeoutException { CacheKey memKey = ns.key(name); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); Map<CacheKey, byte[]> result; try { result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } catch (TimeoutException timeout) { // Fall through and read the database directly. result = emptyMap(); } byte[] data = result.get(memKey); if (data != null) { if (data.length == 0) return null; return RepositoryKey.fromBytes(data); } RepositoryKey key = db.get(name); data = key != null ? key.asBytes() : new byte[0]; client.modify(singleton(Change.put(memKey, data)), none); return key; }
@Override protected void startQueuedOperations(int bytes) throws DhtException { client.modify(pending, wrap(none, bytes)); pending = null; }
CacheKey memKey = nsCachedPack.key(repo); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); } catch (InvalidProtocolBufferException e) { client.modify(singleton(Change.remove(memKey)), none); CachedPackInfoList.Builder list = CachedPackInfoList.newBuilder(); list.addAllPack(r); client.modify( singleton(Change.put(memKey, list.build().toByteArray())), none);
public void get(Context options, Set<ChunkKey> keys, AsyncCallback<Collection<PackChunk.Members>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(keys.size()); for (ChunkKey k : keys) toFind.add(nsChunk.key(k)); client.get(toFind, new ChunkFromCache(options, keys, callback)); }
public void run() { for (Map.Entry<ChunkKey, ChunkMeta> ent : toPutIntoCache.entrySet()) { ChunkKey key = ent.getKey(); Change op = Change.put(nsMeta.key(key), ent.getValue().toByteArray()); client.modify(singleton(op), none); } } });
CacheKey memKey = nsCachedPack.key(repo); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); } catch (InvalidProtocolBufferException e) { client.modify(singleton(Change.remove(memKey)), none); CachedPackInfoList.Builder list = CachedPackInfoList.newBuilder(); list.addAllPack(r); client.modify( singleton(Change.put(memKey, list.build().toByteArray())), none);
public void getMeta(Context options, Set<ChunkKey> keys, AsyncCallback<Map<ChunkKey, ChunkMeta>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(keys.size()); for (ChunkKey k : keys) toFind.add(nsMeta.key(k)); client.get(toFind, new MetaFromCache(options, keys, callback)); }
public void run() { for (Map.Entry<ChunkKey, ChunkMeta> ent : toPutIntoCache.entrySet()) { ChunkKey key = ent.getKey(); Change op = Change.put(nsMeta.key(key), ent.getValue().toByteArray()); client.modify(singleton(op), none); } } });
public void get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(objects.size()); for (ObjectIndexKey k : objects) toFind.add(ns.key(k)); client.get(toFind, new LoaderFromCache(options, objects, callback)); }
public void run() { List<Change> ops = new ArrayList<Change>(toPut.size()); for (Map.Entry<ObjectIndexKey, Collection<ObjectInfo>> e : all(toPut)) { List<ObjectInfo> items = copy(e.getValue()); ObjectInfo.sort(items); ops.add(Change.put(ns.key(e.getKey()), encode(items))); } client.modify(ops, Sync.<Void> none()); }
public void get(Context options, Set<ChunkKey> keys, AsyncCallback<Collection<PackChunk.Members>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(keys.size()); for (ChunkKey k : keys) toFind.add(nsChunk.key(k)); client.get(toFind, new ChunkFromCache(options, keys, callback)); }
public void run() { List<Change> ops = new ArrayList<Change>(toPut.size()); for (Map.Entry<ObjectIndexKey, Collection<ObjectInfo>> e : all(toPut)) { List<ObjectInfo> items = copy(e.getValue()); ObjectInfo.sort(items); ops.add(Change.put(ns.key(e.getKey()), encode(items))); } client.modify(ops, Sync.<Void> none()); }
public void getMeta(Context options, Set<ChunkKey> keys, AsyncCallback<Map<ChunkKey, ChunkMeta>> callback) { List<CacheKey> toFind = new ArrayList<CacheKey>(keys.size()); for (ChunkKey k : keys) toFind.add(nsMeta.key(k)); client.get(toFind, new MetaFromCache(options, keys, callback)); }
public void run() { for (PackChunk.Members members : toPutIntoCache) { ChunkKey key = members.getChunkKey(); Change op = Change.put(nsChunk.key(key), encode(members)); client.modify(singleton(op), none); } } });
public void run() { for (PackChunk.Members members : toPutIntoCache) { ChunkKey key = members.getChunkKey(); Change op = Change.put(nsChunk.key(key), encode(members)); client.modify(singleton(op), none); } } });
public void onPartialResult(Map<CacheKey, byte[]> result) { for (Map.Entry<CacheKey, byte[]> ent : result.entrySet()) { ChunkKey key = ChunkKey.fromBytes(ent.getKey().getBytes()); ChunkMeta meta; try { meta = ChunkMeta.parseFrom(ent.getValue()); } catch (InvalidProtocolBufferException e) { // Invalid meta message, remove the cell from cache. client.modify(singleton(Change.remove(ent.getKey())), Sync.<Void> none()); continue; } if (streamingCallback != null) { streamingCallback.onPartialResult(singletonMap(key, meta)); synchronized (lock) { remaining.remove(key); } } else { synchronized (lock) { all.put(key, meta); remaining.remove(key); } } } }
list = decode(e.getValue()); } catch (InvalidProtocolBufferException badCell) { client.modify( Collections.singleton(Change.remove(e.getKey())), Sync.<Void> none());