private static void checkCycle(Delta delta, ChunkKey key, int ofs) throws DeltaChainCycleException { for (; delta != null; delta = delta.next) { if (delta.deltaPos == ofs && delta.deltaChunk.equals(key)) throw DeltaChainCycleException.INSTANCE; } }
private static void checkCycle(Delta delta, ChunkKey key, int ofs) throws DeltaChainCycleException { for (; delta != null; delta = delta.next) { if (delta.deltaPos == ofs && delta.deltaChunk.equals(key)) throw DeltaChainCycleException.INSTANCE; } }
void push(Iterable<ChunkKey> list) { synchronized (this) { for (ChunkKey key : list) { if (status.containsKey(key)) continue; status.put(key, Status.ON_QUEUE); queue.add(key); if (key.equals(stopAt)) { automaticallyPushHints = false; break; } } if (!first) maybeStartGet(); } }
void push(Iterable<ChunkKey> list) { synchronized (this) { for (ChunkKey key : list) { if (status.containsKey(key)) continue; status.put(key, Status.ON_QUEUE); queue.add(key); if (key.equals(stopAt)) { automaticallyPushHints = false; break; } } if (!first) maybeStartGet(); } }
Entry get(ChunkKey key, int position) { Slot e = table[hash(key, position)]; for (; e != null; e = e.tableNext) { if (e.offset == position && key.equals(e.chunkKey)) { Entry buf = e.data.get(); if (buf != null) { moveToHead(e); stats.deltaBaseCache_Hits++; return buf; } } } stats.deltaBaseCache_Miss++; return null; }
Entry get(ChunkKey key, int position) { Slot e = table[hash(key, position)]; for (; e != null; e = e.tableNext) { if (e.offset == position && key.equals(e.chunkKey)) { Entry buf = e.data.get(); if (buf != null) { moveToHead(e); stats.deltaBaseCache_Hits++; return buf; } } } stats.deltaBaseCache_Miss++; return null; }
private void computeChunkEdges() throws DhtException { List<DhtInfo> objs = objectListByChunk; int beginIdx = 0; ChunkKey key = chunkOf(objs.get(0).chunkPtr); int type = typeOf(objs.get(0).chunkPtr); int objIdx = 1; for (; objIdx < objs.size(); objIdx++) { DhtInfo oe = objs.get(objIdx); ChunkKey oeKey = chunkOf(oe.chunkPtr); if (!key.equals(oeKey)) { computeEdges(objs.subList(beginIdx, objIdx), key, type); beginIdx = objIdx; key = oeKey; type = typeOf(oe.chunkPtr); } if (type != OBJ_MIXED && type != typeOf(oe.chunkPtr)) type = OBJ_MIXED; } computeEdges(objs.subList(beginIdx, objs.size()), key, type); }
private void computeChunkEdges() throws DhtException { List<DhtInfo> objs = objectListByChunk; int beginIdx = 0; ChunkKey key = chunkOf(objs.get(0).chunkPtr); int type = typeOf(objs.get(0).chunkPtr); int objIdx = 1; for (; objIdx < objs.size(); objIdx++) { DhtInfo oe = objs.get(objIdx); ChunkKey oeKey = chunkOf(oe.chunkPtr); if (!key.equals(oeKey)) { computeEdges(objs.subList(beginIdx, objIdx), key, type); beginIdx = objIdx; key = oeKey; type = typeOf(oe.chunkPtr); } if (type != OBJ_MIXED && type != typeOf(oe.chunkPtr)) type = OBJ_MIXED; } computeEdges(objs.subList(beginIdx, objs.size()), key, type); }
if (!queue.getFirst().equals(key)) { int idx = queue.indexOf(key); if (first && objectType == OBJ_COMMIT) {
if (!queue.getFirst().equals(key)) { int idx = queue.indexOf(key); if (first && objectType == OBJ_COMMIT) {
private void putChunkIndexes() throws DhtException { List<DhtInfo> objs = objectListByChunk; int sIdx = 0; DhtInfo oe = objs.get(0); oe.setOffset(offsetOf(oe.chunkPtr)); ChunkKey key = chunkOf(oe.chunkPtr); int type = typeOf(oe.chunkPtr); int objIdx = 1; for (; objIdx < objs.size(); objIdx++) { oe = objs.get(objIdx); oe.setOffset(offsetOf(oe.chunkPtr)); ChunkKey oeKey = chunkOf(oe.chunkPtr); if (!key.equals(oeKey)) { putChunkIndex(objs.subList(sIdx, objIdx), key, type); sIdx = objIdx; key = oeKey; type = typeOf(oe.chunkPtr); } if (type != OBJ_MIXED && type != typeOf(oe.chunkPtr)) type = OBJ_MIXED; } putChunkIndex(objs.subList(sIdx, objs.size()), key, type); }
static ChunkKey getNextFragment(ChunkMeta meta, ChunkKey chunkKey) { int cnt = meta.getFragmentCount(); for (int i = 0; i < cnt - 1; i++) { ChunkKey key = ChunkKey.fromString(meta.getFragment(i)); if (chunkKey.equals(key)) return ChunkKey.fromString(meta.getFragment(i + 1)); } return null; }
static ChunkKey getNextFragment(ChunkMeta meta, ChunkKey chunkKey) { int cnt = meta.getFragmentCount(); for (int i = 0; i < cnt - 1; i++) { ChunkKey key = ChunkKey.fromString(meta.getFragment(i)); if (chunkKey.equals(key)) return ChunkKey.fromString(meta.getFragment(i + 1)); } return null; }
private void putChunkIndexes() throws DhtException { List<DhtInfo> objs = objectListByChunk; int sIdx = 0; DhtInfo oe = objs.get(0); oe.setOffset(offsetOf(oe.chunkPtr)); ChunkKey key = chunkOf(oe.chunkPtr); int type = typeOf(oe.chunkPtr); int objIdx = 1; for (; objIdx < objs.size(); objIdx++) { oe = objs.get(objIdx); oe.setOffset(offsetOf(oe.chunkPtr)); ChunkKey oeKey = chunkOf(oe.chunkPtr); if (!key.equals(oeKey)) { putChunkIndex(objs.subList(sIdx, objIdx), key, type); sIdx = objIdx; key = oeKey; type = typeOf(oe.chunkPtr); } if (type != OBJ_MIXED && type != typeOf(oe.chunkPtr)) type = OBJ_MIXED; } putChunkIndex(objs.subList(sIdx, objs.size()), key, type); }
private void seekChunk(ChunkKey key, boolean cache) throws DhtException, DhtTimeoutException { if (dbChunk == null || !dbChunk.getChunkKey().equals(key)) { dbChunk = chunkReadBackCache.get(key); if (dbChunk == null) { dbWriteBuffer.flush(); Collection<PackChunk.Members> found; Context opt = Context.READ_REPAIR; Sync<Collection<PackChunk.Members>> sync = Sync.create(); db.chunk().get(opt, Collections.singleton(key), sync); try { found = sync.get(objdb.getReaderOptions().getTimeout()); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } if (found.isEmpty()) { throw new DhtException(MessageFormat.format( DhtText.get().missingChunk, key)); } dbChunk = found.iterator().next().build(); if (cache) chunkReadBackCache.put(key, dbChunk); } } }
private void seekChunk(ChunkKey key, boolean cache) throws DhtException, DhtTimeoutException { if (dbChunk == null || !dbChunk.getChunkKey().equals(key)) { dbChunk = chunkReadBackCache.get(key); if (dbChunk == null) { dbWriteBuffer.flush(); Collection<PackChunk.Members> found; Context opt = Context.READ_REPAIR; Sync<Collection<PackChunk.Members>> sync = Sync.create(); db.chunk().get(opt, Collections.singleton(key), sync); try { found = sync.get(objdb.getReaderOptions().getTimeout()); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } if (found.isEmpty()) { throw new DhtException(MessageFormat.format( DhtText.get().missingChunk, key)); } dbChunk = found.iterator().next().build(); if (cache) chunkReadBackCache.put(key, dbChunk); } } }
public ObjectLoader open() throws IOException { ChunkKey chunkKey = current.chunkKey; // Objects returned by the queue are clustered by chunk. This object // is either in the current chunk, or are the next chunk ready on the // prefetcher. Anything else is a programming error. // PackChunk chunk; if (currChunk != null && chunkKey.equals(currChunk.getChunkKey())) chunk = currChunk; else { chunk = prefetcher.get(chunkKey); if (chunk == null) throw new DhtMissingChunkException(chunkKey); currChunk = chunk; reader.recentChunk(chunk); } if (current.info != null) { int ptr = current.info.getOffset(); int type = current.info.getType(); return PackChunk.read(chunk, ptr, reader, type); } else { int ptr = chunk.findOffset(repo, current.object); if (ptr < 0) throw DhtReader.missing(current.object, ObjectReader.OBJ_ANY); return PackChunk.read(chunk, ptr, reader, ObjectReader.OBJ_ANY); } }
public ObjectLoader open() throws IOException { ChunkKey chunkKey = current.chunkKey; // Objects returned by the queue are clustered by chunk. This object // is either in the current chunk, or are the next chunk ready on the // prefetcher. Anything else is a programming error. // PackChunk chunk; if (currChunk != null && chunkKey.equals(currChunk.getChunkKey())) chunk = currChunk; else { chunk = prefetcher.get(chunkKey); if (chunk == null) throw new DhtMissingChunkException(chunkKey); currChunk = chunk; reader.recentChunk(chunk); } if (current.info != null) { int ptr = current.info.getOffset(); int type = current.info.getType(); return PackChunk.read(chunk, ptr, reader, type); } else { int ptr = chunk.findOffset(repo, current.object); if (ptr < 0) throw DhtReader.missing(current.object, ObjectReader.OBJ_ANY); return PackChunk.read(chunk, ptr, reader, ObjectReader.OBJ_ANY); } }
builder.setMeta(meta); if (firstChunkKey.equals(key)) builder.setChunkIndex(ChunkIndex.create(Arrays.asList(oe)));
builder.setMeta(meta); if (firstChunkKey.equals(key)) builder.setChunkIndex(ChunkIndex.create(Arrays.asList(oe)));