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();
}
}
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();
}
}
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;
}
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);
}
}
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();
}
}
Aggregations