View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements. See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache license, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License. You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the license for the specific language governing permissions and
    15   * limitations under the license.
    16   */
    17  package org.apache.logging.log4j.core.jmx;
    18
    19  /**
    20   * The MBean interface for monitoring and managing an LMAX Disruptor ring
    21   * buffer.
    22   */
    23  public interface RingBufferAdminMBean {
    24      /**
    25       * ObjectName pattern ({@value}) for the RingBufferAdmin MBean that instruments
    26       * the global {@code AsyncLogger} ring buffer.
    27       * This pattern contains one variable: the name of the context.
    28       * <p>
    29       * You can find the registered RingBufferAdmin MBean for the global AsyncLogger like this:
    30       * </p>
    31       * <pre>
    32       * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    33       * String pattern = String.format(RingBufferAdminMBean.PATTERN_ASYNC_LOGGER, &quot;*&quot;);
    34       * Set&lt;ObjectName&gt; asyncLoggerNames = mbs.queryNames(new ObjectName(pattern), null);
    35       * </pre>
    36       */
    37      String PATTERN_ASYNC_LOGGER = Server.DOMAIN + ":type=%s,component=AsyncLoggerRingBuffer";
    38
    39      /**
    40       * ObjectName pattern ({@value}) for RingBufferAdmin MBeans that instrument
    41       * {@code AsyncLoggerConfig} ring buffers.
    42       * This pattern contains three variables, where the first is the name of the
    43       * context, the second and third are identical and the name of the instrumented logger config.
    44       * <p>
    45       * You can find all registered RingBufferAdmin MBeans like this:
    46       * </p>
    47       * <pre>
    48       * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    49       * String pattern = String.format(RingBufferAdminMBean.PATTERN_ASYNC_LOGGER_CONFIG, &quot;*&quot;, &quot;*&quot;);
    50       * Set&lt;ObjectName&gt; asyncConfigNames = mbs.queryNames(new ObjectName(pattern), null);
    51       * </pre>
    52       */
    53      String PATTERN_ASYNC_LOGGER_CONFIG = Server.DOMAIN + ":type=%s,component=Loggers,name=%s,subtype=RingBuffer";
    54
    55      /**
    56       * Returns the number of slots that the ring buffer was configured with.
    57       * Disruptor ring buffers are bounded-size data structures, this number does
    58       * not change during the life of the ring buffer.
    59       *
    60       * @return the number of slots that the ring buffer was configured with
    61       */
    62      long getBufferSize();
    63
    64      /**
    65       * Returns the number of available slots in the ring buffer. May vary wildly
    66       * between invocations.
    67       *
    68       * @return the number of available slots in the ring buffer
    69       */
    70      long getRemainingCapacity();
    71  }