mirror of https://github.com/apache/activemq.git
[AMQ-8285] Add 'slow' metrics to PersistenceAdapterStatistics (#664)
(cherry picked from commit c0d5399635
)
This commit is contained in:
parent
f3e90aab44
commit
16ee3cd0f2
|
@ -93,6 +93,9 @@ public class PersistenceAdapterView implements PersistenceAdapterViewMBean {
|
||||||
if (persistenceAdapterStatistics != null) {
|
if (persistenceAdapterStatistics != null) {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
|
result.put("slowCleanupTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getSlowCleanupTime()));
|
||||||
|
result.put("slowWriteTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getSlowWriteTime()));
|
||||||
|
result.put("slowReadTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getSlowReadTime()));
|
||||||
result.put("writeTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getWriteTime()));
|
result.put("writeTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getWriteTime()));
|
||||||
result.put("readTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getReadTime()));
|
result.put("readTime", getTimeStatisticAsMap(persistenceAdapterStatistics.getReadTime()));
|
||||||
return mapper.writeValueAsString(result);
|
return mapper.writeValueAsString(result);
|
||||||
|
|
|
@ -20,16 +20,39 @@ import org.apache.activemq.management.StatsImpl;
|
||||||
import org.apache.activemq.management.TimeStatisticImpl;
|
import org.apache.activemq.management.TimeStatisticImpl;
|
||||||
|
|
||||||
public class PersistenceAdapterStatistics extends StatsImpl {
|
public class PersistenceAdapterStatistics extends StatsImpl {
|
||||||
|
protected TimeStatisticImpl slowCleanupTime;
|
||||||
|
protected TimeStatisticImpl slowWriteTime;
|
||||||
|
protected TimeStatisticImpl slowReadTime;
|
||||||
|
|
||||||
protected TimeStatisticImpl writeTime;
|
protected TimeStatisticImpl writeTime;
|
||||||
protected TimeStatisticImpl readTime;
|
protected TimeStatisticImpl readTime;
|
||||||
|
|
||||||
public PersistenceAdapterStatistics() {
|
public PersistenceAdapterStatistics() {
|
||||||
|
slowCleanupTime = new TimeStatisticImpl("slowCleanupTime", "Slow time to cleanup data in the PersistentAdapter.");
|
||||||
|
slowWriteTime = new TimeStatisticImpl("slowWriteTime", "Slow time to write data to the PersistentAdapter.");
|
||||||
|
slowReadTime = new TimeStatisticImpl("slowReadTime", "Slow time to read data from the PersistentAdapter.");
|
||||||
|
addStatistic("slowCleanupTime", slowCleanupTime);
|
||||||
|
addStatistic("slowWriteTime", slowWriteTime);
|
||||||
|
addStatistic("slowReadTime", slowReadTime);
|
||||||
|
|
||||||
writeTime = new TimeStatisticImpl("writeTime", "Time to write data to the PersistentAdapter.");
|
writeTime = new TimeStatisticImpl("writeTime", "Time to write data to the PersistentAdapter.");
|
||||||
readTime = new TimeStatisticImpl("readTime", "Time to read data from the PersistentAdapter.");
|
readTime = new TimeStatisticImpl("readTime", "Time to read data from the PersistentAdapter.");
|
||||||
addStatistic("writeTime", writeTime);
|
addStatistic("writeTime", writeTime);
|
||||||
addStatistic("readTime", readTime);
|
addStatistic("readTime", readTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSlowCleanupTime(final long time) {
|
||||||
|
slowCleanupTime.addTime(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSlowWriteTime(final long time) {
|
||||||
|
slowWriteTime.addTime(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSlowReadTime(final long time) {
|
||||||
|
slowReadTime.addTime(time);
|
||||||
|
}
|
||||||
|
|
||||||
public void addWriteTime(final long time) {
|
public void addWriteTime(final long time) {
|
||||||
writeTime.addTime(time);
|
writeTime.addTime(time);
|
||||||
}
|
}
|
||||||
|
@ -41,9 +64,23 @@ public class PersistenceAdapterStatistics extends StatsImpl {
|
||||||
@Override
|
@Override
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
|
slowCleanupTime.setEnabled(enabled);
|
||||||
|
slowWriteTime.setEnabled(enabled);
|
||||||
|
slowReadTime.setEnabled(enabled);
|
||||||
writeTime.setEnabled(enabled);
|
writeTime.setEnabled(enabled);
|
||||||
readTime.setEnabled(enabled);
|
readTime.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimeStatisticImpl getSlowCleanupTime() {
|
||||||
|
return slowCleanupTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeStatisticImpl getSlowWriteTime() {
|
||||||
|
return slowWriteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeStatisticImpl getSlowReadTime() { return slowReadTime; }
|
||||||
|
|
||||||
|
|
||||||
public TimeStatisticImpl getWriteTime() {
|
public TimeStatisticImpl getWriteTime() {
|
||||||
return writeTime;
|
return writeTime;
|
||||||
|
@ -56,6 +93,9 @@ public class PersistenceAdapterStatistics extends StatsImpl {
|
||||||
if (isDoReset()) {
|
if (isDoReset()) {
|
||||||
writeTime.reset();
|
writeTime.reset();
|
||||||
readTime.reset();
|
readTime.reset();
|
||||||
|
slowCleanupTime.reset();
|
||||||
|
slowWriteTime.reset();
|
||||||
|
slowReadTime.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,9 +103,15 @@ public class PersistenceAdapterStatistics extends StatsImpl {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
writeTime.setParent(parent.writeTime);
|
writeTime.setParent(parent.writeTime);
|
||||||
readTime.setParent(parent.readTime);
|
readTime.setParent(parent.readTime);
|
||||||
|
slowCleanupTime.setParent(parent.slowCleanupTime);
|
||||||
|
slowWriteTime.setParent(parent.slowWriteTime);
|
||||||
|
slowReadTime.setParent(parent.slowReadTime);
|
||||||
} else {
|
} else {
|
||||||
writeTime.setParent(null);
|
writeTime.setParent(null);
|
||||||
readTime.setParent(null);
|
readTime.setParent(null);
|
||||||
|
slowCleanupTime.setParent(null);
|
||||||
|
slowWriteTime.setParent(null);
|
||||||
|
slowReadTime.setParent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1102,11 +1102,12 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe
|
||||||
this.indexLock.writeLock().unlock();
|
this.indexLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
checkpointUpdate(cleanup);
|
checkpointUpdate(cleanup);
|
||||||
long end = System.currentTimeMillis();
|
long totalTimeMillis = System.currentTimeMillis() - start;
|
||||||
if (LOG_SLOW_ACCESS_TIME > 0 && end - start > LOG_SLOW_ACCESS_TIME) {
|
if (LOG_SLOW_ACCESS_TIME > 0 && totalTimeMillis > LOG_SLOW_ACCESS_TIME) {
|
||||||
if (LOG.isInfoEnabled()) {
|
if (LOG.isInfoEnabled()) {
|
||||||
LOG.info("Slow KahaDB access: cleanup took " + (end - start));
|
LOG.info("Slow KahaDB access: cleanup took " + totalTimeMillis);
|
||||||
}
|
}
|
||||||
|
persistenceAdapterStatistics.addSlowCleanupTime(totalTimeMillis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,13 +1158,15 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe
|
||||||
process(data, location, before);
|
process(data, location, before);
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
if (LOG_SLOW_ACCESS_TIME > 0 && end - start > LOG_SLOW_ACCESS_TIME) {
|
long totalTimeMillis = end - start;
|
||||||
|
if (LOG_SLOW_ACCESS_TIME > 0 && totalTimeMillis > LOG_SLOW_ACCESS_TIME) {
|
||||||
if (LOG.isInfoEnabled()) {
|
if (LOG.isInfoEnabled()) {
|
||||||
LOG.info("Slow KahaDB access: Journal append took: "+(start2-start)+" ms, Index update took "+(end-start2)+" ms");
|
LOG.info("Slow KahaDB access: Journal append took: "+(start2-start)+" ms, Index update took "+(end-start2)+" ms");
|
||||||
}
|
}
|
||||||
|
persistenceAdapterStatistics.addSlowWriteTime(totalTimeMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
persistenceAdapterStatistics.addWriteTime(end - start);
|
persistenceAdapterStatistics.addWriteTime(totalTimeMillis);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
checkpointLock.readLock().unlock();
|
checkpointLock.readLock().unlock();
|
||||||
|
@ -1191,14 +1194,15 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe
|
||||||
public JournalCommand<?> load(Location location) throws IOException {
|
public JournalCommand<?> load(Location location) throws IOException {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
ByteSequence data = journal.read(location);
|
ByteSequence data = journal.read(location);
|
||||||
long end = System.currentTimeMillis();
|
long totalTimeMillis = System.currentTimeMillis() - start;
|
||||||
if( LOG_SLOW_ACCESS_TIME>0 && end-start > LOG_SLOW_ACCESS_TIME) {
|
if( LOG_SLOW_ACCESS_TIME>0 && totalTimeMillis > LOG_SLOW_ACCESS_TIME) {
|
||||||
if (LOG.isInfoEnabled()) {
|
if (LOG.isInfoEnabled()) {
|
||||||
LOG.info("Slow KahaDB access: Journal read took: "+(end-start)+" ms");
|
LOG.info("Slow KahaDB access: Journal read took: "+ totalTimeMillis +" ms");
|
||||||
}
|
}
|
||||||
|
persistenceAdapterStatistics.addSlowReadTime(totalTimeMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
persistenceAdapterStatistics.addReadTime(end - start);
|
persistenceAdapterStatistics.addReadTime(totalTimeMillis);
|
||||||
|
|
||||||
DataByteArrayInputStream is = new DataByteArrayInputStream(data);
|
DataByteArrayInputStream is = new DataByteArrayInputStream(data);
|
||||||
byte readByte = is.readByte();
|
byte readByte = is.readByte();
|
||||||
|
|
Loading…
Reference in New Issue