Search in sources :

Example 36 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class OPerformanceStatisticManager method getSessionPerformanceStatistic.

/**
   * @return Instance of performance container which is used to gathering data about storage performance statistic or
   * <code>null</code> if none of both methods {@link #startMonitoring()} or {@link #startThreadMonitoring()} are called.
   */
public OSessionStoragePerformanceStatistic getSessionPerformanceStatistic() {
    if (!enabled && !enabledForCurrentThread.get())
        return null;
    switchLock.acquireReadLock();
    try {
        if (!enabled && !enabledForCurrentThread.get())
            return null;
        final Thread currentThread = Thread.currentThread();
        OSessionStoragePerformanceStatistic performanceStatistic = statistics.get(currentThread);
        if (performanceStatistic != null) {
            return performanceStatistic;
        }
        performanceStatistic = new OSessionStoragePerformanceStatistic(intervalBetweenSnapshots, enabled ? cleanUpInterval : -1);
        statistics.put(currentThread, performanceStatistic);
        return performanceStatistic;
    } finally {
        switchLock.releaseReadLock();
    }
}
Also used : OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)

Example 37 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class OPerformanceStatisticManager method stopMonitoring.

/**
   * Stops monitoring of performance statistic for whole system.
   */
public void stopMonitoring() {
    switchLock.acquireWriteLock();
    try {
        enabled = false;
        final PerformanceCountersHolder countersHolder = ComponentType.GENERAL.newCountersHolder();
        final Map<String, PerformanceCountersHolder> componentCountersHolder = new HashMap<String, PerformanceCountersHolder>();
        WritCacheCountersHolder writCacheCountersHolder = deadThreadsStatistic.writCacheCountersHolder;
        StorageCountersHolder storageCountersHolder = deadThreadsStatistic.storageCountersHolder;
        WALCountersHolder walCountersHolder = deadThreadsStatistic.walCountersHolder;
        deadThreadsStatistic.countersHolder.pushData(countersHolder);
        componentCountersHolder.putAll(deadThreadsStatistic.countersByComponents);
        deadThreadsStatistic = null;
        for (OSessionStoragePerformanceStatistic statistic : statistics.values()) {
            statistic.pushSystemCounters(countersHolder);
            statistic.pushComponentCounters(componentCountersHolder);
            writCacheCountersHolder = statistic.pushWriteCacheCounters(writCacheCountersHolder);
            storageCountersHolder = statistic.pushStorageCounters(storageCountersHolder);
            walCountersHolder = statistic.pushWALCounters(walCountersHolder);
        }
        statistics.clear();
        postMeasurementStatistic = new ImmutableStatistic(countersHolder, componentCountersHolder, writCacheCountersHolder, storageCountersHolder, walCountersHolder);
    } finally {
        switchLock.releaseWriteLock();
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)

Example 38 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class OPerformanceStatisticManager method fetchStorageCounters.

/**
   * Iterates over all live threads and accumulates storage performance statics gathered form threads,
   * also accumulates statistic from dead threads which were alive when when gathering of performance measurements is started.
   *
   * @return Aggregated storage performance statistic
   */
private StorageCountersHolder fetchStorageCounters() {
    //go through all threads and accumulate statistic only for live threads
    //all dead threads will be removed and statistics from them will be
    //later accumulated in #deadThreadsStatistic field, then result statistic from this field
    //will be aggregated to countersHolder
    //To decrease inter thread communication delay we fetch snapshots first
    //and only after that we aggregate data from immutable snapshots
    final Collection<ORawPair<Thread, PerformanceSnapshot>> snapshots = new ArrayList<ORawPair<Thread, PerformanceSnapshot>>(statistics.size());
    final Collection<Thread> threadsToRemove = new ArrayList<Thread>();
    for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
        final Thread thread = entry.getKey();
        final OSessionStoragePerformanceStatistic statistic = entry.getValue();
        snapshots.add(new ORawPair<Thread, PerformanceSnapshot>(thread, statistic.getSnapshot()));
    }
    StorageCountersHolder holder = null;
    for (ORawPair<Thread, PerformanceSnapshot> pair : snapshots) {
        final Thread thread = pair.getFirst();
        if (thread.isAlive()) {
            final PerformanceSnapshot snapshot = pair.getSecond();
            if (snapshot.storageCountersHolder != null) {
                if (holder == null)
                    holder = new StorageCountersHolder();
                snapshot.storageCountersHolder.pushData(holder);
            }
        } else {
            threadsToRemove.add(thread);
        }
    }
    if (!threadsToRemove.isEmpty()) {
        updateDeadThreadsStatistic(threadsToRemove);
    }
    final ImmutableStatistic ds = deadThreadsStatistic;
    if (ds != null) {
        final StorageCountersHolder sch = ds.storageCountersHolder;
        if (sch != null) {
            if (holder == null)
                holder = new StorageCountersHolder();
            sch.pushData(holder);
        }
    }
    return holder;
}
Also used : ORawPair(com.orientechnologies.common.util.ORawPair) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 39 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class ODiskWriteAheadLog method logAtomicOperationEndRecord.

