private void awaitPendingBatches() throws InterruptedException, DhtTimeoutException, DhtException { Timeout to = ctx.getOptions().getTimeout(); if (!metaBatches.tryAcquire(batchSize, to.getTime(), to.getUnit())) throw new DhtTimeoutException(DhtText.get().timeoutChunkMeta); if (metaError.get() != null) throw metaError.get(); }
private void awaitPendingBatches() throws InterruptedException, DhtTimeoutException, DhtException { Timeout to = ctx.getOptions().getTimeout(); if (!metaBatches.tryAcquire(batchSize, to.getTime(), to.getUnit())) throw new DhtTimeoutException(DhtText.get().timeoutChunkMeta); if (metaError.get() != null) throw metaError.get(); }
private void startBatch(Context context) throws InterruptedException, DhtTimeoutException { Timeout to = ctx.getOptions().getTimeout(); if (!metaBatches.tryAcquire(1, to.getTime(), to.getUnit())) throw new DhtTimeoutException(DhtText.get().timeoutChunkMeta); Set<ChunkKey> keys = metaToRead; ctx.getDatabase().chunk().getMeta( context, keys, new MetaLoader(context, keys)); metaToRead = new HashSet<ChunkKey>(); }
private PackChunk load(ChunkKey chunkKey) throws DhtException { if (0 == stats.access(chunkKey).cntReader_Load++ && readerOptions.isTrackFirstChunkLoad()) stats.access(chunkKey).locReader_Load = new Throwable("first"); Context opt = Context.READ_REPAIR; Sync<Collection<PackChunk.Members>> sync = Sync.create(); db.chunk().get(opt, Collections.singleton(chunkKey), sync); try { Collection<PackChunk.Members> c = sync.get(getOptions() .getTimeout()); if (c.isEmpty()) return null; if (c instanceof List) return ((List<PackChunk.Members>) c).get(0).build(); return c.iterator().next().build(); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
private void startBatch(Context context) throws InterruptedException, DhtTimeoutException { Timeout to = ctx.getOptions().getTimeout(); if (!metaBatches.tryAcquire(1, to.getTime(), to.getUnit())) throw new DhtTimeoutException(DhtText.get().timeoutChunkMeta); Set<ChunkKey> keys = metaToRead; ctx.getDatabase().chunk().getMeta( context, keys, new MetaLoader(context, keys)); metaToRead = new HashSet<ChunkKey>(); }
private PackChunk load(ChunkKey chunkKey) throws DhtException { if (0 == stats.access(chunkKey).cntReader_Load++ && readerOptions.isTrackFirstChunkLoad()) stats.access(chunkKey).locReader_Load = new Throwable("first"); Context opt = Context.READ_REPAIR; Sync<Collection<PackChunk.Members>> sync = Sync.create(); db.chunk().get(opt, Collections.singleton(chunkKey), sync); try { Collection<PackChunk.Members> c = sync.get(getOptions() .getTimeout()); if (c.isEmpty()) return null; if (c instanceof List) return ((List<PackChunk.Members>) c).get(0).build(); return c.iterator().next().build(); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
private List<ObjectInfo> find(AnyObjectId obj) throws DhtException { List<ObjectInfo> info = recentInfo.get(obj); if (info != null) return info; stats.cntObjectIndex_Load++; ObjectIndexKey idxKey = ObjectIndexKey.create(repo, obj); Context opt = Context.READ_REPAIR; Sync<Map<ObjectIndexKey, Collection<ObjectInfo>>> sync = Sync.create(); db.objectIndex().get(opt, Collections.singleton(idxKey), sync); try { Collection<ObjectInfo> m; m = sync.get(getOptions().getTimeout()).get(idxKey); if (m == null || m.isEmpty()) return Collections.emptyList(); info = new ArrayList<ObjectInfo>(m); ObjectInfo.sort(info); recentInfo.put(obj, info); return info; } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (TimeoutException e) { throw new DhtTimeoutException(e); } }
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); } } }
trees = sync.get(ctx.getOptions().getTimeout()); } catch (InterruptedException e) { throw new DhtTimeoutException(e);
trees = sync.get(ctx.getOptions().getTimeout()); } catch (InterruptedException e) { throw new DhtTimeoutException(e);
setTimeout(Timeout.getTimeout(rc, "core", "dht", "timeout", getTimeout())); setPrefetchFollowEdgeHints(rc.getBoolean("core", "dht", "prefetchFollowEdgeHints", isPrefetchFollowEdgeHints())); setChunkLimit(rc.getInt("core", "dht", "chunkLimit", getChunkLimit()));
setTimeout(Timeout.getTimeout(rc, "core", "dht", "timeout", getTimeout())); setPrefetchFollowEdgeHints(rc.getBoolean("core", "dht", "prefetchFollowEdgeHints", isPrefetchFollowEdgeHints())); setChunkLimit(rc.getInt("core", "dht", "chunkLimit", getChunkLimit()));