public class SingleEntryTransactionResourceInterceptor extends Object implements org.aopalliance.intercept.MethodInterceptor
resource managers
for
further processing. The resource managers are called after the method
invocations, but it doesn't matter too much since they are called on a time
frequency basis.
It acts as a sampling tool, but doesn't make any decisions or take any action with regard system or transaction-related resources. All samples are stored against the current transaction. If there is no current transaction then no action will be taken with respect to the resource management.
The default is to activate after 10s and call through every 5s.
This class supports both interceptor-based calling as well as manual calling. Long-running processes can call an this manually on every iteration and get the same behaviour of regular calls to the resouce managers.
The current thread is marked on first entry and all subsequent nested re-entries will just get passed down to the underlying delegate invocation method.
MethodResourceManager
Constructor and Description |
---|
SingleEntryTransactionResourceInterceptor() |
Modifier and Type | Method and Description |
---|---|
Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation) |
void |
performManualCheck(Method calledMethod,
long deltaNs)
An alternative method allowing a manual call to check the resources.
|
void |
setElapsedTimeBeforeActivationMillis(long elapsedTimeBeforeActivationMillis)
Set the minimum number of seconds that a transaction must have been running for
before method sampling begins.
|
void |
setMethodResourceManagers(List<MethodResourceManager> methodResourceManagers)
Set the method-based resource managers that will be notified of the statistics.
|
void |
setResourceManagerCallFrequencyMillis(long resourceManagerCallFrequencyMillis)
Set the approximate time between calls to the
registered resource managers . |
public SingleEntryTransactionResourceInterceptor()
public void setMethodResourceManagers(List<MethodResourceManager> methodResourceManagers)
methodResourceManagers
- a list of resource managers - may be null or emptypublic void setElapsedTimeBeforeActivationMillis(long elapsedTimeBeforeActivationMillis)
elapsedTimeBeforeActivationMillis
- an initial idle time in millisecondspublic void setResourceManagerCallFrequencyMillis(long resourceManagerCallFrequencyMillis)
registered resource managers
. This applies to this instance
of the interceptor and not to the transaction. If a single instance of this
class is used in multiple places, then the resource managers will still only get called at a steady
rate. This is mainly in order to streamline the interception prior to the activation phase, but suits
the resource managers since they get given the exact methods that were called anyway.resourceManagerCallFrequencyMillis
- an approximate time between calls to the resource managerspublic Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
invoke
in interface org.aopalliance.intercept.MethodInterceptor
Throwable
public void performManualCheck(Method calledMethod, long deltaNs)
If you have a loop in a method that doesn't call anything that can be intercepted and handle safely, then get a pre-configured instance (usually from the application context) and mimic the interceptor call.
You should get the Method
, which is used for informational purposes, in a
single call when you calling code is loaded by the classloader. Introspecting every time
you wish to call this method is unnecessary.
calledMethod
- the method that this check applies todeltaNs
- the time in milliseconds that the repeated operation tookCopyright © 2005–2017 Alfresco Software. All rights reserved.