Class PerformanceCounters
java.lang.Object
edu.caltech.nanodb.server.performance.PerformanceCounters
This class provides a basic performance-counter mechanism that can be used
concurrently from many different threads. It allows us to record
performance statistics from the database, and ultimately to expose them
through SQL queries as well.
- Code Review:
- (Donnie) I really don't like that this is a static class, because it prevents us from having multiple sets of performance counters. This is just the easiest way to add counters to NanoDB in the short run. In the future, make this non-static, and maybe stick an instance of it on the NanoDB Server object. We can put it into thread-local storage to make it easy to access.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprivate static ConcurrentHashMap<String, AtomicLong> private static org.apache.logging.log4j.LoggerA logging object for reporting anything interesting that happens.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longAdd a value to the specified counter.static longClear the value of the specified counter.static voidclearAll()Clear the values of all counters.static longDecrement the specified counter.static voiddump()static longRetrieve the current value of the specified counter.private static AtomicLonggetCounter(String counterName) Returns the string names of all counters.static longIncrement the specified counter.static longSubtract a value from the specified counter.
-
Field Details
-
logger
private static org.apache.logging.log4j.Logger loggerA logging object for reporting anything interesting that happens. -
BUFMGR_PAGE_HITS
- See Also:
-
BUFMGR_PAGE_MISSES
- See Also:
-
STORAGE_FILE_CHANGES
- See Also:
-
STORAGE_FILE_DISTANCE_TRAVELED
- See Also:
-
STORAGE_PAGES_READ
- See Also:
-
STORAGE_PAGES_WRITTEN
- See Also:
-
STORAGE_BYTES_READ
- See Also:
-
STORAGE_BYTES_WRITTEN
- See Also:
-
counters
-
-
Constructor Details
-
PerformanceCounters
public PerformanceCounters()
-
-
Method Details
-
getCounter
-
inc
Increment the specified counter.- Parameters:
counterName- the counter to increment- Returns:
- the value of the counter after incrementing
-
add
Add a value to the specified counter.- Parameters:
counterName- the counter to add the value to- Returns:
- the value of the counter after adding the value
-
dec
Decrement the specified counter.- Parameters:
counterName- the counter to decrement- Returns:
- the value of the counter after decrementing
-
sub
Subtract a value from the specified counter.- Parameters:
counterName- the counter to subtract the value from- Returns:
- the value of the counter after subtracting the value
-
get
Retrieve the current value of the specified counter.- Parameters:
counterName- the counter to get the value of- Returns:
- the value of the counter
-
clear
Clear the value of the specified counter. The old value is returned.- Parameters:
counterName- the counter to clear- Returns:
- the old value of the counter
-
clearAll
public static void clearAll()Clear the values of all counters. -
getCounterNames
Returns the string names of all counters. -
dump
public static void dump()
-