@NotNull public static Environment newInstance(@NotNull final String dir) { return newInstance(dir, new EnvironmentConfig()); }
@NotNull public static ContextualEnvironment newContextualInstance(@NotNull final File dir) { return newContextualInstance(dir, new EnvironmentConfig()); }
@NotNull public static Environment newInstance(@NotNull final File dir, @NotNull final EnvironmentConfig ec) { return prepare(new EnvironmentImpl(newLogInstance(dir, ec), ec)); }
@NotNull public static Log newLogInstance(@NotNull final File dir, @NotNull final EnvironmentConfig ec) { return newLogInstance(new LogConfig().setLocation(dir.getPath()), ec); }
@NotNull public static Environment newInstance(@NotNull final Log log, @NotNull final EnvironmentConfig ec) { return prepare(new EnvironmentImpl(log, ec)); }
@NotNull public static Log newLogInstance(@NotNull final LogConfig config, @NotNull final EnvironmentConfig ec) { final Long maxMemory = ec.getMemoryUsage(); if (maxMemory != null) { config.setMemoryUsage(maxMemory); } else { config.setMemoryUsagePercentage(ec.getMemoryUsagePercentage()); } config.setReaderWriterProvider(ec.getLogDataReaderWriterProvider()); if (config.getReaderWriterProvider().isReadonly()) { ec.setEnvIsReadonly(true); config.setLockIgnored(true); } return newLogInstance(config. setFileSize(ec.getLogFileSize()). setLockTimeout(ec.getLogLockTimeout()). setCachePageSize(ec.getLogCachePageSize()). setCacheOpenFilesCount(ec.getLogCacheOpenFilesCount()). setDurableWrite(ec.getLogDurableWrite()). setSharedCache(ec.isLogCacheShared()). setNonBlockingCache(ec.isLogCacheNonBlocking()). setCacheGenerationCount(ec.getLogCacheGenerationCount()). setCleanDirectoryExpected(ec.isLogCleanDirectoryExpected()). setClearInvalidLog(ec.isLogClearInvalid()). setSyncPeriod(ec.getLogSyncPeriod()). setFullFileReadonly(ec.isLogFullFileReadonly()). setCipherProvider(ec.getCipherId() == null ? null : KryptKt.newCipherProvider(ec.getCipherId())). setCipherKey(ec.getCipherKey()). setCipherBasicIV(ec.getCipherBasicIV())); }
@NotNull public static Environment newInstance(@NotNull final File dir) { return newInstance(dir, new EnvironmentConfig()); }
@NotNull public static Environment newInstance(@NotNull final LogConfig config, @NotNull final EnvironmentConfig ec) { return prepare(new EnvironmentImpl(newLogInstance(config, ec), ec)); }
@NotNull public static ContextualEnvironment newContextualInstance(@NotNull final String dir) { return newContextualInstance(dir, new EnvironmentConfig()); }
@NotNull public static Environment newInstance(@NotNull final LogConfig config) { return newInstance(config, new EnvironmentConfig()); }
@NotNull public static ContextualEnvironment newContextualInstance(@NotNull final File dir, @NotNull final EnvironmentConfig ec) { return prepare(new ContextualEnvironmentImpl(newLogInstance(dir, ec), ec)); }
private synchronized void open() { final File loc = ProjectDatabase.getInstance().getBaseLocation(); if (nonNull(this.baseLocation) && !this.baseLocation.equals(loc)) { // change database if (nonNull(this.searcher)) { this.searcher.close(); this.searcher = null; } if (nonNull(this.environment)) { this.environment.close(); this.environment = null; } } if (isNull(this.environment)) { File env = new File(loc, "index"); this.environment = Environments.newContextualInstance(env); String location = this.environment.getLocation(); log.debug("open index database {}", location); try { this.searcher = new DocumentSearcher((ContextualEnvironment) this.environment); } catch (IOException e) { throw new UncheckedIOException(e); } } }
@Override @PostConstruct public synchronized void start() { // Already started? if (this.env != null) return; this.log.info("starting " + this); // Check configuration Preconditions.checkState(this.directory != null, "no directory configured"); if (!this.directory.exists() && !this.directory.mkdirs()) throw new RuntimeException("failed to create directory " + this.directory); if (!this.directory.isDirectory()) throw new RuntimeException("file " + this.directory + " is not a directory"); // Open database if (this.log.isDebugEnabled()) this.log.debug("starting Xodus database " + this); this.env = Environments.newInstance(this.directory, this.config); }
@NotNull public static ContextualEnvironment newContextualInstance(@NotNull final LogConfig config, @NotNull final EnvironmentConfig ec) { return prepare(new ContextualEnvironmentImpl(newLogInstance(config, ec), ec)); }
protected Environment getEnv(String envKey) { Environment env = envs.get(envKey); if (env == null) synchronized (envs) { env = envs.get(envKey); if (env == null) { checkVersion(envKey); EnvironmentConfig config = new EnvironmentConfig(); config.setEnvCloseForcedly(true); config.setMemoryUsagePercentage(MEMORY_USAGE_PERCENT); config.setLogFileSize(getLogFileSize()); env = Environments.newInstance(getEnvDir(envKey), config); envs.put(envKey, env); } } return env; }
@NotNull public static Environment newInstance(@NotNull final String dir, @NotNull final String subDir, @NotNull final EnvironmentConfig ec) { return prepare(new EnvironmentImpl(newLogInstance(new File(dir, subDir), ec), ec)); }
this.environment = Environments.newInstance(new File(base, "project")); } catch (ExodusException ex) { this.environment = Environments.newInstance(new File(base, "project"));
@NotNull public static Environment newInstance(@NotNull final String dir, @NotNull final EnvironmentConfig ec) { return prepare(new EnvironmentImpl(newLogInstance(new File(dir), ec), ec)); }
environment = Environments.newInstance( dbDirectory.getAbsolutePath() + File.separator + FILE_SUB_PATH, environmentConfig );
@NotNull public static ContextualEnvironment newContextualInstance(@NotNull final String dir, @NotNull final EnvironmentConfig ec) { return prepare(new ContextualEnvironmentImpl(newLogInstance(new File(dir), ec), ec)); }