Search in sources :

Example 61 with OStorage

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

the class OConsoleDatabaseApp method listProperties.

@ConsoleCommand(description = "Display the database properties")
public void listProperties() {
    if (currentDatabase == null)
        return;
    final OStorage stg = currentDatabase.getStorage();
    final OStorageConfiguration dbCfg = stg.getConfiguration();
    message("\n\nDATABASE PROPERTIES");
    if (dbCfg.getProperties() != null) {
        final List<ODocument> resultSet = new ArrayList<ODocument>();
        if (dbCfg.name != null)
            resultSet.add(new ODocument().field("NAME", "Name").field("VALUE", dbCfg.name));
        resultSet.add(new ODocument().field("NAME", "Version").field("VALUE", dbCfg.version));
        resultSet.add(new ODocument().field("NAME", "Conflict-Strategy").field("VALUE", dbCfg.getConflictStrategy()));
        resultSet.add(new ODocument().field("NAME", "Date-Format").field("VALUE", dbCfg.dateFormat));
        resultSet.add(new ODocument().field("NAME", "Datetime-Format").field("VALUE", dbCfg.dateTimeFormat));
        resultSet.add(new ODocument().field("NAME", "Timezone").field("VALUE", dbCfg.getTimeZone().getID()));
        resultSet.add(new ODocument().field("NAME", "Locale-Country").field("VALUE", dbCfg.getLocaleCountry()));
        resultSet.add(new ODocument().field("NAME", "Locale-Language").field("VALUE", dbCfg.getLocaleLanguage()));
        resultSet.add(new ODocument().field("NAME", "Charset").field("VALUE", dbCfg.getCharset()));
        resultSet.add(new ODocument().field("NAME", "Schema-RID").field("VALUE", dbCfg.schemaRecordId, OType.LINK));
        resultSet.add(new ODocument().field("NAME", "Index-Manager-RID").field("VALUE", dbCfg.indexMgrRecordId, OType.LINK));
        resultSet.add(new ODocument().field("NAME", "Dictionary-RID").field("VALUE", dbCfg.dictionaryRecordId, OType.LINK));
        final OTableFormatter formatter = new OTableFormatter(this);
        formatter.writeRecords(resultSet, -1);
        message("\n");
        if (!dbCfg.getProperties().isEmpty()) {
            message("\n\nDATABASE CUSTOM PROPERTIES:");
            final List<ODocument> dbResultSet = new ArrayList<ODocument>();
            for (OStorageEntryConfiguration cfg : dbCfg.getProperties()) dbResultSet.add(new ODocument().field("NAME", cfg.name).field("VALUE", cfg.value));
            final OTableFormatter dbFormatter = new OTableFormatter(this);
            dbFormatter.writeRecords(dbResultSet, -1);
        }
    }
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OStorageEntryConfiguration(com.orientechnologies.orient.core.config.OStorageEntryConfiguration) OStorageConfiguration(com.orientechnologies.orient.core.config.OStorageConfiguration) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 62 with OStorage

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

the class LocalCreateBinaryDocumentSpeedTest method cycle.

@Override
@Test(enabled = false)
public void cycle() {
    final OStorage storage = database.getStorage();
    ((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
    record = new ORecordBytes(database, payload);
    record.save();
    if (data.getCyclesDone() == data.getCycles() - 1)
        database.commit();
    OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
    System.out.println(sessionStoragePerformanceStatistic.toDocument().toJSON("prettyPrint"));
}
Also used : ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) OrientMonoThreadTest(com.orientechnologies.orient.test.database.base.OrientMonoThreadTest) Test(org.testng.annotations.Test)

Example 63 with OStorage

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

the class OConsoleDatabaseApp method info.

@ConsoleCommand(aliases = { "status" }, description = "Display information about the database", onlineHelp = "Console-Command-Info")
public void info() {
    if (currentDatabaseName != null) {
        message("\nCurrent database: " + currentDatabaseName + " (url=" + currentDatabase.getURL() + ")");
        final OStorage stg = currentDatabase.getStorage();
        if (stg instanceof OStorageRemote) {
            listServers();
        }
        listProperties();
        listClusters(null);
        listClasses();
        listIndexes();
    }
}
Also used : OStorageRemote(com.orientechnologies.orient.client.remote.OStorageRemote) OStorage(com.orientechnologies.orient.core.storage.OStorage) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 64 with OStorage

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

the class OServerAdmin method dropDatabase.

/**
   * Drops a database from a remote server instance.
   *
   * @param iDatabaseName The database name
   * @param storageType   Storage type between "plocal" or "memory".
   * @return The instance itself. Useful to execute method in chain
   * @throws IOException
   */
public synchronized OServerAdmin dropDatabase(final String iDatabaseName, final String storageType) throws IOException {
    boolean retry = true;
    while (retry) {
        retry = networkAdminOperation(new OStorageRemoteOperation<Boolean>() {

            @Override
            public Boolean execute(final OChannelBinaryAsynchClient network, OStorageRemoteSession session) throws IOException {
                try {
                    try {
                        storage.beginRequest(network, OChannelBinaryProtocol.REQUEST_DB_DROP, session);
                        network.writeString(iDatabaseName);
                        network.writeString(storageType);
                    } finally {
                        storage.endRequest(network);
                    }
                    storage.getResponse(network, session);
                    return false;
                } catch (OModificationOperationProhibitedException oope) {
                    return handleDBFreeze();
                }
            }
        }, "Cannot delete the remote storage: " + storage.getName());
    }
    final Set<OStorage> underlyingStorages = new HashSet<OStorage>();
    for (OStorage s : Orient.instance().getStorages()) {
        if (s.getType().equals(storage.getType()) && s.getName().equals(storage.getName())) {
            underlyingStorages.add(s.getUnderlying());
        }
    }
    for (OStorage s : underlyingStorages) {
        s.close(true, true);
    }
    ODatabaseRecordThreadLocal.INSTANCE.remove();
    return this;
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OChannelBinaryAsynchClient(com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient) OModificationOperationProhibitedException(com.orientechnologies.common.concur.lock.OModificationOperationProhibitedException) HashSet(java.util.HashSet)

Example 65 with OStorage

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

the class OPartitionedDatabasePool method close.

public void close() {
    if (closed)
        return;
    closed = true;
    for (PoolPartition partition : partitions) {
        if (partition == null)
            continue;
        final Queue<DatabaseDocumentTxPooled> queue = partition.queue;
        while (!queue.isEmpty()) {
            DatabaseDocumentTxPooled db = queue.poll();
            db.activateOnCurrentThread();
            OStorage storage = db.getStorage();
            storage.close();
            ODatabaseRecordThreadLocal.INSTANCE.remove();
        }
    }
    partitions = null;
    poolData = null;
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage)

Aggregations

OStorage (com.orientechnologies.orient.core.storage.OStorage)90 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)31 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)22 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)21 ORecordId (com.orientechnologies.orient.core.id.ORecordId)20 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)18 OPhysicalPosition (com.orientechnologies.orient.core.storage.OPhysicalPosition)12 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)11 File (java.io.File)11 ORID (com.orientechnologies.orient.core.id.ORID)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)7 Test (org.testng.annotations.Test)7 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)6 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)6 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)5 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5