Skip to content

Commit

Permalink
Issue #4873 , methods to gather WAL and full checkpoint performance w…
Browse files Browse the repository at this point in the history
…ere added.
  • Loading branch information
laa committed Apr 15, 2016
1 parent 51b4da7 commit 091b3e1
Show file tree
Hide file tree
Showing 16 changed files with 1,774 additions and 623 deletions.
Expand Up @@ -482,6 +482,9 @@ public void change(final Object iCurrentValue, final Object iNewValue) {
STORAGE_PROFILER_SNAPSHOT_INTERVAL("storageProfiler.intervalBetweenSnapshots",
"Interval between snapshots of profiler state in milliseconds", Integer.class, 100),

STORAGE_PROFILER_CLEANUP_INTERVAL("storageProfiler.cleanUpInterval",
"Interval between time series in milliseconds", Integer.class, 5000),

// LOG
LOG_CONSOLE_LEVEL("log.console.level", "Console logging level.", String.class, "info", new OConfigurationChangeCallback() {
public void change(final Object iCurrentValue, final Object iNewValue) {
Expand Down
Expand Up @@ -50,12 +50,6 @@ public void startup() {
readCache = new O2QCache(calculateReadCacheMaxMemory(OGlobalConfiguration.DISK_CACHE_SIZE.getValueAsLong() * 1024 * 1024),
OGlobalConfiguration.DISK_CACHE_PAGE_SIZE.getValueAsInteger() * 1024, true,
OGlobalConfiguration.DISK_CACHE_PINNED_PAGES.getValueAsInteger());
try {
readCache.registerMBean();
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for read cache cannot be registered", e);
}

try {
if (OByteBufferPool.instance() != null)
OByteBufferPool.instance().registerMBean();
Expand Down Expand Up @@ -107,11 +101,6 @@ public void shutdown() {
super.shutdown();

readCache.clear();
try {
readCache.unregisterMBean();
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for read cache cannot be unregistered", e);
}

try {
OByteBufferPool.instance().unregisterMBean();
Expand Down
Expand Up @@ -51,17 +51,14 @@
import com.orientechnologies.orient.core.storage.impl.local.statistic.OPerformanceStatisticManager;
import com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic;

import javax.management.*;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.management.ManagementFactory;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.zip.CRC32;
Expand All @@ -70,7 +67,7 @@
* @author Andrey Lomakin
* @since 7/23/13
*/
public class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCachePointer.WritersListener, OWOWCacheMXBean {
public class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCachePointer.WritersListener {
// we add 8 bytes before and after cache pages to prevent word tearing in mt case.

private final int MAX_PAGES_PER_FLUSH;
Expand All @@ -96,6 +93,7 @@ public class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCach
private final ConcurrentSkipListSet<PageKey> exclusiveWritePages = new ConcurrentSkipListSet<PageKey>();
private final ODistributedCounter writeCacheSize = new ODistributedCounter();
private final ODistributedCounter exclusiveWriteCacheSize = new ODistributedCounter();
private final ODistributedCounter cacheOverflowCount = new ODistributedCounter();

private final OBinarySerializer<String> stringSerializer;
private final ConcurrentMap<Integer, OFileClassic> files;
Expand Down Expand Up @@ -131,9 +129,6 @@ public class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCach

private final OByteBufferPool bufferPool;

private final AtomicBoolean mbeanIsRegistered = new AtomicBoolean();
public static final String MBEAN_NAME = "com.orientechnologies.orient.core.storage.cache.local:type=OWOWCacheMXBean";

public OWOWCache(boolean syncOnPageFlush, int pageSize, OByteBufferPool bufferPool, long groupTTL, OWriteAheadLog writeAheadLog,
long pageFlushInterval, long writeCacheMaxSize, long cacheMaxSize, OLocalPaginatedStorage storageLocal, boolean checkMinSize,
int id) {
Expand Down Expand Up @@ -573,6 +568,7 @@ public Future store(final long fileId, final long pageIndex, final OCachePointer
}

if (exclusiveWriteCacheSize.get() > writeCacheMaxSize) {
cacheOverflowCount.increment();
future = commitExecutor.submit(new PeriodicFlushTask());
}

Expand Down Expand Up @@ -1030,82 +1026,18 @@ public int getId() {
return id;
}

public void registerMBean() {
if (mbeanIsRegistered.compareAndSet(false, true)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(getMBeanName());
if (!server.isRegistered(mbeanName)) {
server.registerMBean(this, mbeanName);
} else {
mbeanIsRegistered.set(false);
OLogManager.instance().warn(this,
"MBean with name %s has already registered. Probably your system was not shutdown correctly"
+ " or you have several running applications which use OrientDB engine inside", mbeanName.getCanonicalName());
}

} catch (MalformedObjectNameException e) {
throw OException.wrapException(new OStorageException("Error during registration of write cache MBean"), e);
} catch (InstanceAlreadyExistsException e) {
throw OException.wrapException(new OStorageException("Error during registration of write cache MBean"), e);
} catch (MBeanRegistrationException e) {
throw OException.wrapException(new OStorageException("Error during registration of write cache MBean"), e);
} catch (NotCompliantMBeanException e) {
throw OException.wrapException(new OStorageException("Error during registration of write cache MBean"), e);
}
}
}

private String getMBeanName() {
return MBEAN_NAME + ",name=" + ObjectName.quote(storageLocal.getName()) + ",id=" + storageLocal.getId();
}

public void unregisterMBean() {
if (mbeanIsRegistered.compareAndSet(true, false)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(getMBeanName());
server.unregisterMBean(mbeanName);
} catch (MalformedObjectNameException e) {
throw OException.wrapException(new OStorageException("Error during unregistration of write cache MBean"), e);
} catch (InstanceNotFoundException e) {
throw OException.wrapException(new OStorageException("Error during unregistration of write cache MBean"), e);
} catch (MBeanRegistrationException e) {
throw OException.wrapException(new OStorageException("Error during unregistration of write cache MBean"), e);
}
}
public long getCacheOverflowCount() {
return cacheOverflowCount.get();
}

@Override
public long getWriteCacheSize() {
return writeCacheSize.get();
}

@Override
public long getWriteCacheSizeInMB() {
return getWriteCacheSize() / (1024 * 1024);
}

@Override
public double getWriteCacheSizeInGB() {
return Math.ceil((getWriteCacheSize() * 100.0) / (1024 * 1204 * 1024)) / 100;
}

@Override
public long getExclusiveWriteCacheSize() {
return exclusiveWriteCacheSize.get();
}

@Override
public long getExclusiveWriteCacheSizeInMB() {
return getExclusiveWriteCacheSize() / (1024 * 1024);
}

@Override
public double getExclusiveWriteCacheSizeInGB() {
return Math.ceil((getExclusiveWriteCacheSize() * 100.0) / (1024 * 1024 * 1024)) / 100;
}

private void openFile(final OFileClassic fileClassic) throws IOException {
if (fileClassic.exists()) {
if (!fileClassic.isOpen())
Expand Down Expand Up @@ -1511,7 +1443,7 @@ public void run() {
OLogManager.instance().error(this, "Exception during data flush", e);
} finally {
if (statistic != null)
statistic.stopWriteCacheFlushTimer(iterateByWritePagesFirst, flushedPages);
statistic.stopWriteCacheFlushTimer(flushedPages);
}
}

Expand Down
Expand Up @@ -52,7 +52,7 @@
* @author Andrey Lomakin
* @since 7/24/13
*/
public class O2QCache implements OReadCache, O2QCacheMXBean {
public class O2QCache implements OReadCache {
/**
* Maximum percent of pinned pages which may be contained in this cache.
*/
Expand Down Expand Up @@ -118,9 +118,6 @@ public class O2QCache implements OReadCache, O2QCacheMXBean {

private final AtomicBoolean coldPagesRemovalInProgress = new AtomicBoolean();

private final AtomicBoolean mbeanIsRegistered = new AtomicBoolean();
public static final String MBEAN_NAME = "com.orientechnologies.orient.core.storage.cache.local:type=O2QCacheMXBean";

/**
* @param readCacheMaxMemory
* Maximum amount of direct memory which can allocated by disk cache in bytes.
Expand Down Expand Up @@ -1072,64 +1069,6 @@ public void deleteStorage(OWriteCache writeCache) throws IOException {
}
}

public void registerMBean() {
if (mbeanIsRegistered.compareAndSet(false, true)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(MBEAN_NAME);

if (!server.isRegistered(mbeanName)) {
server.registerMBean(this, mbeanName);
} else {
mbeanIsRegistered.set(false);
OLogManager.instance().warn(this,
"MBean with name %s has already registered. Probably your system was not shutdown correctly"
+ " or you have several running applications which use OrientDB engine inside", mbeanName.getCanonicalName());
}

} catch (MalformedObjectNameException e) {
throw OException.wrapException(new OReadCacheException("Error during registration of read cache MBean"), e);
} catch (InstanceAlreadyExistsException e) {
throw OException.wrapException(new OReadCacheException("Error during registration of read cache MBean"), e);
} catch (MBeanRegistrationException e) {
throw OException.wrapException(new OReadCacheException("Error during registration of read cache MBean"), e);
} catch (NotCompliantMBeanException e) {
throw OException.wrapException(new OReadCacheException("Error during registration of read cache MBean"), e);
}
}
}

public void unregisterMBean() {
if (mbeanIsRegistered.compareAndSet(true, false)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(MBEAN_NAME);
server.unregisterMBean(mbeanName);
} catch (MalformedObjectNameException e) {
throw OException.wrapException(new OReadCacheException("Error during unregistration of read cache MBean"), e);
} catch (InstanceNotFoundException e) {
throw OException.wrapException(new OReadCacheException("Error during unregistration of read cache MBean"), e);
} catch (MBeanRegistrationException e) {
throw OException.wrapException(new OReadCacheException("Error during unregistration of read cache MBean"), e);
}
}
}

@Override
public int getA1InSize() {
return a1in.size();
}

@Override
public int getA1OutSize() {
return a1out.size();
}

@Override
public int getAmSize() {
return am.size();
}

private OCacheEntry get(long fileId, long pageIndex, boolean useOutQueue) {
OCacheEntry cacheEntry = am.get(fileId, pageIndex);

Expand Down Expand Up @@ -1535,16 +1474,6 @@ public long getUsedMemory() {
return ((long) (am.size() + a1in.size())) * pageSize;
}

@Override
public long getUsedMemoryInMB() {
return getUsedMemory() / (1024 * 1024);
}

@Override
public double getUsedMemoryInGB() {
return Math.ceil((getUsedMemory() * 100) / (1024.0 * 1024 * 1024)) / 100;
}

private OCacheEntry remove(long fileId, long pageIndex) {
OCacheEntry cacheEntry = am.remove(fileId, pageIndex);
if (cacheEntry != null) {
Expand Down

0 comments on commit 091b3e1

Please sign in to comment.