@Override
public OLogSequenceNumber logAtomicOperationEndRecord(OOperationUnitId operationUnitId, boolean rollback, OLogSequenceNumber startLsn, Map<String, OAtomicOperationMetadata<?>> atomicOperationMetadata) throws IOException {
    final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic();
    if (statistic != null)
        statistic.startWALLogRecordTimer();
    try {
        OAtomicUnitEndRecord record = new OAtomicUnitEndRecord(operationUnitId, rollback, atomicOperationMetadata);
        byte[] content = OWALRecordsFactory.INSTANCE.toStream(record);
        syncObject.lock();
        try {
            checkForClose();
            final OLogSequenceNumber lsn = internalLog(record, content);
            activeOperations.remove(operationUnitId);
            return lsn;
        } finally {
            syncObject.unlock();
        }
    } finally {
        if (statistic != null)
            statistic.stopWALRecordTimer(false, true);
    }
}
Also used : OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)

Example 40 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class OAbstractPaginatedStorage method makeFullCheckpoint.

protected void makeFullCheckpoint() throws IOException {
    final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic();
    if (statistic != null)
        statistic.startFullCheckpointTimer();
    try {
        if (writeAheadLog == null)
            return;
        try {
            writeAheadLog.flush();
            if (configuration != null)
                configuration.synch();
            final OLogSequenceNumber lastLSN = writeAheadLog.logFullCheckpointStart();
            writeCache.flush();
            writeAheadLog.logFullCheckpointEnd();
            writeAheadLog.flush();
            writeAheadLog.cutTill(lastLSN);
            clearStorageDirty();
        } catch (IOException ioe) {
            throw OException.wrapException(new OStorageException("Error during checkpoint creation for storage " + name), ioe);
        }
        fullCheckpointCount++;
    } finally {
        if (statistic != null)
            statistic.stopFullCheckpointTimer();
    }
}
Also used : OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)

Aggregations

OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)47 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)25 IOException (java.io.IOException)23 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)20 Lock (java.util.concurrent.locks.Lock)11 OSBTreeBonsaiLocalException (com.orientechnologies.orient.core.exception.OSBTreeBonsaiLocalException)9 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 ORawPair (com.orientechnologies.common.util.ORawPair)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 OException (com.orientechnologies.common.exception.OException)4 ORecordId (com.orientechnologies.orient.core.id.ORecordId)4 OPaginatedClusterException (com.orientechnologies.orient.core.exception.OPaginatedClusterException)3 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)3 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)3 OIndexException (com.orientechnologies.orient.core.index.OIndexException)3 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)2 OStorage (com.orientechnologies.orient.core.storage.OStorage)2 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OAllCacheEntriesAreUsedException (com.orientechnologies.orient.core.exception.OAllCacheEntriesAreUsedException)1