* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.yangtools.util.concurrent;
+import static java.util.Objects.requireNonNull;
+
import java.beans.ConstructorProperties;
+import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* Class used by the {@link QueuedNotificationManager} that contains a snapshot of notification
* @author Thomas Pantelis
* @see QueuedNotificationManager
*/
+@NonNullByDefault
public class ListenerNotificationQueueStats {
-
private final String listenerClassName;
private final int currentQueueSize;
- @ConstructorProperties({ "listenerClassName","currentQueueSize" })
+ @ConstructorProperties({ "listenerClassName", "currentQueueSize" })
public ListenerNotificationQueueStats(final String listenerClassName, final int currentQueueSize) {
- this.listenerClassName = listenerClassName;
+ this.listenerClassName = requireNonNull(listenerClassName);
this.currentQueueSize = currentQueueSize;
}
private static final long TASK_WAIT_NANOS = TimeUnit.MILLISECONDS.toNanos(10);
private final ConcurrentMap<ListenerKey<L>, NotificationTask> listenerCache = new ConcurrentHashMap<>();
+ private final @NonNull QueuedNotificationManagerMXBean mxBean = new QueuedNotificationManagerMXBeanImpl(this);
private final @NonNull BatchedInvoker<L, N> listenerInvoker;
private final @NonNull Executor executor;
private final @NonNull String name;
return maxQueueCapacity;
}
+ /**
+ * Return an {@link QueuedNotificationManagerMXBean} tied to this instance.
+ *
+ * @return An QueuedNotificationManagerMXBean object.
+ */
+ public @NonNull QueuedNotificationManagerMXBean getMXBean() {
+ return mxBean;
+ }
+
/**
* Returns the {@link Executor} to used for notification tasks.
*/
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util.concurrent;
+
+import java.util.List;
+
+/**
+ * MXBean interface for {@link QueuedNotificationManager} statistic metrics.
+ *
+ * @author Thomas Pantelis
+ */
+public interface QueuedNotificationManagerMXBean {
+ /**
+ * Returns a list of stat instances for each current listener notification task in progress.
+ */
+ List<ListenerNotificationQueueStats> getCurrentListenerQueueStats();
+
+ /**
+ * Returns the configured maximum listener queue size.
+ */
+ int getMaxListenerQueueSize();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util.concurrent;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.List;
+
+final class QueuedNotificationManagerMXBeanImpl implements QueuedNotificationManagerMXBean {
+ private final QueuedNotificationManager<?, ?> manager;
+
+ QueuedNotificationManagerMXBeanImpl(final QueuedNotificationManager<?, ?> manager) {
+ this.manager = requireNonNull(manager);
+ }
+
+ /**
+ * Returns a list of stat instances for each current listener notification task in progress.
+ */
+ @Override
+ public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
+ return manager.getListenerNotificationQueueStats();
+ }
+
+ /**
+ * Returns the configured maximum listener queue size.
+ */
+ @Override
+ public int getMaxListenerQueueSize() {
+ return manager.getMaxQueueCapacity();
+ }
+}