You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2016/07/19 21:41:21 UTC
[21/50] hadoop git commit: HADOOP-13290. Appropriate use of generics
in FairCallQueue. Contributed by Jonathan Hung.
HADOOP-13290. Appropriate use of generics in FairCallQueue. Contributed by Jonathan Hung.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/60ac09c7
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/60ac09c7
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/60ac09c7
Branch: refs/heads/YARN-2915
Commit: 60ac09c724176503ee0fdb69f191f21f56f7d02b
Parents: 9b697ba
Author: Zhe Zhang <zh...@apache.org>
Authored: Wed Jul 13 16:37:40 2016 -0700
Committer: Subru Krishnan <su...@apache.org>
Committed: Tue Jul 19 14:39:30 2016 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/ipc/FairCallQueue.java | 15 +++++++-------
.../apache/hadoop/ipc/TestFairCallQueue.java | 21 +++++++++++++++++++-
2 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/60ac09c7/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
index 38b196d..c2d3cd8 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
@@ -300,7 +300,7 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
@Override
public int size() {
int size = 0;
- for (BlockingQueue q : this.queues) {
+ for (BlockingQueue<E> q : this.queues) {
size += q.size();
}
return size;
@@ -346,7 +346,7 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
@Override
public int remainingCapacity() {
int sum = 0;
- for (BlockingQueue q : this.queues) {
+ for (BlockingQueue<E> q : this.queues) {
sum += q.remainingCapacity();
}
return sum;
@@ -362,7 +362,7 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
new HashMap<String, MetricsProxy>();
// Weakref for delegate, so we don't retain it forever if it can be GC'd
- private WeakReference<FairCallQueue> delegate;
+ private WeakReference<FairCallQueue<? extends Schedulable>> delegate;
// Keep track of how many objects we registered
private int revisionNumber = 0;
@@ -381,14 +381,15 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
return mp;
}
- public void setDelegate(FairCallQueue obj) {
- this.delegate = new WeakReference<FairCallQueue>(obj);
+ public void setDelegate(FairCallQueue<? extends Schedulable> obj) {
+ this.delegate
+ = new WeakReference<FairCallQueue<? extends Schedulable>>(obj);
this.revisionNumber++;
}
@Override
public int[] getQueueSizes() {
- FairCallQueue obj = this.delegate.get();
+ FairCallQueue<? extends Schedulable> obj = this.delegate.get();
if (obj == null) {
return new int[]{};
}
@@ -398,7 +399,7 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
@Override
public long[] getOverflowedCalls() {
- FairCallQueue obj = this.delegate.get();
+ FairCallQueue<? extends Schedulable> obj = this.delegate.get();
if (obj == null) {
return new long[]{};
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/60ac09c7/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
index 8c96c2e..d5e5f90 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestFairCallQueue.java
@@ -23,6 +23,9 @@ import static org.mockito.Mockito.when;
import junit.framework.TestCase;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.BlockingQueue;
@@ -392,4 +395,20 @@ public class TestFairCallQueue extends TestCase {
assertEquals(call, fcq.take());
assertEquals(0, fcq.size());
}
-}
\ No newline at end of file
+
+ public void testFairCallQueueMXBean() throws Exception {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName mxbeanName = new ObjectName(
+ "Hadoop:service=ns,name=FairCallQueue");
+
+ Schedulable call = mockCall("c");
+ fcq.put(call);
+ int[] queueSizes = (int[]) mbs.getAttribute(mxbeanName, "QueueSizes");
+ assertEquals(1, queueSizes[0]);
+ assertEquals(0, queueSizes[1]);
+ fcq.take();
+ queueSizes = (int[]) mbs.getAttribute(mxbeanName, "QueueSizes");
+ assertEquals(0, queueSizes[0]);
+ assertEquals(0, queueSizes[1]);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org