Java Code Examples for com.sleepycat.je.EnvironmentConfig#setReadOnly()

The following examples show how to use com.sleepycat.je.EnvironmentConfig#setReadOnly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUpgradeTestCase.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
protected Environment createEnvironment(File storeLocation)
{
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(true);
    envConfig.setConfigParam("je.lock.nLockTables", "7");
    envConfig.setReadOnly(false);
    envConfig.setSharedCache(false);
    envConfig.setCacheSize(0);
    return new Environment(storeLocation, envConfig);
}
 
Example 2
Source File: BerkeleyDBWiktionaryEdition.java    From dkpro-jwktl with Apache License 2.0 4 votes vote down vote up
protected void connect(boolean isReadOnly, boolean allowCreateNew,
		boolean overwriteExisting, final Long cacheSize) throws DatabaseException {
	// Configure DB environment.
	EnvironmentConfig envConfig = new EnvironmentConfig();
	envConfig.setAllowCreate(allowCreateNew);
	envConfig.setReadOnly(isReadOnly);
	envConfig.setTransactional(false);
	if (cacheSize != null)
		envConfig.setCacheSize(cacheSize);
	env = new Environment(dbPath, envConfig);

	// Configure store.
	StoreConfig storeConfig = new StoreConfig();
	storeConfig.setAllowCreate(allowCreateNew);
	storeConfig.setTransactional(false);
	storeConfig.setReadOnly(isReadOnly);
	store = new EntityStore(env, DATABASE_NAME, storeConfig);

	// Load properties.
	properties = new Properties();
	File propFile = new File(dbPath, PROPERTY_FILE_NAME);
	if (propFile.exists()) {
		try {
			try (Reader reader = new InputStreamReader(new FileInputStream(propFile), "UTF-8")) {
				properties.load(reader);
			}
		} catch (IOException e) {
			throw new DatabaseException("Unable to load property file", e){};
		}

		String lang = properties.getProperty("wiktionary.language");
		if (lang == null)
			lang = properties.getProperty("entry_language");
		language = Language.get(lang);
	}

	// Load index.
	pageById = store.getPrimaryIndex(Long.class, WiktionaryPage.class);
	pageByTitle = store.getSecondaryIndex(pageById, String.class, "title");
	pageByNormalizedTitle = store.getSecondaryIndex(pageById, String.class, "normalizedTitle");

	entryByKey = store.getPrimaryIndex(String.class, WiktionaryEntryProxy.class);
	entryById = store.getSecondaryIndex(entryByKey, Long.class, "entryId");
	senseByKey = store.getPrimaryIndex(String.class, WiktionarySenseProxy.class);

	openCursors = new HashSet<>();
}