Search in sources :

Example 6 with OLocalPaginatedStorage

use of com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method displayRawRecord.

@ConsoleCommand(description = "Display a record as raw bytes", onlineHelp = "Console-Command-Display-Raw-Record")
public void displayRawRecord(@ConsoleParameter(name = "rid", description = "The record id to display") final String iRecordId) throws IOException {
    checkForDatabase();
    ORecordId rid;
    if (iRecordId.indexOf(':') > -1)
        rid = new ORecordId(iRecordId);
    else {
        OIdentifiable rec = setCurrentRecord(Integer.parseInt(iRecordId));
        if (rec != null)
            rid = (ORecordId) rec.getIdentity();
        else
            return;
    }
    ORawBuffer record;
    ORecordId id = new ORecordId(rid);
    if (!(currentDatabase.getStorage() instanceof OLocalPaginatedStorage)) {
        record = currentDatabase.getStorage().readRecord(rid, null, false, false, null).getResult();
        if (record != null) {
            String content;
            if (Integer.parseInt(properties.get("maxBinaryDisplay")) < record.buffer.length)
                content = new String(Arrays.copyOf(record.buffer, Integer.parseInt(properties.get("maxBinaryDisplay"))));
            else
                content = new String(record.buffer);
            out.println("\nRaw record content. The size is " + record.buffer.length + " bytes, while settings force to print first " + content.length() + " bytes:\n\n" + content);
        }
    } else {
        final OLocalPaginatedStorage storage = (OLocalPaginatedStorage) currentDatabase.getStorage();
        final OPaginatedCluster cluster = (OPaginatedCluster) storage.getClusterById(id.getClusterId());
        if (cluster == null) {
            message("\n cluster with id %i does not exist", id.getClusterId());
            return;
        }
        message("\n\nLOW LEVEL CLUSTER INFO");
        final OPaginatedCluster.RECORD_STATUS status = cluster.getRecordStatus(id.getClusterPosition());
        message("\n status: %s", status);
        final OPaginatedClusterDebug debugInfo = cluster.readDebug(id.getClusterPosition());
        message("\n cluster fieldId: %d", debugInfo.fileId);
        message("\n cluster name: %s", cluster.getName());
        message("\n in cluster position: %d", debugInfo.clusterPosition);
        message("\n empty: %b", debugInfo.empty);
        message("\n contentSize: %d", debugInfo.contentSize);
        message("\n n-pages: %d", debugInfo.pages.size());
        message("\n\n +----------PAGE_ID---------------+------IN_PAGE_POSITION----------+---------IN_PAGE_SIZE-----------+----PAGE_CONTENT---->> ");
        for (OClusterPageDebug page : debugInfo.pages) {
            message("\n |%30d ", page.pageIndex);
            message(" |%30d ", page.inPagePosition);
            message(" |%30d ", page.inPageSize);
            message(" |%s", OBase64Utils.encodeBytes(page.content));
        }
        record = cluster.readRecord(id.getClusterPosition(), false);
    }
    if (record == null)
        throw new OSystemException("The record has been deleted");
    if ("ORecordSerializerBinary".equals(currentDatabase.getSerializer().toString())) {
        byte[] buff = record.getBuffer();
        ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
        ORecordSerializationDebug deserializeDebug = debugger.deserializeDebug(buff, currentDatabase);
        message("\n\nRECORD CONTENT INFO");
        message("\n class name: %s", deserializeDebug.className);
        message("\n fail on Reading: %b", deserializeDebug.readingFailure);
        message("\n fail position: %d", deserializeDebug.failPosition);
        if (deserializeDebug.readingException != null) {
            StringWriter writer = new StringWriter();
            deserializeDebug.readingException.printStackTrace(new PrintWriter(writer));
            message("\n Exception On Reading: %s", writer.getBuffer().toString());
        }
        message("\n number of properties : %d", deserializeDebug.properties.size());
        message("\n\n PROPERTIES");
        for (ORecordSerializationDebugProperty prop : deserializeDebug.properties) {
            message("\n  property name: %s", prop.name);
            message("\n  property type: %s", prop.type.name());
            message("\n  property globalId: %d", prop.globalId);
            message("\n  fail on reading: %b", prop.faildToRead);
            if (prop.faildToRead) {
                message("\n  failed on reading position: %b", prop.failPosition);
                StringWriter writer = new StringWriter();
                prop.readingException.printStackTrace(new PrintWriter(writer));
                message("\n  Exception on reading: %s", writer.getBuffer().toString());
            } else {
                if (prop.value instanceof ORidBag) {
                    message("\n  property value: ORidBug ");
                    ((ORidBag) prop.value).debugPrint(System.out);
                } else
                    message("\n  property value: %s", prop.value != null ? prop.value.toString() : "null");
            }
            message("\n");
        }
    }
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OSystemException(com.orientechnologies.common.exception.OSystemException) OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) ORecordSerializationDebugProperty(com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializationDebugProperty) ORecordSerializerBinaryDebug(com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinaryDebug) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ORawBuffer(com.orientechnologies.orient.core.storage.ORawBuffer) OClusterPageDebug(com.orientechnologies.orient.core.storage.impl.local.paginated.OClusterPageDebug) OPaginatedCluster(com.orientechnologies.orient.core.storage.impl.local.paginated.OPaginatedCluster) OPaginatedClusterDebug(com.orientechnologies.orient.core.storage.impl.local.paginated.OPaginatedClusterDebug) ORecordSerializationDebug(com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializationDebug) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 7 with OLocalPaginatedStorage

