mirror of
https://github.com/apache/openjpa.git
synced 2025-02-08 02:59:42 +00:00
OPENJPA-1566: Allow access to keys of the statistics.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@922311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f04031edc1
commit
732ff354b3
@ -23,6 +23,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records query execution statistics.
|
* Records query execution statistics.
|
||||||
@ -38,6 +39,11 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface QueryStatistics<T> extends Serializable {
|
public interface QueryStatistics<T> extends Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the identifier keys for the cached queries.
|
||||||
|
*/
|
||||||
|
public Set<T> keys();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record that the given query has been executed.
|
* Record that the given query has been executed.
|
||||||
@ -126,6 +132,10 @@ public interface QueryStatistics<T> extends Serializable {
|
|||||||
private Map<T, long[]> astats = new HashMap<T, long[]>();
|
private Map<T, long[]> astats = new HashMap<T, long[]>();
|
||||||
private Date start = new Date();
|
private Date start = new Date();
|
||||||
private Date since = start;
|
private Date since = start;
|
||||||
|
|
||||||
|
public Set<T> keys() {
|
||||||
|
return stats.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
public long getExecutionCount() {
|
public long getExecutionCount() {
|
||||||
return stat[READ];
|
return stat[READ];
|
||||||
@ -205,6 +215,8 @@ public interface QueryStatistics<T> extends Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void recordExecution(T query) {
|
public void recordExecution(T query) {
|
||||||
|
if (query == null)
|
||||||
|
return;
|
||||||
boolean cached = (astats.containsKey(query));
|
boolean cached = (astats.containsKey(query));
|
||||||
addSample(query, READ);
|
addSample(query, READ);
|
||||||
if (cached)
|
if (cached)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user