public class Meter extends MeterData implements Closeable
start() to produce a 1-line summary
about operation start and current system status as debug message and an encoded event as trace message. Call ok() to produce a 1-line summary about
operation successful end and current system status as information message and an encoded event as trace message. Call fail(Object) to produce a
1-line summary about operation failure and current system status as error message and an encoded event as trace message. Call progress() to produce
a 1-line summary about operation progress and current system status as information message and an encoded event as trace message.| Modifier and Type | Class and Description |
|---|---|
static class |
Meter.IllegalMeterUsage |
static class |
Meter.MeterThrowable |
| Modifier and Type | Field and Description |
|---|---|
static String |
CONTEXT_RESULT |
category, context, createTime, currentIteration, description, DETAILED_MESSAGE_PREFIX, EVENT_CATEGORY, EVENT_NAME, EVENT_PARENT, expectedIterations, failMessage, failPath, okPath, operation, parent, PROP_CONTEXT, PROP_CREATE_TIME, PROP_DESCRIPTION, PROP_EXPECTED_ITERATION, PROP_FAIL_ID, PROP_ITERATION, PROP_LIMIT_TIME, PROP_PATH_ID, PROP_REJECT_ID, PROP_START_TIME, PROP_STOP_TIME, rejectPath, startTime, stopTime, timeLimitclassLoading_loaded, classLoading_total, classLoading_unloaded, compilationTime, garbageCollector_count, garbageCollector_time, heap_commited, heap_max, heap_used, nonHeap_commited, nonHeap_max, nonHeap_used, objectPendingFinalizationCount, PROP_CLASS_LOADING, PROP_COMPILATION_TIME, PROP_FINALIZATION_COUNT, PROP_GARBAGE_COLLECTOR, PROP_HEAP, PROP_MEMORY, PROP_NON_HEAP, PROP_SYSTEM_LOAD, runtime_maxMemory, runtime_totalMemory, runtime_usedMemory, systemLoadEVENT_POSITION, EVENT_TIME, position, SESSION_UUID, sessionUuid, time| Constructor and Description |
|---|
Meter(org.slf4j.Logger logger)
Creates a new meter for the category given by the logger's name.
|
Meter(org.slf4j.Logger logger,
String operation)
Creates a new Meter for the operation beloging to the category given by the logger's name.
|
Meter(org.slf4j.Logger logger,
String operation,
String parent)
Creates a new Meter for the operation beloging to the category given by the logger's name, as child for an existing Meter.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
call(Callable<T> callable) |
<T> T |
callOrReject(Callable<T> callable,
Class<? extends Exception>... exceptionsToReject) |
<T> T |
callOrRejectChecked(Callable<T> callable) |
void |
close()
Compliance with
Closeable. |
Meter |
ctx(boolean condition,
String trueName)
Adds an entry to the context map if conditions is true.
|
Meter |
ctx(boolean condition,
String trueName,
String falseName)
Adds an entry to the context map if conditions is true or false.
|
Meter |
ctx(String name)
Adds an entry to the context map.
|
Meter |
ctx(String name,
boolean value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Boolean value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
double value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Double value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
float value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Float value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
int value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Integer value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
long value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Long value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
Object object)
Adds an entry to the context map.
|
Meter |
ctx(String name,
String value)
Adds an entry to the context map.
|
Meter |
ctx(String name,
String format,
Object... args)
Adds an entry to the context map.
|
Meter |
fail(Object cause)
Refuses the meter in order to claim incomplete or inconsistent execution of the task represented by the meter.
|
protected void |
finalize()
Checks if meters the meter has been forgotten to be confirmed or refused.
|
static Meter |
getCurrentInstance() |
Meter |
inc()
Notifies the meter that one more iteration or step completed that make up the task successfully.
|
Meter |
incBy(long increment)
Notifies the meter that more of iterations or steps that make up the task completed successfully.
|
Meter |
incTo(long currentIteration)
Notifies the meter that a number of iterations or steps that make up the task already completed successfully.
|
Meter |
iterations(long expectedIterations)
Configures the Meter for an operation made up of iterations or steps.
|
Meter |
limitMilliseconds(long timeLimit)
Configures the Meter with an threshold for reasonable, typical execution time for the operation.
|
Meter |
m(String message)
Configures the Meter with a human readable message that explains the operations's purpose.
|
Meter |
m(String format,
Object... args)
Configures the Meter with a human readable message that explains the operations's purpose.
|
Meter |
ok()
Confirms the meter in order to claim successful completion of the task represented by the meter.
|
Meter |
ok(Object pathId)
Confirms the meter in order to claim successful completion of the task represented by the meter.
|
Meter |
path(Object pathId) |
Meter |
progress()
Allow informing about successful completion of iterations or steps making up the task represented by the meter.
|
Meter |
reject(Object cause)
Confirms the meter in order to claim unsuccessful completion of the task represented by the meter.
|
void |
run(Runnable runnable) |
void |
runOrReject(Runnable runnable,
Class<? extends Exception>... exceptionsToReject) |
<T> T |
safeCall(Callable<T> callable) |
<E extends RuntimeException,T> |
safeCall(Class<E> exceptionClass,
Callable<T> callable) |
Meter |
start()
Notifies the meter in order to claim immediate execution start of the task represented by the meter.
|
Meter |
sub(String suboperationName)
Creates a new Meter for an operation that belongs to the opeartion of this Meter.
|
Meter |
unctx(String name)
Removes an entry from the context map.
|
collectRuntimeStatus, equals, getContext, getExecutionTime, getFullID, getIterationsPerSecond, getPath, getWaitingTime, hashCode, isFail, isOK, isReject, isSlow, isStarted, isStopped, readableStringBuilder, resetImpl, writeJson5ImplcollectManagedBeanStatus, collectPlatformStatus, readJson5encodedMessage, json5Message, readableMessage, reset, writeJson5public static final String CONTEXT_RESULT
public Meter(org.slf4j.Logger logger)
logger - Logger that reports messages.public Meter(org.slf4j.Logger logger,
String operation)
logger - Logger that reports messages.operation - The operation name or null.public Meter(org.slf4j.Logger logger,
String operation,
String parent)
logger - Logger that reports messages.operation - The operation name or null.parent - ID of the parent Meter or null.public static Meter getCurrentInstance()
public Meter sub(String suboperationName)
suboperationName - Additional identification appended to this logger name.public Meter m(String message)
message - fixed messagepublic Meter m(String format, Object... args)
format - message format (String.format(java.lang.String, java.lang.Object...))args - message argumentspublic Meter limitMilliseconds(long timeLimit)
timeLimit - time thresholdpublic Meter iterations(long expectedIterations)
progress() an arbitrarily number of Such
Meter should call inc(), incBy(long) or incTo(long) to advance the current iteration. times between start() and
ok()/reject(Object)/fail(Object) method calls.expectedIterations - Number of expected iterations or steps that make up the taskpublic Meter ctx(String name)
name - key of the entry to add.public Meter ctx(boolean condition, String trueName)
condition - the conditiontrueName - key of the entry to add if conditions is truepublic Meter ctx(boolean condition, String trueName, String falseName)
condition - the conditiontrueName - key of the entry to add if conditions is truefalseName - key of the entry to add if conditions is truepublic Meter ctx(String name, int value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, long value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, boolean value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, float value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, double value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Integer value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Long value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Boolean value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Float value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Double value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, Object object)
name - key of the entry to add.object - object which string representation is used for the value of the entry to addpublic Meter ctx(String name, String value)
name - key of the entry to add.value - value of the entry to add.public Meter ctx(String name, String format, Object... args)
name - key of the entry to add.format - message format (String.format(java.lang.String, java.lang.Object...))args - message argumentspublic Meter unctx(String name)
name - key of the entry to remove.public Meter start()
public Meter inc()
public Meter incBy(long increment)
increment - the number of iterations or stepspublic Meter incTo(long currentIteration)
currentIteration - the number of iterations or stepspublic Meter progress()
iterations(long i) before calling start(). Sends a message to logger using info level, only periodically and if progress was observed,
to minimize performance degradation.public Meter ok()
public Meter ok(Object pathId)
pathId - A token, enum or exception that describes the successful pathId.public Meter reject(Object cause)
cause - A token, enum or exception that describes the cause of rejection.public Meter fail(Object cause)
cause - Exception that represents the failure. May be null if no exception applies.protected void finalize()
throws Throwable
checkCurrentInstance() are not considered for check.public void close()
Closeable. Assumes failure and refuses the meter if the meter has not yet been marked as confirmed.close in interface Closeableclose in interface AutoCloseablepublic void run(Runnable runnable)
public void runOrReject(Runnable runnable, Class<? extends Exception>... exceptionsToReject)
public <T> T callOrRejectChecked(Callable<T> callable)
public <T> T callOrReject(Callable<T> callable, Class<? extends Exception>... exceptionsToReject)
public <T> T safeCall(Callable<T> callable)
public <E extends RuntimeException,T> T safeCall(Class<E> exceptionClass, Callable<T> callable)
Copyright © 2010–2025. All rights reserved.