Class PerformanceCounters

java.lang.Object
edu.caltech.nanodb.server.performance.PerformanceCounters

public class PerformanceCounters extends 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 Details

  • Constructor Details

    • PerformanceCounters

      public PerformanceCounters()
  • Method Details

    • getCounter

      private static AtomicLong getCounter(String counterName)
    • inc

      public static long inc(String counterName)
      Increment the specified counter.
      Parameters:
      counterName - the counter to increment
      Returns:
      the value of the counter after incrementing
    • add

      public static long add(String counterName, long value)
      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

      public static long dec(String counterName)
      Decrement the specified counter.
      Parameters:
      counterName - the counter to decrement
      Returns:
      the value of the counter after decrementing
    • sub

      public static long sub(String counterName, long value)
      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

      public static long get(String counterName)
      Retrieve the current value of the specified counter.
      Parameters:
      counterName - the counter to get the value of
      Returns:
      the value of the counter
    • clear

      public static long clear(String counterName)
      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

      public static Set<String> getCounterNames()
      Returns the string names of all counters.
    • dump

      public static void dump()