/** * @param key * @return the key */ public static ChunkKey fromBytes(byte[] key) { return fromBytes(key, 0, key.length); }
/** * @param key * @return the key */ public static ChunkKey fromBytes(byte[] key) { return fromBytes(key, 0, key.length); }
/** * @param key * @return the key */ public static ChunkKey fromString(String key) { return fromBytes(Constants.encodeASCII(key)); }
/** * @param key * @return the key */ public static ChunkKey fromString(String key) { return fromBytes(Constants.encodeASCII(key)); }
public void onPartialResult(Map<CacheKey, byte[]> result) { for (Map.Entry<CacheKey, byte[]> ent : result.entrySet()) { ChunkKey key = ChunkKey.fromBytes(ent.getKey().getBytes()); PackChunk.Members members = decode(key, ent.getValue()); if (streamingCallback != null) { streamingCallback.onPartialResult(singleton(members)); synchronized (lock) { remaining.remove(key); } } else { synchronized (lock) { all.add(members); remaining.remove(key); } } } }
public void onPartialResult(Map<CacheKey, byte[]> result) { for (Map.Entry<CacheKey, byte[]> ent : result.entrySet()) { ChunkKey key = ChunkKey.fromBytes(ent.getKey().getBytes()); PackChunk.Members members = decode(key, ent.getValue()); if (streamingCallback != null) { streamingCallback.onPartialResult(singleton(members)); synchronized (lock) { remaining.remove(key); } } else { synchronized (lock) { all.add(members); remaining.remove(key); } } } }
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); } } } }
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); } } } }
public void get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { Map<ObjectIndexKey, Collection<ObjectInfo>> out = new HashMap<ObjectIndexKey, Collection<ObjectInfo>>(); for (ObjectIndexKey objId : objects) { for (MemTable.Cell cell : table.scanFamily(objId.asBytes(), colInfo)) { Collection<ObjectInfo> chunks = out.get(objId); ChunkKey chunkKey; if (chunks == null) { chunks = new ArrayList<ObjectInfo>(4); out.put(objId, chunks); } chunkKey = ChunkKey.fromBytes(colInfo.suffix(cell.getName())); try { chunks.add(new ObjectInfo( chunkKey, cell.getTimestamp(), GitStore.ObjectInfo.parseFrom(cell.getValue()))); } catch (InvalidProtocolBufferException badCell) { callback.onFailure(new DhtException(MessageFormat.format( DhtText.get().invalidObjectInfo, objId, chunkKey), badCell)); return; } } } callback.onSuccess(out); }
public void get(Context options, Set<ObjectIndexKey> objects, AsyncCallback<Map<ObjectIndexKey, Collection<ObjectInfo>>> callback) { Map<ObjectIndexKey, Collection<ObjectInfo>> out = new HashMap<ObjectIndexKey, Collection<ObjectInfo>>(); for (ObjectIndexKey objId : objects) { for (MemTable.Cell cell : table.scanFamily(objId.asBytes(), colInfo)) { Collection<ObjectInfo> chunks = out.get(objId); ChunkKey chunkKey; if (chunks == null) { chunks = new ArrayList<ObjectInfo>(4); out.put(objId, chunks); } chunkKey = ChunkKey.fromBytes(colInfo.suffix(cell.getName())); try { chunks.add(new ObjectInfo( chunkKey, cell.getTimestamp(), GitStore.ObjectInfo.parseFrom(cell.getValue()))); } catch (InvalidProtocolBufferException badCell) { callback.onFailure(new DhtException(MessageFormat.format( DhtText.get().invalidObjectInfo, objId, chunkKey), badCell)); return; } } } callback.onSuccess(out); }