Search in sources :

Example 6 with OGlobalConfiguration

use of com.orientechnologies.orient.core.config.OGlobalConfiguration in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method configSet.

@ConsoleCommand(description = "Change the value of a configuration value")
public void configSet(@ConsoleParameter(name = "config-name", description = "Name of the configuration") final String iConfigName, @ConsoleParameter(name = "config-value", description = "Value to set") final String iConfigValue) throws IOException {
    final OGlobalConfiguration config = OGlobalConfiguration.findByKey(iConfigName);
    if (config == null)
        throw new IllegalArgumentException("Configuration variable '" + iConfigName + "' not found");
    if (serverAdmin != null) {
        serverAdmin.setGlobalConfiguration(config, iConfigValue);
        message("\nRemote configuration value changed correctly");
    } else {
        config.setValue(iConfigValue);
        message("\nLocal configuration value changed correctly");
    }
    out.println();
}
Also used : OGlobalConfiguration(com.orientechnologies.orient.core.config.OGlobalConfiguration) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 7 with OGlobalConfiguration

use of com.orientechnologies.orient.core.config.OGlobalConfiguration in project orientdb by orientechnologies.

the class OServerCommandPostServer method changeConfiguration.

private void changeConfiguration(final OHttpResponse iResponse, final String settingName, final String settingValue) throws IOException {
    final OGlobalConfiguration cfg = OGlobalConfiguration.findByKey(settingName);
    if (cfg != null) {
        final Object oldValue = cfg.getValue();
        cfg.setValue(settingValue);
        iResponse.send(OHttpUtils.STATUS_OK_CODE, OHttpUtils.STATUS_OK_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, "Server global configuration '" + settingName + "' update successfully. Old value was '" + oldValue + "', new value is '" + settingValue + "'", null);
    } else
        iResponse.send(OHttpUtils.STATUS_BADREQ_CODE, OHttpUtils.STATUS_BADREQ_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, "Server global configuration '" + settingName + "' is invalid", null);
}
Also used : OGlobalConfiguration(com.orientechnologies.orient.core.config.OGlobalConfiguration)

Example 8 with OGlobalConfiguration

use of com.orientechnologies.orient.core.config.OGlobalConfiguration in project orientdb by orientechnologies.

the class OStorageLocalTest method contextConfigurationOnCreation.

public void contextConfigurationOnCreation() {
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:testCtxCfgOnCreate");
    Map<OGlobalConfiguration, Object> settings = new HashMap<OGlobalConfiguration, Object>();
    settings.put(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, "gzip");
    db.create(settings);
    db.close();
    ODatabaseDocumentTx db2 = new ODatabaseDocumentTx("memory:testCtxCfgOnCreate").open("admin", "admin");
    Assert.assertEquals(db2.getConfiguration().getValueAsString(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD), "gzip");
}
Also used : HashMap(java.util.HashMap) OGlobalConfiguration(com.orientechnologies.orient.core.config.OGlobalConfiguration) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 9 with OGlobalConfiguration

use of com.orientechnologies.orient.core.config.OGlobalConfiguration in project orientdb by orientechnologies.

the class OOrientDBLoader method configure.

@Override
public void configure(final OETLProcessor iProcessor, final ODocument conf, final OCommandContext iContext) {
    super.configure(iProcessor, conf, iContext);
    if (conf.containsField("dbURL"))
        dbURL = (String) resolve(conf.field("dbURL"));
    if (conf.containsField("dbUser"))
        dbUser = (String) resolve(conf.field("dbUser"));
    if (conf.containsField("dbPassword"))
        dbPassword = (String) resolve(conf.field("dbPassword"));
    if (conf.containsField("serverUser"))
        serverUser = (String) resolve(conf.field("serverUser"));
    if (conf.containsField("serverPassword"))
        serverPassword = (String) resolve(conf.field("serverPassword"));
    if (conf.containsField("dbType"))
        dbType = DB_TYPE.valueOf(conf.field("dbType").toString().toUpperCase());
    if (conf.containsField("tx"))
        tx = conf.<Boolean>field("tx");
    if (conf.containsField("wal"))
        wal = conf.<Boolean>field("wal");
    if (conf.containsField("txUseLog"))
        txUseLog = conf.<Boolean>field("txUseLog");
    if (conf.containsField("batchCommit"))
        batchCommitSize = conf.<Integer>field("batchCommit");
    if (conf.containsField("dbAutoCreate"))
        dbAutoCreate = conf.<Boolean>field("dbAutoCreate");
    if (conf.containsField("dbAutoDropIfExists"))
        dbAutoDropIfExists = conf.<Boolean>field("dbAutoDropIfExists");
    if (conf.containsField("dbAutoCreateProperties"))
        dbAutoCreateProperties = conf.<Boolean>field("dbAutoCreateProperties");
    if (conf.containsField("useLightweightEdges"))
        useLightweightEdges = conf.<Boolean>field("useLightweightEdges");
    if (conf.containsField("standardElementConstraints"))
        standardElementConstraints = conf.<Boolean>field("standardElementConstraints");
    if (conf.containsField("skipDuplicates"))
        skipDuplicates = conf.field("skipDuplicates");
    clusterName = conf.field("cluster");
    className = conf.field("class");
    indexes = conf.field("indexes");
    classes = conf.field("classes");
    if (conf.containsField("settings")) {
        final ODocument settings = conf.field("settings");
        settings.setAllowChainedAccess(false);
        for (String s : settings.fieldNames()) {
            final OGlobalConfiguration v = OGlobalConfiguration.findByKey(s);
            if (v != null)
                v.setValue(settings.field(s));
        }
    }
    // use wal or not
    OGlobalConfiguration.USE_WAL.setValue(wal);
    if (dbURL.startsWith("remote")) {
        manageRemoteDatabase();
    } else {
        switch(dbType) {
            case DOCUMENT:
                configureDocumentDB();
                break;
            case GRAPH:
                configureGraphDB();
                break;
        }
    }
}
Also used : OGlobalConfiguration(com.orientechnologies.orient.core.config.OGlobalConfiguration) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 10 with OGlobalConfiguration

use of com.orientechnologies.orient.core.config.OGlobalConfiguration 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)13 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 IOException (java.io.IOException)3 OException (com.orientechnologies.common.exception.OException)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 OOfflineClusterException (com.orientechnologies.orient.core.storage.impl.local.paginated.OOfflineClusterException)2 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)1 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1 OLockException (com.orientechnologies.common.concur.lock.OLockException)1 OIOException (com.orientechnologies.common.io.OIOException)1 OCommandCacheHook (com.orientechnologies.orient.core.cache.OCommandCacheHook)1 OContextConfiguration (com.orientechnologies.orient.core.config.OContextConfiguration)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 ODatabaseRecordThreadLocal (com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal)1 OMetadataDefault (com.orientechnologies.orient.core.metadata.OMetadataDefault)1 File (java.io.File)1 SocketException (java.net.SocketException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1