DhtObjDatabase(DhtRepository repository, DhtRepositoryBuilder builder) { this.repository = repository; this.db = builder.getDatabase(); this.readerOptions = builder.getReaderOptions(); this.inserterOptions = builder.getInserterOptions(); }
/** * Set the reader options. * * @param opt * new reader options object. * @return {@code this} */ public B setReaderOptions(DhtReaderOptions opt) { readerOptions = opt; return self(); }
/** Initializes an empty builder with no values set. */ public DhtRepositoryBuilder() { setBare(); setMustExist(true); }
@Override public B setup() throws IllegalArgumentException, DhtException, RepositoryNotFoundException { if (getDatabase() == null) throw new IllegalArgumentException(DhtText.get().databaseRequired); if (getReaderOptions() == null) setReaderOptions(new DhtReaderOptions()); if (getInserterOptions() == null) setInserterOptions(new DhtInserterOptions()); if (getRepositoryKey() == null) { if (getRepositoryName() == null) throw new IllegalArgumentException(DhtText.get().nameRequired); RepositoryKey r; try { r = getDatabase().repositoryIndex().get( RepositoryName.create(name)); } catch (TimeoutException e) { throw new DhtTimeoutException(MessageFormat.format( DhtText.get().timeoutLocatingRepository, name), e); } if (isMustExist() && r == null) throw new RepositoryNotFoundException(getRepositoryName()); if (r != null) setRepositoryKey(r); } return self(); }
/** * Open a repository by name on this database. * * @param name * the name of the repository. * @return the repository instance. If the repository does not yet exist, * the caller can use {@link Repository#create(boolean)} to create. * @throws IOException */ public DhtRepository open(String name) throws IOException { return (DhtRepository) new DhtRepositoryBuilder<DhtRepositoryBuilder, DhtRepository, MemoryDatabase>() .setDatabase(this) // .setRepositoryName(name) // .setMustExist(false) // .build(); }
/** * 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 B setup() throws IllegalArgumentException, DhtException, RepositoryNotFoundException { if (getDatabase() == null) throw new IllegalArgumentException(DhtText.get().databaseRequired); if (getReaderOptions() == null) setReaderOptions(new DhtReaderOptions()); if (getInserterOptions() == null) setInserterOptions(new DhtInserterOptions()); if (getRepositoryKey() == null) { if (getRepositoryName() == null) throw new IllegalArgumentException(DhtText.get().nameRequired); RepositoryKey r; try { r = getDatabase().repositoryIndex().get( RepositoryName.create(name)); } catch (TimeoutException e) { throw new DhtTimeoutException(MessageFormat.format( DhtText.get().timeoutLocatingRepository, name), e); } if (isMustExist() && r == null) throw new RepositoryNotFoundException(getRepositoryName()); if (r != null) setRepositoryKey(r); } return self(); }
/** * Open a repository by name on this database. * * @param name * the name of the repository. * @return the repository instance. If the repository does not yet exist, * the caller can use {@link Repository#create(boolean)} to create. * @throws IOException */ public DhtRepository open(String name) throws IOException { return (DhtRepository) new DhtRepositoryBuilder<DhtRepositoryBuilder, DhtRepository, MemoryDatabase>() .setDatabase(this) // .setRepositoryName(name) // .setMustExist(false) // .build(); }
/** * 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(); }
/** * Set the name of the repository to open. * * @param name * the name. * @return {@code this}. */ public B setRepositoryName(String name) { this.name = name; return self(); }
DhtObjDatabase(DhtRepository repository, DhtRepositoryBuilder builder) { this.repository = repository; this.db = builder.getDatabase(); this.readerOptions = builder.getReaderOptions(); this.inserterOptions = builder.getInserterOptions(); }
/** Initializes an empty builder with no values set. */ public DhtRepositoryBuilder() { setBare(); setMustExist(true); }
/** * Set the cluster used to store the repositories. * * @param database * the database supplier. * @return {@code this} */ public B setDatabase(D database) { this.database = database; return self(); }
/** * Set the reader options. * * @param opt * new reader options object. * @return {@code this} */ public B setReaderOptions(DhtReaderOptions opt) { readerOptions = opt; return self(); }
/** * Set the inserter options. * * @param opt * new inserter options object. * @return {@code this} */ public B setInserterOptions(DhtInserterOptions opt) { inserterOptions = opt; return self(); }
/** * Set the cluster used to store the repositories. * * @param database * the database supplier. * @return {@code this} */ public B setDatabase(D database) { this.database = database; return self(); }
/** * Set the inserter options. * * @param opt * new inserter options object. * @return {@code this} */ public B setInserterOptions(DhtInserterOptions opt) { inserterOptions = opt; return self(); }
/** * Set the name of the repository to open. * * @param name * the name. * @return {@code this}. */ public B setRepositoryName(String name) { this.name = name; return self(); }
/** * @param key * @return {@code this} */ public B setRepositoryKey(RepositoryKey key) { this.key = key; return self(); }
/** * @param key * @return {@code this} */ public B setRepositoryKey(RepositoryKey key) { this.key = key; return self(); }