Class CustomMeterImpl<T>

java.lang.Object
com.atlassian.diagnostics.ipd.api.meters.AbstractIpdMeter
com.atlassian.diagnostics.ipd.api.meters.custom.CustomMeterImpl<T>
All Implemented Interfaces:
CustomMeter<T>, IpdMeter

public class CustomMeterImpl<T> extends AbstractIpdMeter implements CustomMeter<T>
  • Constructor Details

    • CustomMeterImpl

      protected CustomMeterImpl(MeterConfig config, T mBean)
    • CustomMeterImpl

      protected CustomMeterImpl(MeterConfig config, T mBean, MBeanServer mBeanServer)
  • Method Details

    • getMBeanObject

      public T getMBeanObject()
      Description copied from interface: CustomMeter
      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.
      Specified by:
      getMBeanObject in interface CustomMeter<T>
      Returns:
      the object that will be exposed to JMX
    • getAttributes

      public Map<String,Object> getAttributes(boolean extraAttributes)
      Description copied from interface: IpdMeter
      Returns the attributes of the meter.
      Specified by:
      getAttributes in interface IpdMeter
      Parameters:
      extraAttributes - if true, all attributes visible in JMX will be returned, otherwise only the most important ones
      Returns:
      Map of meter attributes, will return empty map if attributes can't be retrieved
    • isVisible

      public boolean isVisible()
      Description copied from interface: IpdMeter
      Meter might be enabled, but temporarily hidden in JMX. This might happen when meter value was not set yet or method IpdMeter.hideUntilUpdate() was called.
      Specified by:
      isVisible in interface IpdMeter
      Returns:
      true if the meter is visible in JMX, false otherwise
    • registerMBean

      protected void registerMBean()
      Description copied from class: AbstractIpdMeter
      Registers the MBean in the MBeanServer.
      Method will be called when the meter is enabled and is visible in JMX.
      Specified by:
      registerMBean in class AbstractIpdMeter
    • unregisterMBean

      protected void unregisterMBean()
      Description copied from class: AbstractIpdMeter
      Unregisters the MBean from the MBeanServer.
      Method will be called when the meter is closed or is hidden from JMX.
      Specified by:
      unregisterMBean in class AbstractIpdMeter
    • getTypeId

      public String getTypeId()
      Description copied from interface: IpdMeter
      Identifies type of the meter.
      Specified by:
      getTypeId in interface IpdMeter
      Returns:
      Type ID of the meter
    • update

      public void update(Consumer<T> updater)
      Description copied from interface: CustomMeter
      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).

      Specified by:
      update in interface CustomMeter<T>
      Parameters:
      updater - function that updates the meter state
    • factory

      public static <BEAN_TYPE> MeterFactory<CustomMeter<BEAN_TYPE>> factory(Class<BEAN_TYPE> beanType)
    • factory

      public static <BEAN_TYPE> MeterFactory<CustomMeter<BEAN_TYPE>> factory(CustomMeter.MBeanSupplier<BEAN_TYPE> mBeanSupplier)