use of com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage in project orientdb by orientechnologies.

the class ServerRun method deleteStorages.

public void deleteStorages() {
    for (OStorage s : Orient.instance().getStorages()) {
        if (s instanceof OLocalPaginatedStorage && new File(((OLocalPaginatedStorage) s).getStoragePath()).getAbsolutePath().startsWith(getDatabasePath(""))) {
            s.close(true, true);
            Orient.instance().unregisterStorage(s);
        }
    }
}
Also used : OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) OStorage(com.orientechnologies.orient.core.storage.OStorage) File(java.io.File)

Example 8 with OLocalPaginatedStorage

use of com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage in project orientdb by orientechnologies.

the class OAbstractProfiler method dumpEnvironment.

public static String dumpEnvironment() {
    final StringBuilder buffer = new StringBuilder();
    final Runtime runtime = Runtime.getRuntime();
    final long freeSpaceInMB = new File(".").getFreeSpace();
    final long totalSpaceInMB = new File(".").getTotalSpace();
    int stgs = 0;
    long diskCacheUsed = 0;
    long diskCacheTotal = 0;
    for (OStorage stg : Orient.instance().getStorages()) {
        if (stg instanceof OLocalPaginatedStorage) {
            diskCacheUsed += ((OLocalPaginatedStorage) stg).getReadCache().getUsedMemory();
            diskCacheTotal += OGlobalConfiguration.DISK_CACHE_SIZE.getValueAsLong() * 1024 * 1024;
            stgs++;
        }
    }
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName osMBeanName = ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
        if (mbs.isInstanceOf(osMBeanName, "com.sun.management.OperatingSystemMXBean")) {
            final long osTotalMem = ((Number) mbs.getAttribute(osMBeanName, "TotalPhysicalMemorySize")).longValue();
            final long osUsedMem = osTotalMem - ((Number) mbs.getAttribute(osMBeanName, "FreePhysicalMemorySize")).longValue();
            buffer.append(String.format("OrientDB Memory profiler: HEAP=%s of %s - DISKCACHE (%s dbs)=%s of %s - OS=%s of %s - FS=%s of %s", OFileUtils.getSizeAsString(runtime.totalMemory() - runtime.freeMemory()), OFileUtils.getSizeAsString(runtime.maxMemory()), stgs, OFileUtils.getSizeAsString(diskCacheUsed), OFileUtils.getSizeAsString(diskCacheTotal), OFileUtils.getSizeAsString(osUsedMem), OFileUtils.getSizeAsString(osTotalMem), OFileUtils.getSizeAsString(freeSpaceInMB), OFileUtils.getSizeAsString(totalSpaceInMB)));
            return buffer.toString();
        }
    } catch (Exception e) {
    // Nothing to do. Proceed with default output
    }
    buffer.append(String.format("OrientDB Memory profiler: Heap=%s of %s - DiskCache (%s dbs)=%s of %s - FS=%s of %s", OFileUtils.getSizeAsString(runtime.totalMemory() - runtime.freeMemory()), OFileUtils.getSizeAsString(runtime.maxMemory()), stgs, OFileUtils.getSizeAsString(diskCacheUsed), OFileUtils.getSizeAsString(diskCacheTotal), OFileUtils.getSizeAsString(freeSpaceInMB), OFileUtils.getSizeAsString(totalSpaceInMB)));
    return buffer.toString();
}
Also used : OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) OStorage(com.orientechnologies.orient.core.storage.OStorage) File(java.io.File) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 9 with OLocalPaginatedStorage

