Class LocalBackendMonitor<B extends LocalBackend<?>>

  • Type Parameters:
    B - The type of local backend associated with this monitor.
    All Implemented Interfaces:
    MeterBinder
    Direct Known Subclasses:
    PluggableBackendMonitor

    public class LocalBackendMonitor<B extends LocalBackend<?>>
    extends MonitorProvider
    This class implements a monitor provider that will report generic information for an enabled Directory Server backend, including its backend ID, base DNs, writability mode, and the number of entries it contains.

    Sub-classes may override addAdditionalMetrics() in order to add implementation specific monitoring metrics.

    • Constructor Detail

      • LocalBackendMonitor

        public LocalBackendMonitor​(B backend,
                                   ServerContext serverContext)
        Creates a new instance of this backend monitor provider that will work with the provided backend.
        Parameters:
        backend - The backend with which this monitor is associated.
        serverContext - The server context
    • Method Detail

      • computeMonitorInstanceDn

        protected final Dn computeMonitorInstanceDn()
        Description copied from class: MonitorProvider
        Returns the monitor instance DN for this monitor provider.
        Specified by:
        computeMonitorInstanceDn in class MonitorProvider
        Returns:
        the monitor instance DN.
      • addMonitorObjectClassNames

        protected void addMonitorObjectClassNames​(Attribute ocAttr)
        Description copied from class: MonitorProvider
        Adds to the provided attribute the objectclass names that should be included in the monitor entry created from this monitor provider. This method should be implemented by child classes to make it easier to search for monitor entries of a specific type.
        Specified by:
        addMonitorObjectClassNames in class MonitorProvider
        Parameters:
        ocAttr - the objectClass attribute where to add the object class names
      • bindTo

        public final void bindTo​(MeterRegistry parent)
        Description copied from class: MonitorProvider
        .

        Implementation considerations

        Implementations MUST set the MonitorProvider.registry field by creating a new MeterRegistryHolder, and specifying the appropriate prefix for the dimensional model and also the hierarchical model if they are different. This can be done using a parameter on the constructor, or the MeterRegistryHolder.hierarchicalNamePrefix(String) method. Tags common to all metrics for this monitor provider can also be set using the MeterRegistryHolder.tag(String, String) method.

        Attribute names are then registered by calling factory methods on the MonitorProvider.registry field.

        Sample dummy implementation

        (Please remove the comments when using this code as a template)

         
         public void bindTo(final MeterRegistry parent) {
             // create the MeterRegistryHolder wrapping OpenDJ's MeterRegistry
             registry = new MeterRegistryHolder("dimensional-name-prefix", parent)
                      .tag("label", "dimension")
                      .hierarchicalNamePrefix("hierarchical-name-prefix.dimension");
        
             // register the metrics against the wrapper
             registry.numberGauge("gauge", numberSupplier); // use lambdas or method references here
             timer = registry.timer("requests-submitted");
             // set a different name for the metric in cn=monitor, dimensional model and hierarchical model
             Gauge.doubleGauge(dimensionalName, supplier)
                  .hierarchicalName(hierarchicalName)
                  .tag(MeterRegistryHolder.TAG_ATTRIBUTE_NAME, "cn-monitor-name") // drop the "ds-mon-" prefix here
                  .register(registry);
             // this gauge will only output to cn=monitor based monitoring endpoints
             registry.monitoringGauge("only-visible-in-cn-monitor", supplier);
         }
         
         
        Specified by:
        bindTo in interface MeterBinder
        Specified by:
        bindTo in class MonitorProvider
      • getBackendType

        protected String getBackendType()
        Returns the local backend implementation type.
        Returns:
        A string used in this monitor provider's MeterRegistry representing the local backend type.
      • addAdditionalMetrics

        protected void addAdditionalMetrics()
        Adds additional metrics specific to the local backend implementation in this monitor provider's MeterRegistry.

        The default implementation is to do nothing.

      • getLocalBackend

        protected final B getLocalBackend()
        Returns the local backend associated with this backend.
        Returns:
        The local backend associated with this backend.
      • registerBaseDnMonitors

        public final void registerBaseDnMonitors()
        Registers monitoring entries associated to the base DNs handled by the monitored backend in the directory server.
      • deregisterBaseDnMonitors

        public final void deregisterBaseDnMonitors()
        Deregisters monitoring entries associated to the base DNs handled by the monitored backend in the directory server.
      • updateBaseDnMonitors

        public final void updateBaseDnMonitors()
        Updates the list of monitoring entries associated to the base DNs handled by the monitored backend in the directory server.