public class DefaultAutoFetchManager extends Object implements AutoFetchManager, Serializable
| Constructor and Description |
|---|
DefaultAutoFetchManager(String fileName) |
| 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 |
collectNodeUsage(NodeUsageCollector usageCollector)
Collect usage statistics from a node in the object graph.
|
void |
collectQueryInfo(ObjectGraphNode node,
long beans,
long micros)
Gather query execution statistics.
|
String |
collectUsageViaGC(long waitMillis)
Ask for a System.gc() so that we gather node usage information.
|
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 originKey)
Return the current Statistics for a given originKey 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 originKey)
Return the current Tuned query info for a given origin 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 |
serialize() |
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 up this profile listener before it is active.
|
void |
setProfiling(boolean profiling)
When the application is running, BEFORE turning off profiling you
probably should call collectUsageViaGC() as there is a delay (waiting for
garbage collection) collecting usage profiling information.
|
void |
setProfilingBase(int profilingBase)
Set a max number of queries to profile per query point.
|
void |
setProfilingMin(int profilingMin)
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 queryTuning)
Set to true to enable automatic query tuning.
|
void |
shutdown()
Shutdown the listener.
|
String |
toString() |
boolean |
tuneQuery(SpiQuery<?> query)
Auto tune the query and enable profiling.
|
String |
updateTunedQueryInfo()
Update the tuned fetch plans from the current usage information.
|
public DefaultAutoFetchManager(String fileName)
public void setOwner(SpiEbeanServer server, ServerConfig serverConfig)
setOwner in interface AutoFetchManagerpublic void clearQueryStatistics()
AutoFetchManagerclearQueryStatistics in interface AutoFetchManagerpublic int getTotalTunedQueryCount()
getTotalTunedQueryCount in interface AutoFetchManagerpublic int getTotalTunedQuerySize()
getTotalTunedQuerySize in interface AutoFetchManagerpublic int getTotalProfileSize()
getTotalProfileSize in interface AutoFetchManagerpublic int clearTunedQueryInfo()
AutoFetchManagerShould only need do this for testing and playing around.
clearTunedQueryInfo in interface AutoFetchManagerpublic int clearProfilingInfo()
AutoFetchManagerThis means the profiling information will need to be re-gathered.
Should only need do this for testing and playing around.
clearProfilingInfo in interface AutoFetchManagerpublic void serialize()
public TunedQueryInfo getTunedQueryInfo(String originKey)
getTunedQueryInfo in interface AutoFetchManagerpublic Statistics getStatistics(String originKey)
getStatistics in interface AutoFetchManagerpublic Iterator<TunedQueryInfo> iterateTunedQueryInfo()
AutoFetchManagerThis should be a read only iteration.
iterateTunedQueryInfo in interface AutoFetchManagerpublic Iterator<Statistics> iterateStatistics()
AutoFetchManagerThis should be a read only iteration.
iterateStatistics in interface AutoFetchManagerpublic boolean isProfiling()
AutoFetchManagerisProfiling in interface AutoFetchManagerpublic void setProfiling(boolean profiling)
setProfiling in interface AutoFetchManagerpublic boolean isQueryTuning()
AutoFetchManagerisQueryTuning in interface AutoFetchManagerpublic void setQueryTuning(boolean queryTuning)
AutoFetchManagersetQueryTuning in interface AutoFetchManagerpublic double getProfilingRate()
AutoFetchManagergetProfilingRate in interface AutoFetchManagerpublic AutofetchMode getMode()
AutoFetchManagerQuery#setAutoFetch(boolean).getMode in interface AutoFetchManagerpublic void setMode(AutofetchMode mode)
AutoFetchManagerQuery#setAutoFetch(boolean).setMode in interface AutoFetchManagerpublic void setProfilingRate(double rate)
AutoFetchManagersetProfilingRate in interface AutoFetchManagerpublic int getProfilingBase()
AutoFetchManagerThe 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.
getProfilingBase in interface AutoFetchManagerpublic void setProfilingBase(int profilingBase)
AutoFetchManagerThis number should provide a level of confidence that no more profiling is required for this query point.
setProfilingBase in interface AutoFetchManagerpublic int getProfilingMin()
AutoFetchManagerThis could be one which means start autoFetch tuning after the first profiling information is collected.
getProfilingMin in interface AutoFetchManagerpublic void setProfilingMin(int profilingMin)
AutoFetchManagerIncreasing this number will mean more profiling is collected before autoFetch starts tuning the query.
setProfilingMin in interface AutoFetchManagerpublic void shutdown()
We should try to collect the usage statistics by calling a System.gc(). This is necessary for use with short lived applications where garbage collection may not otherwise occur at all.
shutdown in interface AutoFetchManagerpublic String collectUsageViaGC(long waitMillis)
Really only want to do this sparingly but useful just prior to shutdown for short run application where garbage collection may otherwise not occur at all.
waitMillis will do a thread sleep to give the garbage collection a little time to do its thing assuming we are shutting down the VM.
If waitMillis is -1 then the defaultGarbageCollectionWait is used which defaults to 100 milliseconds.
collectUsageViaGC in interface AutoFetchManagerpublic String updateTunedQueryInfo()
updateTunedQueryInfo in interface AutoFetchManagerpublic boolean tuneQuery(SpiQuery<?> query)
tuneQuery in interface AutoFetchManagerpublic void collectQueryInfo(ObjectGraphNode node, long beans, long micros)
collectQueryInfo in interface AutoFetchManagernode - the node path in the object graph.beans - the number of beans loaded by the query.micros - the query executing time in microsecondspublic void collectNodeUsage(NodeUsageCollector usageCollector)
This is sent to use from a EntityBeanIntercept when the finalise method is called on the bean.
collectNodeUsage in interface NodeUsageListenerCopyright © 2014. All Rights Reserved.