public class Meter extends MeterData implements java.io.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(Throwable)
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 |
static class |
Meter.TryWithResourcesFailed |
context, createTime, description, DETAILED_MESSAGE_PREFIX, expectedIterations, failClass, failMessage, iteration, pathId, 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, PROP_THREAD, rejectId, startTime, stopTime, timeLimitNanoseconds
classLoading_loaded, classLoading_total, classLoading_unloaded, compilationTime, garbageCollector_count, garbageCollector_time, heap_commited, heap_max, heap_used, nonHeap_commited, nonHeap_max, nonHeap_used, objectPendingFinalizationCount, runtime_maxMemory, runtime_totalMemory, runtime_usedMemory, systemLoad
EVENT_CATEGORY, EVENT_NAME, EVENT_POSITION, eventCategory, eventName, eventPosition, SESSION_UUID, sessionUuid, time
Constructor and Description |
---|
Meter(org.slf4j.Logger logger)
Creates a new meter.
|
Meter(org.slf4j.Logger logger,
java.lang.String operationName)
Creates a new meter.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
call(java.util.concurrent.Callable<T> callable) |
boolean |
checkCurrentInstance() |
void |
close()
Compliance with
Closeable . |
Meter |
ctx(boolean condition,
java.lang.String trueName)
Adds an entry to the context map if conditions is true.
|
Meter |
ctx(boolean condition,
java.lang.String trueName,
java.lang.String falseName)
Adds an entry to the context map if conditions is true or false.
|
Meter |
ctx(java.lang.String name)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
boolean value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Boolean value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
double value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Double value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
float value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Float value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
int value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Integer value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
long value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Long value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.Object object)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.String value)
Adds an entry to the context map.
|
Meter |
ctx(java.lang.String name,
java.lang.String format,
java.lang.Object... args)
Adds an entry to the context map.
|
Meter |
fail(java.lang.Throwable 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.
|
Meter |
flow(java.lang.Object flow)
Deprecated.
|
static Meter |
getCurrentInstance() |
org.slf4j.Logger |
getLogger() |
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 as representing a task made up of iterations or steps.
|
Meter |
limitMilliseconds(long timeLimitMilliseconds)
Configures the meter with an threshold for reasonable, typical execution time for the task represented by the meter.
|
Meter |
m(java.lang.String message)
Configures the meter with a human readable message that explains the task's purpose.
|
Meter |
m(java.lang.String format,
java.lang.Object... args)
Configures the meter with a human readable message that explains the task's purpose.
|
Meter |
ok()
Confirms the meter in order to claim successful completion of the task represented by the meter.
|
Meter |
ok(java.lang.Object pathId)
Confirms the meter in order to claim successful completion of the task represented by the meter.
|
Meter |
path(java.lang.Object pathId) |
Meter |
progress()
Allow informing about successful completion of iterations or steps making up the task represented by the meter.
|
Meter |
reject(java.lang.Object cause)
Confirms the meter in order to claim unsuccessful completion of the task represented by the meter.
|
void |
run(java.lang.Runnable runnable) |
<T> T |
safeCall(java.util.concurrent.Callable<T> callable) |
<E extends java.lang.RuntimeException,T> |
safeCall(java.lang.Class<E> exceptionClass,
java.util.concurrent.Callable<T> callable) |
Meter |
start()
Notifies the meter in order to claim immediate execution start of the task represented by the meter.
|
Meter |
sub(java.lang.String suboperationName)
Creates a new Meter whose name is under the hierarchy of this meter.
|
Meter |
unctx(java.lang.String name)
Removes an entry from the context map.
|
getContext, getCreateTime, getCurrentIteration, getDescription, getExceptionClass, getExceptionMessage, getExecutionTime, getExpectedIterations, getIterationsPerSecond, getPathId, getRejectId, getStartTime, getStopTime, getTimeLimitNanoseconds, getWaitingTime, isCompletelyEqualsImpl, isFail, isOK, isReject, isSlow, isStarted, isStopped, read, readableString, readableWrite, readPropertyImpl, resetImpl, write, writePropertiesImpl
collectManagedBeanStatus, collectPlatformStatus, collectRuntimeStatus
equals, getEventCategory, getEventName, getEventPosition, getFullID, getSessionUuid, getTime, hashCode, isCompletelyEqualsTo, isSameAs, read, reset, toString, write
public Meter(org.slf4j.Logger logger)
logger
- Logger that reports messages.public Meter(org.slf4j.Logger logger, java.lang.String operationName)
logger
- Logger that reports messages.operationName
- Additional identification to distinguish operations reported on the same logger.public static Meter getCurrentInstance()
public org.slf4j.Logger getLogger()
public Meter sub(java.lang.String suboperationName)
suboperationName
- Additional identification appended to this logger name.public Meter m(java.lang.String message)
message
- fixed messagepublic Meter m(java.lang.String format, java.lang.Object... args)
format
- message format (String.format(java.lang.String, java.lang.Object...)
)args
- message argumentspublic Meter limitMilliseconds(long timeLimitMilliseconds)
timeLimitMilliseconds
- time thresholdpublic Meter iterations(long expectedIterations)
progress()
an arbitrarily number of times between start()
and ok()
/fail(java.lang.Throwable)
method calls.expectedIterations
- Number of expected iterations or steps that make up the taskpublic Meter ctx(java.lang.String name)
name
- key of the entry to add.public Meter ctx(boolean condition, java.lang.String trueName)
condition
- the conditiontrueName
- key of the entry to add if conditions is truepublic Meter ctx(boolean condition, java.lang.String trueName, java.lang.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(java.lang.String name, int value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, long value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, boolean value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, float value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, double value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.Integer value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.Long value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.Boolean value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.Float value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.Double value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.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(java.lang.String name, java.lang.String value)
name
- key of the entry to add.value
- value of the entry to add.public Meter ctx(java.lang.String name, java.lang.String format, java.lang.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(java.lang.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.@Deprecated public Meter flow(java.lang.Object flow)
public Meter path(java.lang.Object pathId)
public Meter ok()
public boolean checkCurrentInstance()
public Meter ok(java.lang.Object pathId)
pathId
- A token, enum or exception that describes the successful pathId.public Meter reject(java.lang.Object cause)
cause
- A token, enum or exception that describes the cause of rejection.public Meter fail(java.lang.Throwable cause)
cause
- Exception that represents the failure. May be null if no exception applies.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void close()
Closeable
. Assumes failure and refuses the meter if the meter has not yet been marked as confirmed.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void run(java.lang.Runnable runnable)
public <T> T call(java.util.concurrent.Callable<T> callable) throws java.lang.Exception
java.lang.Exception
public <T> T safeCall(java.util.concurrent.Callable<T> callable)
public <E extends java.lang.RuntimeException,T> T safeCall(java.lang.Class<E> exceptionClass, java.util.concurrent.Callable<T> callable)