Search in sources :

Example 11 with OStorageProxy

use of com.orientechnologies.orient.core.storage.OStorageProxy 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;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 12 with OStorageProxy

use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.

the class OPropertyImpl method setMax.

public OPropertyImpl setMax(final String max) {
    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 max %s", getFullNameQuoted(), quoteString(max));
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final String cmd = String.format("alter property %s max %s", getFullNameQuoted(), quoteString(max));
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            setMaxInternal(max);
        } else
            setMaxInternal(max);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 13 with OStorageProxy

use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.

the class OPropertyImpl method setLinkedType.

public OProperty setLinkedType(final OType linkedType) {
    getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
    checkLinkTypeSupport(getType());
    acquireSchemaWriteLock();
    try {
        final ODatabaseDocumentInternal database = getDatabase();
        final OStorage storage = database.getStorage();
        if (storage instanceof OStorageProxy) {
            final String cmd = String.format("alter property %s linkedtype %s", getFullNameQuoted(), linkedType);
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final String cmd = String.format("alter property %s linkedtype %s", getFullNameQuoted(), linkedType);
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            setLinkedTypeInternal(linkedType);
        } else
            setLinkedTypeInternal(linkedType);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 14 with OStorageProxy

use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.

the class OPropertyImpl method setCustom.

public OPropertyImpl setCustom(final String name, final String value) {
    getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
    acquireSchemaWriteLock();
    try {
        final String cmd = String.format("alter property %s custom %s=%s", getFullNameQuoted(), name, quoteString(value));
        final ODatabaseDocumentInternal database = getDatabase();
        final OStorage storage = database.getStorage();
        if (storage instanceof OStorageProxy) {
            database.command(new OCommandSQL(cmd)).execute();
        } else if (isDistributedCommand()) {
            final OCommandSQL commandSQL = new OCommandSQL(cmd);
            commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
            database.command(commandSQL).execute();
            setCustomInternal(name, value);
        } else
            setCustomInternal(name, value);
    } finally {
        releaseSchemaWriteLock();
    }
    return this;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OAutoshardedStorage(com.orientechnologies.orient.core.storage.OAutoshardedStorage) OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 15 with OStorageProxy

use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.

the class IndexTest method testIndexInComplexSelectTwo.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInComplexSelectTwo() {
    if (database.getStorage() instanceof OStorageProxy) {
        return;
    }
    final boolean oldRecording = Orient.instance().getProfiler().isRecording();
    if (!oldRecording) {
        Orient.instance().getProfiler().startRecording();
    }
    long indexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    if (indexQueries < 0) {
        indexQueries = 0;
    }
    final List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where " + "((name = 'Giuseppe' OR name <> 'Napoleone')" + " AND (nick is not null AND (name = 'Giuseppe' OR name <> 'Napoleone') AND (nick >= 'ZZZJayLongNickIndex3' OR nick >= 'ZZZJayLongNickIndex4')))")).execute();
    if (!oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("ZZZJayLongNickIndex3", "ZZZJayLongNickIndex4", "ZZZJayLongNickIndex5"));
    Assert.assertEquals(result.size(), 3);
    for (Profile profile : result) {
        expectedNicks.remove(profile.getNick());
    }
    Assert.assertEquals(expectedNicks.size(), 0);
    long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    Assert.assertEquals(newIndexQueries, indexQueries);
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test) DatabaseAbstractTest(com.orientechnologies.DatabaseAbstractTest) OrientTest(com.orientechnologies.orient.test.database.base.OrientTest)

Aggregations

OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)43 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)20 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)18 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 OStorage (com.orientechnologies.orient.core.storage.OStorage)18 DatabaseAbstractTest (com.orientechnologies.DatabaseAbstractTest)9 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)9 OrientTest (com.orientechnologies.orient.test.database.base.OrientTest)9 Profile (com.orientechnologies.orient.test.domain.whiz.Profile)9 Test (org.testng.annotations.Test)9 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)7 OServerAdmin (com.orientechnologies.orient.client.remote.OServerAdmin)6 ORID (com.orientechnologies.orient.core.id.ORID)6 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)4 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)3 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)3 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)3 ORecord (com.orientechnologies.orient.core.record.ORecord)3 ODatabaseLifecycleListener (com.orientechnologies.orient.core.db.ODatabaseLifecycleListener)2