Search in sources :

Example 1 with ODatabaseRecordThreadLocal

use of com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal in project orientdb by orientechnologies.

the class OSystemDatabase method init.

private void init() {
    final ODatabaseRecordThreadLocal tl = ODatabaseRecordThreadLocal.INSTANCE;
    final ODatabaseDocumentInternal oldDbInThread = tl != null ? tl.getIfDefined() : null;
    try {
        ODatabaseDocumentTx sysDB = new ODatabaseDocumentTx("plocal:" + getSystemDatabasePath());
        if (!sysDB.exists()) {
            OLogManager.instance().info(this, "Creating the system database '%s' for current server", SYSTEM_DB_NAME);
            Map<OGlobalConfiguration, Object> settings = new ConcurrentHashMap<OGlobalConfiguration, Object>();
            settings.put(OGlobalConfiguration.CREATE_DEFAULT_USERS, false);
            settings.put(OGlobalConfiguration.CLASS_MINIMUM_CLUSTERS, 1);
            sysDB.create(settings);
            sysDB.close();
        }
    } finally {
        if (oldDbInThread != null) {
            ODatabaseRecordThreadLocal.INSTANCE.set(oldDbInThread);
        } else {
            ODatabaseRecordThreadLocal.INSTANCE.remove();
        }
    }
}
Also used : ODatabaseRecordThreadLocal(com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal) OGlobalConfiguration(com.orientechnologies.orient.core.config.OGlobalConfiguration) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Aggregations

OGlobalConfiguration (com.orientechnologies.orient.core.config.OGlobalConfiguration)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 ODatabaseRecordThreadLocal (com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal)1 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1