use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OServer method openDatabase.
public ODatabase<?> openDatabase(final String iDbUrl, final OToken iToken) {
final String path = getStoragePath(iDbUrl);
final ODatabaseInternal<?> database = new ODatabaseDocumentTx(path);
if (database.isClosed()) {
final OStorage storage = database.getStorage();
if (storage instanceof ODirectMemoryStorage && !storage.exists())
database.create();
else
database.open(iToken);
}
return database;
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OObjectEntitySerializer method getCurrentSerializedSchema.
protected static OObjectEntitySerializedSchema getCurrentSerializedSchema() {
OStorage storage = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage();
OObjectEntitySerializedSchema serializedShchema = storage.getResource(SIMPLE_NAME, new Callable<OObjectEntitySerializedSchema>() {
@Override
public OObjectEntitySerializedSchema call() throws Exception {
return new OObjectEntitySerializedSchema();
}
});
return serializedShchema;
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OPropertyImpl method setName.
public OProperty setName(final String name) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s name %s", getFullNameQuoted(), quoteString(name));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s name %s", getFullNameQuoted(), quoteString(name));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setNameInternal(name);
} else
setNameInternal(name);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OPropertyImpl method setLinkedClass.
public OPropertyImpl setLinkedClass(final OClass linkedClass) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
checkSupportLinkedClass(getType());
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s linkedclass `%s`", getFullNameQuoted(), linkedClass);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s linkedclass `%s`", getFullNameQuoted(), linkedClass);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setLinkedClassInternal(linkedClass);
} else
setLinkedClassInternal(linkedClass);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OPropertyImpl method setNotNull.
public OPropertyImpl setNotNull(final boolean isNotNull) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s notnull %s", getFullNameQuoted(), isNotNull);
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s notnull %s", getFullNameQuoted(), isNotNull);
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setNotNullInternal(isNotNull);
} else
setNotNullInternal(isNotNull);
} finally {
releaseSchemaWriteLock();
}
return this;
}
Aggregations