use of com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage in project orientdb by orientechnologies.

the class OLocalHashTableWALTest method beforeMethod.

@BeforeMethod
public void beforeMethod() throws IOException {
    buildDirectory = System.getProperty("buildDirectory", ".");
    buildDirectory += "/" + this.getClass().getSimpleName();
    final File buildDir = new File(buildDirectory);
    if (buildDir.exists())
        buildDir.delete();
    buildDir.mkdir();
    final String actualStorageName = this.getClass().getSimpleName() + "Actual";
    databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + File.separator + actualStorageName);
    if (databaseDocumentTx.exists()) {
        databaseDocumentTx.open("admin", "admin");
        databaseDocumentTx.drop();
    }
    databaseDocumentTx.create();
    final String expectedStorageName = this.getClass().getSimpleName() + "Expected";
    expectedDatabaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + File.separator + expectedStorageName);
    if (expectedDatabaseDocumentTx.exists()) {
        expectedDatabaseDocumentTx.open("admin", "admin");
        expectedDatabaseDocumentTx.drop();
    }
    expectedDatabaseDocumentTx.create();
    actualStorageDir = ((OLocalPaginatedStorage) databaseDocumentTx.getStorage()).getStoragePath();
    expectedStorageDir = ((OLocalPaginatedStorage) expectedDatabaseDocumentTx.getStorage()).getStoragePath();
    createActualHashTable();
    OLocalPaginatedStorage actualStorage = (OLocalPaginatedStorage) databaseDocumentTx.getStorage();
    ODiskWriteAheadLog diskWriteAheadLog = (ODiskWriteAheadLog) actualStorage.getWALInstance();
    diskWriteAheadLog.preventCutTill(diskWriteAheadLog.getFlushedLsn());
}
Also used : OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 10 with OLocalPaginatedStorage

use of com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage in project orientdb by orientechnologies.

the class OSBTreeBonsaiWALTest method createExpectedSBTree.

private void createExpectedSBTree() {
    expectedStorageDir = buildDirectory + "/sbtreeWithWALTestExpected";
    final File buildDir = new File(buildDirectory);
    if (!buildDir.exists())
        buildDir.mkdirs();
    final File expectedStorageDirFile = new File(expectedStorageDir);
    if (!expectedStorageDirFile.exists())
        expectedStorageDirFile.mkdirs();
    expectedDatabaseDocumentTx = new ODatabaseDocumentTx("plocal:" + expectedStorageDir);
    if (expectedDatabaseDocumentTx.exists()) {
        expectedDatabaseDocumentTx.open("admin", "admin");
        expectedDatabaseDocumentTx.drop();
    }
    expectedDatabaseDocumentTx.create();
    final OLocalPaginatedStorage expectedStorage = (OLocalPaginatedStorage) expectedDatabaseDocumentTx.getStorage();
    expectedWriteCache = expectedStorage.getWriteCache();
    expectedReadCache = expectedStorage.getReadCache();
}
Also used : OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Aggregations

OLocalPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage)15 File (java.io.File)9 OStorage (com.orientechnologies.orient.core.storage.OStorage)4 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)4 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)2 IOException (java.io.IOException)2 RandomAccessFile (java.io.RandomAccessFile)2 HazelcastException (com.hazelcast.core.HazelcastException)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)1 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)1 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 OException (com.orientechnologies.common.exception.OException)1 OSystemException (com.orientechnologies.common.exception.OSystemException)1 OIOException (com.orientechnologies.common.io.OIOException)1 OCallable (com.orientechnologies.common.util.OCallable)1 OStorageConfiguration (com.orientechnologies.orient.core.config.OStorageConfiguration)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1