DhtInserter(DhtObjDatabase objdb) { this.objdb = objdb; this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.options = objdb.getInserterOptions(); }
DhtReader(DhtObjDatabase objdb) { this.repository = objdb.getRepository(); this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.readerOptions = objdb.getReaderOptions(); this.inserterOptions = objdb.getInserterOptions(); this.stats = new Statistics(); this.recentInfo = new RecentInfoCache(getOptions()); this.recentChunks = new RecentChunks(this); this.deltaBaseCache = new DeltaBaseCache(this); }
/** * Initialize an in-memory representation of a DHT backed repository. * * @param builder * description of the repository and its data storage. */ public DhtRepository(DhtRepositoryBuilder builder) { super(builder); this.name = RepositoryName.create(builder.getRepositoryName()); this.key = builder.getRepositoryKey(); this.db = builder.getDatabase(); this.refdb = new DhtRefDatabase(this, db); this.objdb = new DhtObjDatabase(this, builder); this.config = new DhtConfig(); }
@Override public void create(boolean bare) throws IOException { if (!bare) throw new IllegalArgumentException( DhtText.get().repositoryMustBeBare); if (getObjectDatabase().exists()) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); try { key = db.repository().nextKey(); db.repositoryIndex().putUnique(name, key); } catch (TimeoutException err) { throw new DhtTimeoutException(MessageFormat.format( DhtText.get().timeoutLocatingRepository, name), err); } String master = Constants.R_HEADS + Constants.MASTER; RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master); if (result != RefUpdate.Result.NEW) throw new IOException(result.name()); }
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); } } }
/** * Initialize an in-memory representation of a DHT backed repository. * * @param builder * description of the repository and its data storage. */ public DhtRepository(DhtRepositoryBuilder builder) { super(builder); this.name = RepositoryName.create(builder.getRepositoryName()); this.key = builder.getRepositoryKey(); this.db = builder.getDatabase(); this.refdb = new DhtRefDatabase(this, db); this.objdb = new DhtObjDatabase(this, builder); this.config = new DhtConfig(); }
@Override public void create(boolean bare) throws IOException { if (!bare) throw new IllegalArgumentException( DhtText.get().repositoryMustBeBare); if (getObjectDatabase().exists()) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); try { key = db.repository().nextKey(); db.repositoryIndex().putUnique(name, key); } catch (TimeoutException err) { throw new DhtTimeoutException(MessageFormat.format( DhtText.get().timeoutLocatingRepository, name), err); } String master = Constants.R_HEADS + Constants.MASTER; RefUpdate.Result result = updateRef(Constants.HEAD, true).link(master); if (result != RefUpdate.Result.NEW) throw new IOException(result.name()); }
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); } } }
DhtInserter(DhtObjDatabase objdb) { this.objdb = objdb; this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.options = objdb.getInserterOptions(); }
DhtReader(DhtObjDatabase objdb) { this.repository = objdb.getRepository(); this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.readerOptions = objdb.getReaderOptions(); this.inserterOptions = objdb.getInserterOptions(); this.stats = new Statistics(); this.recentInfo = new RecentInfoCache(getOptions()); this.recentChunks = new RecentChunks(this); this.deltaBaseCache = new DeltaBaseCache(this); }
this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.options = objdb.getInserterOptions(); this.chunkKeyDigest = Constants.newMessageDigest();
this.repo = objdb.getRepository().getRepositoryKey(); this.db = objdb.getDatabase(); this.options = objdb.getInserterOptions(); this.chunkKeyDigest = Constants.newMessageDigest();