@ManagedResource public class ApexMetricsTowerControl extends Object implements IApexMetricsTowerControl, org.springframework.beans.factory.InitializingBean
| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.cache.LoadingCache<StartMetricEvent,org.joda.time.LocalDateTime> |
activeTasks
Cache the
StartMetricEvent which have not ended yet. |
protected IApexThreadDumper |
apexThreadDumper |
static int |
CACHE_MAX_SIZE
Do not maintain more than this amount of active tasks
|
static int |
CACHE_TIMEOUT_MINUTES
A
StartMetricEvent event will be discarded if we don't receive its EndMetricEvent event after
this amount of time |
static int |
DEFAULT_LONGRUNNINGCHECK_SECONDS
Frequency at which we check for long tasks
|
protected AtomicLong |
endEventNotReceivedExplicitely |
protected int |
factorForOld
Frequency at which we consider a task is lasting too long.
|
protected int |
factorForTooOld
This is multiplied with factorForOld and longRunningCheckSeconds.
|
protected static org.slf4j.Logger |
LOGGER |
protected ScheduledExecutorService |
logLongRunningES |
protected int |
longRunningCheckSeconds |
static String |
PATH_JOINER
MetricRegistry uses a String as Key.
|
protected AtomicReference<ScheduledFuture<?>> |
scheduledFuture |
protected com.google.common.cache.LoadingCache<StartMetricEvent,StartMetricEvent> |
verySlowTasks |
| Constructor and Description |
|---|
ApexMetricsTowerControl(IApexThreadDumper apexThreadDumper) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
checkForEndEvents() |
protected com.google.common.cache.LoadingCache<StartMetricEvent,org.joda.time.LocalDateTime> |
cleanAndGetActiveTasks() |
protected NavigableMap<Date,String> |
convertToMapDateString(ConcurrentMap<?,org.joda.time.LocalDateTime> asMap) |
NavigableMap<Date,String> |
getActiveTasks() |
long |
getActiveTasksSize() |
String |
getAllThreads(boolean withoutMonitors)
This ThreadDump tends to be faster as by default, it does not collect monitors
|
long |
getEndedBeforeReceivingEndEvent() |
int |
getFactorForOld() |
int |
getFactorForTooOld() |
int |
getLongRunningCheckSeconds() |
long |
getRootActiveTasksSize() |
protected void |
invalidate(StartMetricEvent startEvent) |
boolean |
invalidateActiveTasks(String nameOrStar)
In some cases, we may have ghosts active tasks.
|
protected void |
invalidateStartEvent(StartMetricEvent startEvent) |
protected void |
logLongRunningTasks() |
protected void |
logOnDetectingVeryLongTask(StartMetricEvent startEvent) |
protected void |
logOnEndEvent(StartMetricEvent startEvent) |
protected void |
logOnFarTooMuchLongTask(StartMetricEvent startEvent) |
protected Object |
noNewLine(StartMetricEvent key) |
protected void |
onActiveTaskRemoval(com.google.common.cache.RemovalNotification<StartMetricEvent,org.joda.time.LocalDateTime> removal) |
void |
onEndEvent(EndMetricEvent endEvent) |
void |
onStartEvent(StartMetricEvent startEvent)
It also starts a Timer
|
void |
onThrowable(Throwable t) |
protected void |
scheduleLogLongRunningTasks() |
void |
setDoRememberStack(boolean doRememberStack) |
void |
setFactorForOld(int factorForOld) |
void |
setFactorForTooOld(int factorForTooOld) |
void |
setLongRunningCheckSeconds(int longRunningCheckSeconds) |
protected static final org.slf4j.Logger LOGGER
public static final String PATH_JOINER
public static final int CACHE_TIMEOUT_MINUTES
StartMetricEvent event will be discarded if we don't receive its EndMetricEvent event after
this amount of timepublic static final int CACHE_MAX_SIZE
public static final int DEFAULT_LONGRUNNINGCHECK_SECONDS
protected int longRunningCheckSeconds
protected int factorForOld
protected int factorForTooOld
protected final com.google.common.cache.LoadingCache<StartMetricEvent,org.joda.time.LocalDateTime> activeTasks
StartMetricEvent which have not ended yet.protected final com.google.common.cache.LoadingCache<StartMetricEvent,StartMetricEvent> verySlowTasks
protected final AtomicLong endEventNotReceivedExplicitely
protected final AtomicReference<ScheduledFuture<?>> scheduledFuture
protected final ScheduledExecutorService logLongRunningES
protected final IApexThreadDumper apexThreadDumper
public ApexMetricsTowerControl(IApexThreadDumper apexThreadDumper)
protected void onActiveTaskRemoval(com.google.common.cache.RemovalNotification<StartMetricEvent,org.joda.time.LocalDateTime> removal)
protected void logOnFarTooMuchLongTask(StartMetricEvent startEvent)
protected void logOnDetectingVeryLongTask(StartMetricEvent startEvent)
protected void logOnEndEvent(StartMetricEvent startEvent)
@ManagedAttribute public int getLongRunningCheckSeconds()
getLongRunningCheckSeconds in interface IApexMetricsTowerControl@ManagedAttribute public void setLongRunningCheckSeconds(int longRunningCheckSeconds)
setLongRunningCheckSeconds in interface IApexMetricsTowerControl@ManagedAttribute public int getFactorForOld()
@ManagedAttribute public void setFactorForOld(int factorForOld)
@ManagedAttribute public int getFactorForTooOld()
@ManagedAttribute public void setFactorForTooOld(int factorForTooOld)
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionprotected void scheduleLogLongRunningTasks()
protected void logLongRunningTasks()
protected com.google.common.cache.LoadingCache<StartMetricEvent,org.joda.time.LocalDateTime> cleanAndGetActiveTasks()
protected Object noNewLine(StartMetricEvent key)
public void onStartEvent(StartMetricEvent startEvent)
startEvent - public void onEndEvent(EndMetricEvent endEvent)
endEvent - mark the task associated to this event as completedpublic void onThrowable(Throwable t)
protected void invalidateStartEvent(StartMetricEvent startEvent)
@ManagedAttribute public long getActiveTasksSize()
getActiveTasksSize in interface IApexMetricsTowerControlprotected void checkForEndEvents()
@ManagedAttribute public long getRootActiveTasksSize()
getRootActiveTasksSize in interface IApexMetricsTowerControl@ManagedAttribute public NavigableMap<Date,String> getActiveTasks()
getActiveTasks in interface IApexMetricsTowerControlMap from the start date of the currently running operation, to the name of the operationprotected NavigableMap<Date,String> convertToMapDateString(ConcurrentMap<?,org.joda.time.LocalDateTime> asMap)
@ManagedOperation public boolean invalidateActiveTasks(String nameOrStar)
name - the full name of the activeTask to invalidate. If '*', we cancel all monitor-tasksprotected void invalidate(StartMetricEvent startEvent)
@ManagedOperation public void setDoRememberStack(boolean doRememberStack)
@ManagedOperation public String getAllThreads(boolean withoutMonitors)
withoutMonitors - if true (default JConsole behavior),it skips monitors and synchronizers which is much faster and
prevent freezing the JVM@ManagedAttribute public long getEndedBeforeReceivingEndEvent()
Copyright © 2014–2017 Pivotal Software, Inc.. All rights reserved.