server.createDatabase(db.getName(), ORIENTDB_DOCUMENT_TYPE, remoteStorageType); } else { if (!server.existsDatabase()) {
/** * Reuses the underlying database avoiding to create and open it every time. * * @param iDatabase * Underlying OGraphDatabase object */ public OrientBaseGraph reuse(final ODatabaseDocumentTx iDatabase) { this.url = iDatabase.getURL(); this.username = iDatabase.getUser() != null ? iDatabase.getUser() .getName() : null; synchronized (this) { OrientGraphContext context = threadContext.get(); if (context == null || !context.rawGraph.getName().equals(iDatabase.getName())) { removeContext(); context = new OrientGraphContext(); context.rawGraph = iDatabase; checkForGraphSchema(iDatabase); threadContext.set(context); } } return this; }
private void replaceStorage(ODatabaseDocumentTx db, final OStorage storage) { db.replaceStorage(storage); if (!db.isClosed()) { try { // reload metadata for active connections if old schema is gone if (db.getMetadata().getSchema().countClasses() == 0) { log.debug("Reloading metadata for {} as storage has changed", db.getName()); db.activateOnCurrentThread(); db.getMetadata().reload(); } } catch (Exception e) { log.warn("Problem reloading metadata for {}", db.getName(), e); } } }
@Override public void drop() { checkOpenness(); internal.callOnDropListeners(); ODatabaseRecordThreadLocal.instance().remove(); factory.drop(this.getName(), null, null); this.internal = null; clearOwner(); }
public void register(final ODatabaseDocumentTx db, @Nullable final Runnable initializer) { checkNotNull(db); OSchema schema = db.getMetadata().getSchema(); OClass type = schema.getClass(typeName); if (type == null) { int clusters = getMinimumClusters(); type = clusters > 0 ? schema.createClass(typeName, clusters) : schema.createClass(typeName); defineType(db, type); log.debug("Created schema type '{}': properties={}, indexes={}", type, type.properties(), type.getIndexes() ); if (initializer != null) { log.debug("Running initializer: {}", initializer); initializer.run(); } } this.dbName = db.getName(); this.schemaType = type; if (sendEvents() && entityHook != null) { entityHook.enableEvents(this); } if (resolveConflicts() && conflictHook != null) { conflictHook.enableConflictResolution(this); if (!conflictHook.equals(db.getConflictStrategy())) { db.setConflictStrategy(conflictHook); } } }