Github user mfranklin commented on a diff in the pull request:
https://github.com/apache/incubator-streams/pull/99#discussion_r18607089
--- Diff:
streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/queues/ThroughputQueue.java
---
@@ -0,0 +1,384 @@
+package org.apache.streams.local.queues;
+
+import net.jcip.annotations.GuardedBy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+import javax.management.*;
+import java.lang.management.ManagementFactory;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * A {@link java.util.concurrent.BlockingQueue} implementation that allows
the measure measurement of how
+ * data flows through the queue. Is also a {@code MBean} so the flow
statistics can be viewed through
+ * JMX. Registration of the bean happens whenever a constructor receives a
non-null id.
+ *
+ * !!! Warning !!!
+ * Only the necessary methods for the local streams runtime are
implemented. All other methods throw a
+ * {@link sun.reflect.generics.reflectiveObjects.NotImplementedException}.
+ */
+public class ThroughputQueue<E> implements BlockingQueue<E>,
ThroughputQueueMXBean {
+
+ public static final String NAME_TEMPLATE =
"org.apache.streams.local:type=ThroughputQueue,name=%s";
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ThroughputQueue.class);
+
+ private BlockingQueue<ThroughputElement<E>> underlyingQueue;
+ private ReadWriteLock putCountsLock;
+ private ReadWriteLock takeCountsLock;
+ @GuardedBy("putCountsLock")
+ private long elementsAdded;
--- End diff --
Why not use AtomicLong?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---