Class PerformanceCounters
- java.lang.Object
-
- edu.caltech.nanodb.server.performance.PerformanceCounters
-
public class PerformanceCounters extends java.lang.Object
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
Fields Modifier and Type Field Description private static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.atomic.AtomicLong>
counters
private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.static java.lang.String
STORAGE_BYTES_READ
static java.lang.String
STORAGE_BYTES_WRITTEN
static java.lang.String
STORAGE_FILE_CHANGES
static java.lang.String
STORAGE_FILE_DISTANCE_TRAVELED
static java.lang.String
STORAGE_PAGES_READ
static java.lang.String
STORAGE_PAGES_WRITTEN
-
Constructor Summary
Constructors Constructor Description PerformanceCounters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
add(java.lang.String counterName, long value)
static long
clear(java.lang.String counterName)
static void
clearAll()
static long
dec(java.lang.String counterName)
static long
get(java.lang.String counterName)
private static java.util.concurrent.atomic.AtomicLong
getCounter(java.lang.String counterName)
static java.util.Set<java.lang.String>
getCounterNames()
static long
inc(java.lang.String counterName)
static long
sub(java.lang.String counterName, long value)
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
STORAGE_FILE_CHANGES
public static final java.lang.String STORAGE_FILE_CHANGES
- See Also:
- Constant Field Values
-
STORAGE_FILE_DISTANCE_TRAVELED
public static final java.lang.String STORAGE_FILE_DISTANCE_TRAVELED
- See Also:
- Constant Field Values
-
STORAGE_PAGES_READ
public static final java.lang.String STORAGE_PAGES_READ
- See Also:
- Constant Field Values
-
STORAGE_PAGES_WRITTEN
public static final java.lang.String STORAGE_PAGES_WRITTEN
- See Also:
- Constant Field Values
-
STORAGE_BYTES_READ
public static final java.lang.String STORAGE_BYTES_READ
- See Also:
- Constant Field Values
-
STORAGE_BYTES_WRITTEN
public static final java.lang.String STORAGE_BYTES_WRITTEN
- See Also:
- Constant Field Values
-
counters
private static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.atomic.AtomicLong> counters
-
-
Method Detail
-
getCounter
private static java.util.concurrent.atomic.AtomicLong getCounter(java.lang.String counterName)
-
inc
public static long inc(java.lang.String counterName)
-
add
public static long add(java.lang.String counterName, long value)
-
dec
public static long dec(java.lang.String counterName)
-
sub
public static long sub(java.lang.String counterName, long value)
-
get
public static long get(java.lang.String counterName)
-
clear
public static long clear(java.lang.String counterName)
-
clearAll
public static void clearAll()
-
getCounterNames
public static java.util.Set<java.lang.String> getCounterNames()
-
-