public interface AutoFetchManager extends NodeUsageListener
The profile information is periodically converted into "tuned query details" - which is used to automatically tune the queries that use autoFetch.
The "tuned query details" effectively are part of the query that has the select() and join() information (but not the where clause, order by, limits etc). These are applied to the query when tuneQuery() is called.
Modifier and Type | Method and Description |
---|---|
int |
clearProfilingInfo()
Clear all the profiling information.
|
void |
clearQueryStatistics()
Clear the query execution statistics.
|
int |
clearTunedQueryInfo()
Clear all the tuned query info.
|
void |
collectQueryInfo(ObjectGraphNode node,
long beans,
long micros)
Collect query profiling information.
|
String |
collectUsageViaGC(long waitMillis)
Fire a garbage collection (hint to the JVM).
|
AutofetchMode |
getMode()
This controls whether autoFetch is used when it has not been explicitly
set on a query via
Query#setAutoFetch(boolean) . |
int |
getProfilingBase()
Return the max number of queries profiled (per query point).
|
int |
getProfilingMin()
Return the minimum number of queries profiled before autoFetch will start
automatically tuning the queries.
|
double |
getProfilingRate()
Return the profiling rate (int between 0 and 100).
|
Statistics |
getStatistics(String queryPointKey)
Return the current Statistics for a given queryPoint key.
|
int |
getTotalProfileSize()
Return the size of the profile map.
|
int |
getTotalTunedQueryCount()
Return the number of queries tuned by AutoFetch.
|
int |
getTotalTunedQuerySize()
Return the size of the TuneQuery map.
|
TunedQueryInfo |
getTunedQueryInfo(String queryPointKey)
Return the current tuned fetch information for a given queryPoint key.
|
boolean |
isProfiling()
Return true if profiling is enabled.
|
boolean |
isQueryTuning()
Return true if automatic query tuning is enabled.
|
Iterator<Statistics> |
iterateStatistics()
Iterate the node usage statistics.
|
Iterator<TunedQueryInfo> |
iterateTunedQueryInfo()
Iterate the tuned fetch info.
|
void |
setMode(AutofetchMode Mode)
Set the auto fetch mode used when a query has not had
Query#setAutoFetch(boolean) . |
void |
setOwner(SpiEbeanServer server,
ServerConfig serverConfig)
Set the owning ebean server.
|
void |
setProfiling(boolean enable)
Set to true to enable profiling.
|
void |
setProfilingBase(int profilingMax)
Set a max number of queries to profile per query point.
|
void |
setProfilingMin(int autoFetchMinThreshold)
Set the minimum number of queries profiled per query point before
autoFetch will automatically tune the queries.
|
void |
setProfilingRate(double rate)
Set the profiling rate (int between 0 and 100).
|
void |
setQueryTuning(boolean enable)
Set to true to enable automatic query tuning.
|
void |
shutdown()
On shutdown fire garbage collection and collect statistics.
|
boolean |
tuneQuery(SpiQuery<?> query)
Called when a query thinks it should be automatically tuned by autoFetch.
|
String |
updateTunedQueryInfo()
This will take the current profiling information and update the "tuned
query detail".
|
collectNodeUsage
void setOwner(SpiEbeanServer server, ServerConfig serverConfig)
void clearQueryStatistics()
int clearTunedQueryInfo()
Should only need do this for testing and playing around.
int clearProfilingInfo()
This means the profiling information will need to be re-gathered.
Should only need do this for testing and playing around.
void shutdown()
TunedQueryInfo getTunedQueryInfo(String queryPointKey)
Statistics getStatistics(String queryPointKey)
Iterator<TunedQueryInfo> iterateTunedQueryInfo()
This should be a read only iteration.
Iterator<Statistics> iterateStatistics()
This should be a read only iteration.
boolean isProfiling()
void setProfiling(boolean enable)
We rely on garbage collection to collect the profiling information. This means there is a unknown delay between when a query is executed and when we actually collect the usage profile information.
Due to this garbage collection delay, when turning off profiling while the application is running you should consider calling collectUsageViaGC() BEFORE setProfiling(false). This hints to the JVM to perform garbage collection, and hopefully collects the profiling information.
boolean isQueryTuning()
void setQueryTuning(boolean enable)
AutofetchMode getMode()
Query#setAutoFetch(boolean)
.void setMode(AutofetchMode Mode)
Query#setAutoFetch(boolean)
.double getProfilingRate()
void setProfilingRate(double rate)
int getProfilingBase()
The number of queries profiled is collected per query point. Once a query point has profiled this number of queries it does not profile any more.
void setProfilingBase(int profilingMax)
This number should provide a level of confidence that no more profiling is required for this query point.
int getProfilingMin()
This could be one which means start autoFetch tuning after the first profiling information is collected.
void setProfilingMin(int autoFetchMinThreshold)
Increasing this number will mean more profiling is collected before autoFetch starts tuning the query.
String collectUsageViaGC(long waitMillis)
String updateTunedQueryInfo()
This is done periodically and can also be manually invoked.
This returns a string summary of the updates that occurred.
boolean tuneQuery(SpiQuery<?> query)
This internally checks that autoFetch is enabled, there is a "tuned query detail" to tune the query with and that the autoFetchMinThreshold has been reached.
This will also determine if the query should be profiled.
void collectQueryInfo(ObjectGraphNode node, long beans, long micros)
This is for the original query as well as any subsequent lazy loading queries that are required as the object graph is traversed.
node
- the node path in the object graph.beans
- the number of beans loaded by the query.micros
- the query executing time in microsecondsint getTotalTunedQueryCount()
int getTotalTunedQuerySize()
int getTotalProfileSize()
Copyright © 2015. All Rights Reserved.