Interface CustomMeter<T>

Type Parameters:
T - T is a class which implements an interface annotated with MXBean. Getters on this interface define the exposed JMX attributes.
All Superinterfaces:
IpdMeter
All Known Implementing Classes:
CustomMeter.Noop, CustomMeterImpl

public interface CustomMeter<T> extends IpdMeter
Interface representing a custom meter, which is a type of IpdMeter. A custom meter is used to expose custom attributes to JMX and log file through the IPD framework.

You can define custom attributes by creating a class which implements an interface annotated with MXBean. Getters on this interface define the exposed JMX attributes.
Your class implementation must be thread safe.

See example implementations:
IpdConnectionState
IpdLongBucketsCounter
  • Field Details

  • Method Details

    • noopFactory

      static <T> MeterFactory<CustomMeter<T>> noopFactory(CustomMeter.MBeanSupplier<T> mBeanSupplier)
    • getMBeanObject

      T getMBeanObject()
      The returned object holds attribute data that are exposed to JMX. You can update the meter state directly by calling methods on this instance.

      However, any changes made through this instance will bypass enabled checks of this meter.
      Direct updates won't be logged to file when the meter is configured as MeterConfigBuilder.setLogOnUpdate(boolean).

      Do not keep this MBeanObject instance long-term.
      Returns:
      the object that will be exposed to JMX
    • update

      void update(Consumer<T> updater)
      Updates the meter state by calling the updater function. Updater function will be called only when the meter is enabled.

      Updates made through this instance will be logged to file when the meter is configured as MeterConfigBuilder.setLogOnUpdate(boolean).

      Parameters:
      updater - function that updates the meter state