@Override public synchronized ODatabaseSession acquire() { return pool.getResource(null, config.getConfigurations().getValueAsLong(DB_POOL_ACQUIRE_TIMEOUT)); }
public synchronized void loadAllDatabases() { if (basePath != null) { scanDatabaseDirectory(new File(basePath), (name) -> { if (!storages.containsKey(name)) { OAbstractPaginatedStorage storage = getOrInitStorage(name); // THIS OPEN THE STORAGE ONLY THE FIRST TIME storage.open(getConfigurations().getConfigurations()); } }); } }
public ODatabasePoolImpl(OrientDBInternal factory, String database, String user, String password, OrientDBConfig config) { int max = config.getConfigurations().getValueAsInteger(DB_POOL_MAX); // TODO use configured max pool = new OResourcePool(max, new OResourcePoolListener<Void, ODatabaseDocumentInternal>() { @Override public ODatabaseDocumentInternal createNewResource(Void iKey, Object... iAdditionalArgs) { return factory.poolOpen(database, user, password, ODatabasePoolImpl.this); } @Override public boolean reuseResource(Void iKey, Object[] iAdditionalArgs, ODatabaseDocumentInternal iValue) { if (iValue.getStorage().isClosed()) { return false; } iValue.reuse(); return true; } }); this.factory = factory; this.config = config; }
public void reCreatePool() { close(); OrientDBConfig config = OrientDBConfig.defaultConfig(); config.getConfigurations().setValue(OGlobalConfiguration.DB_POOL_MAX, this.maxSize); this.pool = new ODatabasePool(this.orientdb, this.dbName, this.userName, this.password, config); }
final OContextConfiguration config = configurations.getConfigurations(); final OContextConfiguration config = configurations.getConfigurations(); if (config != null) { maxSegSize = config.getValueAsLong(OGlobalConfiguration.WAL_MAX_SEGMENT_SIZE) * 1024 * 1024; int sizePercent; if (configurations != null) { final OContextConfiguration config = configurations.getConfigurations(); OContextConfiguration config = configurations.getConfigurations(); if (config != null) { minSegSize = config.getValueAsLong(OGlobalConfiguration.WAL_MIN_SEG_SIZE) * 1024 * 1024;
protected ODatabaseDocumentEmbedded internalCreate(OrientDBConfig config, OAbstractPaginatedStorage storage) { try { storage.create(config.getConfigurations()); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error on database creation"), e); } ORecordSerializer serializer = ORecordSerializerFactory.instance().getDefaultRecordSerializer(); if (serializer.toString().equals("ORecordDocument2csv")) throw new ODatabaseException("Impossible to create the database with ORecordDocument2csv serializer"); storage.setRecordSerializer(serializer.toString(), serializer.getCurrentVersion()); // since 2.1 newly created databases use strict SQL validation by default storage.setProperty(OStatement.CUSTOM_STRICT_SQL, "true"); // No need to close final ODatabaseDocumentEmbedded embedded = factory.newInstance(storage); embedded.setSerializer(serializer); embedded.internalCreate(config); return embedded; }
factory = getOrCreateEmbeddedFactory(baseUrl, null); factory.create(dbName, null, null, ODatabaseType.MEMORY, config); OrientDBConfig openConfig = OrientDBConfig.builder().fromContext(config.getConfigurations()).build(); internal = (ODatabaseDocumentInternal) factory.open(dbName, "admin", "admin", openConfig); for (Map.Entry<ATTRIBUTES, Object> attr : preopenAttributes.entrySet()) { factory = getOrCreateEmbeddedFactory(baseUrl, null); factory.create(dbName, null, null, ODatabaseType.PLOCAL, config); OrientDBConfig openConfig = OrientDBConfig.builder().fromContext(config.getConfigurations()).build(); internal = (ODatabaseDocumentInternal) factory.open(dbName, "admin", "admin", openConfig); for (Map.Entry<ATTRIBUTES, Object> attr : preopenAttributes.entrySet()) {
public ODatabaseDocumentInternal poolOpen(String name, String user, String password, ODatabasePoolInternal pool) { final ODatabaseDocumentEmbedded embedded; synchronized (this) { checkOpen(); OAbstractPaginatedStorage storage = getOrInitStorage(name); storage.open(pool.getConfig().getConfigurations()); embedded = factory.newPoolInstance(pool, storage); embedded.init(pool.getConfig()); } embedded.rebuildIndexes(); embedded.internalOpen(user, password); embedded.callOnOpenListeners(); return embedded; }
public ODatabaseDocumentEmbedded openNoAuthorization(String name) { try { final ODatabaseDocumentEmbedded embedded; OrientDBConfig config = solveConfig(null); synchronized (this) { OAbstractPaginatedStorage storage = getOrInitStorage(name); // THIS OPEN THE STORAGE ONLY THE FIRST TIME storage.open(config.getConfigurations()); embedded = factory.newInstance(storage); embedded.init(config); } embedded.rebuildIndexes(); embedded.callOnOpenListeners(); return embedded; } catch (Exception e) { throw OException.wrapException(new ODatabaseException("Cannot open database '" + name + "'"), e); } }
public ODatabaseDocumentEmbedded openNoAuthenticate(String name, String user) { try { final ODatabaseDocumentEmbedded embedded; OrientDBConfig config = solveConfig(null); synchronized (this) { OAbstractPaginatedStorage storage = getOrInitStorage(name); // THIS OPEN THE STORAGE ONLY THE FIRST TIME storage.open(config.getConfigurations()); embedded = factory.newInstance(storage); embedded.init(config); } embedded.rebuildIndexes(); embedded.internalOpen(user, "nopwd", false); embedded.callOnOpenListeners(); return embedded; } catch (Exception e) { throw OException.wrapException(new ODatabaseException("Cannot open database '" + name + "'"), e); } }
@Override public ODatabaseDocumentInternal open(String name, String user, String password, OrientDBConfig config) { try { final ODatabaseDocumentEmbedded embedded; synchronized (this) { checkOpen(); config = solveConfig(config); OAbstractPaginatedStorage storage = getOrInitStorage(name); // THIS OPEN THE STORAGE ONLY THE FIRST TIME storage.open(config.getConfigurations()); embedded = factory.newInstance(storage); embedded.init(config); } embedded.rebuildIndexes(); embedded.internalOpen(user, password); embedded.callOnOpenListeners(); return embedded; } catch (Exception e) { throw OException.wrapException(new ODatabaseException("Cannot open database '" + name + "'"), e); } }