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 AutoFetchManager
public void clearQueryStatistics()
AutoFetchManager
clearQueryStatistics
in interface AutoFetchManager
public int getTotalTunedQueryCount()
getTotalTunedQueryCount
in interface AutoFetchManager
public int getTotalTunedQuerySize()
getTotalTunedQuerySize
in interface AutoFetchManager
public int getTotalProfileSize()
getTotalProfileSize
in interface AutoFetchManager
public int clearTunedQueryInfo()
AutoFetchManager
Should only need do this for testing and playing around.
clearTunedQueryInfo
in interface AutoFetchManager
public int clearProfilingInfo()
AutoFetchManager
This means the profiling information will need to be re-gathered.
Should only need do this for testing and playing around.
clearProfilingInfo
in interface AutoFetchManager
public void serialize()
public TunedQueryInfo getTunedQueryInfo(String originKey)
getTunedQueryInfo
in interface AutoFetchManager
public Statistics getStatistics(String originKey)
getStatistics
in interface AutoFetchManager
public Iterator<TunedQueryInfo> iterateTunedQueryInfo()
AutoFetchManager
This should be a read only iteration.
iterateTunedQueryInfo
in interface AutoFetchManager
public Iterator<Statistics> iterateStatistics()
AutoFetchManager
This should be a read only iteration.
iterateStatistics
in interface AutoFetchManager
public boolean isProfiling()
AutoFetchManager
isProfiling
in interface AutoFetchManager
public void setProfiling(boolean profiling)
setProfiling
in interface AutoFetchManager
public boolean isQueryTuning()
AutoFetchManager
isQueryTuning
in interface AutoFetchManager
public void setQueryTuning(boolean queryTuning)
AutoFetchManager
setQueryTuning
in interface AutoFetchManager
public double getProfilingRate()
AutoFetchManager
getProfilingRate
in interface AutoFetchManager
public AutofetchMode getMode()
AutoFetchManager
Query#setAutoFetch(boolean)
.getMode
in interface AutoFetchManager
public void setMode(AutofetchMode mode)
AutoFetchManager
Query#setAutoFetch(boolean)
.setMode
in interface AutoFetchManager
public void setProfilingRate(double rate)
AutoFetchManager
setProfilingRate
in interface AutoFetchManager
public int getProfilingBase()
AutoFetchManager
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.
getProfilingBase
in interface AutoFetchManager
public void setProfilingBase(int profilingBase)
AutoFetchManager
This number should provide a level of confidence that no more profiling is required for this query point.
setProfilingBase
in interface AutoFetchManager
public int getProfilingMin()
AutoFetchManager
This could be one which means start autoFetch tuning after the first profiling information is collected.
getProfilingMin
in interface AutoFetchManager
public void setProfilingMin(int profilingMin)
AutoFetchManager
Increasing this number will mean more profiling is collected before autoFetch starts tuning the query.
setProfilingMin
in interface AutoFetchManager
public 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 AutoFetchManager
public 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 AutoFetchManager
public String updateTunedQueryInfo()
updateTunedQueryInfo
in interface AutoFetchManager
public boolean tuneQuery(SpiQuery<?> query)
tuneQuery
in interface AutoFetchManager
public void collectQueryInfo(ObjectGraphNode node, long beans, long micros)
collectQueryInfo
in interface AutoFetchManager
node
- 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 NodeUsageListener
Copyright © 2015. All Rights Reserved.