001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017 package org.apache.logging.log4j.core.jmx;
018
019 /**
020 * The MBean interface for monitoring and managing an LMAX Disruptor ring
021 * buffer.
022 */
023 public interface RingBufferAdminMBean {
024 /**
025 * ObjectName pattern ({@value}) for the RingBufferAdmin MBean that instruments
026 * the global {@code AsyncLogger} ring buffer.
027 * This pattern contains one variable: the name of the context.
028 * <p>
029 * You can find the registered RingBufferAdmin MBean for the global AsyncLogger like this:
030 * </p>
031 * <pre>
032 * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
033 * String pattern = String.format(RingBufferAdminMBean.PATTERN_ASYNC_LOGGER, "*");
034 * Set<ObjectName> asyncLoggerNames = mbs.queryNames(new ObjectName(pattern), null);
035 * </pre>
036 */
037 String PATTERN_ASYNC_LOGGER = Server.DOMAIN + ":type=%s,component=AsyncLoggerRingBuffer";
038
039 /**
040 * ObjectName pattern ({@value}) for RingBufferAdmin MBeans that instrument
041 * {@code AsyncLoggerConfig} ring buffers.
042 * This pattern contains three variables, where the first is the name of the
043 * context, the second and third are identical and the name of the instrumented logger config.
044 * <p>
045 * You can find all registered RingBufferAdmin MBeans like this:
046 * </p>
047 * <pre>
048 * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
049 * String pattern = String.format(RingBufferAdminMBean.PATTERN_ASYNC_LOGGER_CONFIG, "*", "*");
050 * Set<ObjectName> asyncConfigNames = mbs.queryNames(new ObjectName(pattern), null);
051 * </pre>
052 */
053 String PATTERN_ASYNC_LOGGER_CONFIG = Server.DOMAIN + ":type=%s,component=Loggers,name=%s,subtype=RingBuffer";
054
055 /**
056 * Returns the number of slots that the ring buffer was configured with.
057 * Disruptor ring buffers are bounded-size data structures, this number does
058 * not change during the life of the ring buffer.
059 *
060 * @return the number of slots that the ring buffer was configured with
061 */
062 long getBufferSize();
063
064 /**
065 * Returns the number of available slots in the ring buffer. May vary wildly
066 * between invocations.
067 *
068 * @return the number of available slots in the ring buffer
069 */
070 long getRemainingCapacity();
071 }