PackChunk getChunk(ChunkKey key) throws DhtException { PackChunk chunk = recentChunks.get(key); if (chunk != null) return chunk; chunk = load(key); if (chunk != null) return chunk; throw new DhtMissingChunkException(key); }
/** * Initialize a new missing chunk exception. * * @param key * the key of the chunk that is not found. * @param why * reason the chunk is missing. This may be an explanation about * low-level data corruption in the database. */ public DhtMissingChunkException(ChunkKey key, Throwable why) { this(key); initCause(why); }
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp, boolean validate) throws IOException, StoredObjectRepresentationNotAvailableException { DhtObjectToPack obj = (DhtObjectToPack) otp; try { PackChunk chunk = recentChunks.get(obj.chunk); if (chunk == null) { chunk = prefetcher.get(obj.chunk); if (chunk == null) { // This should never happen during packing, it implies // the fetch plan was incorrect. Unfortunately that can // occur if objects need to be recompressed on the fly. // stats.access(obj.chunk).cntCopyObjectAsIs_PrefetchMiss++; chunk = getChunk(obj.chunk); } if (!chunk.isFragment()) recentChunk(chunk); } chunk.copyObjectAsIs(out, obj, validate, this); } catch (DhtMissingChunkException missingChunk) { stats.access(missingChunk.getChunkKey()).cntCopyObjectAsIs_InvalidChunk++; throw new StoredObjectRepresentationNotAvailableException(otp); } }
public void copyObjectAsIs(PackOutputStream out, ObjectToPack otp, boolean validate) throws IOException, StoredObjectRepresentationNotAvailableException { DhtObjectToPack obj = (DhtObjectToPack) otp; try { PackChunk chunk = recentChunks.get(obj.chunk); if (chunk == null) { chunk = prefetcher.get(obj.chunk); if (chunk == null) { // This should never happen during packing, it implies // the fetch plan was incorrect. Unfortunately that can // occur if objects need to be recompressed on the fly. // stats.access(obj.chunk).cntCopyObjectAsIs_PrefetchMiss++; chunk = getChunk(obj.chunk); } if (!chunk.isFragment()) recentChunk(chunk); } chunk.copyObjectAsIs(out, obj, validate, this); } catch (DhtMissingChunkException missingChunk) { stats.access(missingChunk.getChunkKey()).cntCopyObjectAsIs_InvalidChunk++; throw new StoredObjectRepresentationNotAvailableException(otp); } }
PackChunk getChunk(ChunkKey key) throws DhtException { PackChunk chunk = recentChunks.get(key); if (chunk != null) return chunk; chunk = load(key); if (chunk != null) return chunk; throw new DhtMissingChunkException(key); }
/** * Initialize a new missing chunk exception. * * @param key * the key of the chunk that is not found. * @param why * reason the chunk is missing. This may be an explanation about * low-level data corruption in the database. */ public DhtMissingChunkException(ChunkKey key, Throwable why) { this(key); initCause(why); }
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); } }