protected static boolean canReuseActiveGraph(final ODatabaseDocument iGraphDatabase, final ODatabaseDocument iThreadLocalDatabase) { if (iGraphDatabase.getURL().equals(iThreadLocalDatabase.getURL())) { final OSecurityUser gdbUser = iGraphDatabase.getUser(); final OSecurityUser tlUser = iThreadLocalDatabase.getUser(); return gdbUser == null && tlUser == null || (gdbUser != null && tlUser != null && gdbUser.equals(tlUser)); } return false; }
@Override public String toString() { return StringFactory.graphString(this, database.getURL()); }
public String getURL() throws SQLException { database.activateOnCurrentThread(); return database.getURL(); }
OSchema schema = db.getMetadata().getSchema(); int schemaVersion = schema.getVersion(); Integer prevSchemaVersion = schemaVersions.get(db.getURL()); if(!Objects.equals(prevSchemaVersion, schemaVersion)) calcProperties.row(db.getURL()).clear(); for(OClass clazz: schema.getClasses()) if(calcProperties!=null) this.calcProperties.put(db.getURL(), clazz.getName(), calcProperties); schemaVersions.put(db.getURL(), schemaVersion); return calcProperties.get(db.getURL(), oClass.getName());
/** * Gives new connection to database. If current factory configured to use pool (see {@link #setupPool(int, int)} method), * retrieves connection from pool. Otherwise creates new connection each time. * * @param iCreate if true automatically creates database if database with given URL does not exist * @param iOpen if true automatically opens the database * * @return database */ public ODatabaseDocumentTx getDatabase(final boolean iCreate, final boolean iOpen) { if (pool != null) return pool.acquire(); final ODatabaseDocument db = new ODatabaseDocumentTx(url); if (properties != null) { properties.entrySet().forEach(e -> db.setProperty(e.getKey(), e.getValue())); } if (!db.getURL().startsWith("remote:") && !db.exists()) { if (iCreate) db.create(); else if (iOpen) throw new ODatabaseException("Database '" + url + "' not found"); } else if (iOpen) db.open(user, password); return (ODatabaseDocumentTx) db; }
@Override public void close() { makeActive(); String url = database.getURL(); try { this.tx().close(); } finally { try { if (!database.isClosed()) { database.close(); if (shouldCloseFactory) { factory.close(); } } } catch (Exception e) { OLogManager.instance().error(this, "Error during context close for db " + url, e); } } }
.warn(this, "Found a record (%s) that is not an edge. Source vertex : %s, Target vertex : %s, Database : %s", rec, sourceVertex != null ? sourceVertex.getIdentity() : null, targetVertex != null ? targetVertex.getIdentity() : null, record.getDatabase().getURL()); return null;
"Found a record (%s) that is not an edge. Source vertex : %s, Target vertex : %s, Database : %s", rec, sourceVertex != null ? sourceVertex.getIdentity() : null, targetVertex != null ? targetVertex.getIdentity() : null, record.getDatabase().getURL()); return null;