public class MARSScheduler extends Object
This service differs from standard ScheduledExecutorService
in that it attempts to execute
scheduled tasks at times that are multiples of specified periods (subject to available CPU resources).
As a result stats are gathered and reported at "even" times, including independent stats in separate JVMs.
Modifier and Type | Field and Description |
---|---|
static int |
MARS_DELAY |
static String |
MARS_DELAY_PROPERTY |
Modifier and Type | Method and Description |
---|---|
static void |
cancel(Object o)
Cancels scheduling of specified command or stops watching of specified object.
|
static void |
schedule(Runnable command)
Schedules specified command for execution with default MARS period.
|
static void |
schedule(Runnable command,
long period,
TimeUnit unit)
Schedules specified command for execution with specified period.
|
static void |
watch(Object o,
MARSNode node)
Watches specified object and reports it's
Object.toString() value into specified MARS node
with default MARS period. |
static void |
watchDelta(Number number,
MARSNode node)
Watches specified number and reports it's delta into specified MARS node with default MARS period.
|
static void |
watchSize(Collection<?> c,
MARSNode node)
Watches specified collection and reports it's
size into specified MARS node
with default MARS period. |
static void |
watchTimeRate(Number number,
double multiplier,
int precision,
MARSNode node)
Watches specified number and reports it's rate of change per second into specified MARS node
with default MARS period.
|
public static final String MARS_DELAY_PROPERTY
public static final int MARS_DELAY
public static void schedule(Runnable command)
public static void schedule(Runnable command, long period, TimeUnit unit)
public static void watch(Object o, MARSNode node)
Object.toString()
value into specified MARS node
with default MARS period. This method is suitable both for text values and for numeric values.
Intended use-case is to report value contained in AtomicInteger
or AtomicLong
.
This way atomicity, concurrency and thread-safety are guaranteed with flexibility of value
aggregation policy.
public static void watchSize(Collection<?> c, MARSNode node)
size
into specified MARS node
with default MARS period.
Intended use-case is to report size of some cache or length of some queue.
public static void watchDelta(Number number, MARSNode node)
Intended use-case is to report delta of a value contained in AtomicInteger
or AtomicLong
.
This way atomicity, concurrency and thread-safety are guaranteed with flexibility of value
aggregation policy.
public static void watchTimeRate(Number number, double multiplier, int precision, MARSNode node)
Intended use-case is to report rate of change of a value contained in AtomicInteger
or AtomicLong
.
This way atomicity, concurrency and thread-safety are guaranteed with flexibility of value
aggregation policy.
public static void cancel(Object o)
schedule()
or watchXXX()
methods.
When cancelling previously watched object this method also removes MARS node that was specified.
If specified object was scheduled or watched multiple times, then this method cancels all those tasks.
This method does nothing if specified object was not scheduled or watched.Copyright © 2015 Devexperts. All Rights Reserved.