diff --git a/hbase-archetypes/hbase-client-project/pom.xml b/hbase-archetypes/hbase-client-project/pom.xml index 18464840e72..35a2dbc6e5f 100644 --- a/hbase-archetypes/hbase-client-project/pom.xml +++ b/hbase-archetypes/hbase-client-project/pom.xml @@ -40,19 +40,6 @@ 2.19 4.12 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - - - diff --git a/hbase-archetypes/hbase-shaded-client-project/pom.xml b/hbase-archetypes/hbase-shaded-client-project/pom.xml index 5c0b0a0c6e1..bf056a85bc4 100644 --- a/hbase-archetypes/hbase-shaded-client-project/pom.xml +++ b/hbase-archetypes/hbase-shaded-client-project/pom.xml @@ -40,19 +40,6 @@ 2.19 4.12 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - - - diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/util/PoolMapTestBase.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/PoolMapTestBase.java new file mode 100644 index 00000000000..1b242522f35 --- /dev/null +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/PoolMapTestBase.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.util; + +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.hadoop.hbase.util.PoolMap.PoolType; +import org.junit.After; +import org.junit.Before; + +public abstract class PoolMapTestBase { + + protected PoolMap poolMap; + + protected static final int POOL_SIZE = 3; + + @Before + public void setUp() throws Exception { + this.poolMap = new PoolMap<>(getPoolType(), POOL_SIZE); + } + + @After + public void tearDown() throws Exception { + this.poolMap.clear(); + } + + protected abstract PoolType getPoolType(); + + protected void runThread(final String randomKey, final String randomValue, + final String expectedValue) throws InterruptedException { + final AtomicBoolean matchFound = new AtomicBoolean(false); + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + poolMap.put(randomKey, randomValue); + String actualValue = poolMap.get(randomKey); + matchFound + .set(expectedValue == null ? actualValue == null : expectedValue.equals(actualValue)); + } + }); + thread.start(); + thread.join(); + assertTrue(matchFound.get()); + } +} diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestReusablePoolMap.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestReusablePoolMap.java new file mode 100644 index 00000000000..3fcaebb5fe5 --- /dev/null +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestReusablePoolMap.java @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.util; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.testclassification.MiscTests; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.PoolMap.PoolType; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category({ MiscTests.class, SmallTests.class }) +public class TestReusablePoolMap extends PoolMapTestBase { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestReusablePoolMap.class); + + @Override + protected PoolType getPoolType() { + return PoolType.Reusable; + } + + @Test + public void testSingleThreadedClient() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + // As long as we poll values we put, the pool size should remain zero + runThread(randomKey, randomValue, randomValue); + assertEquals(0, poolMap.size(randomKey)); + } + + @Test + public void testMultiThreadedClients() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + // As long as we poll values we put, the pool size should remain zero + for (int i = 0; i < POOL_SIZE; i++) { + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + runThread(randomKey, randomValue, randomValue); + assertEquals(0, poolMap.size(randomKey)); + } + poolMap.clear(); + String randomKey = String.valueOf(rand.nextInt()); + for (int i = 0; i < POOL_SIZE - 1; i++) { + String randomValue = String.valueOf(rand.nextInt()); + runThread(randomKey, randomValue, randomValue); + assertEquals(0, poolMap.size(randomKey)); + } + assertEquals(0, poolMap.size(randomKey)); + } + + @Test + public void testPoolCap() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + // As long as we poll values we put, the pool size should remain zero + String randomKey = String.valueOf(rand.nextInt()); + List randomValues = new ArrayList<>(); + for (int i = 0; i < POOL_SIZE * 2; i++) { + String randomValue = String.valueOf(rand.nextInt()); + randomValues.add(randomValue); + runThread(randomKey, randomValue, randomValue); + } + assertEquals(0, poolMap.size(randomKey)); + } +} diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestRoundRobinPoolMap.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestRoundRobinPoolMap.java new file mode 100644 index 00000000000..a71cf2974a1 --- /dev/null +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestRoundRobinPoolMap.java @@ -0,0 +1,102 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.util; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.testclassification.MiscTests; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.PoolMap.PoolType; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category({ MiscTests.class, SmallTests.class }) +public class TestRoundRobinPoolMap extends PoolMapTestBase { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestRoundRobinPoolMap.class); + + @Override + protected PoolType getPoolType() { + return PoolType.RoundRobin; + } + + @Test + public void testSingleThreadedClient() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + // As long as the pool is not full, we'll get null back. + // This forces the user to create new values that can be used to populate + // the pool. + runThread(randomKey, randomValue, null); + assertEquals(1, poolMap.size(randomKey)); + } + + @Test + public void testMultiThreadedClients() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + for (int i = 0; i < POOL_SIZE; i++) { + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + // As long as the pool is not full, we'll get null back + runThread(randomKey, randomValue, null); + // As long as we use distinct keys, each pool will have one value + assertEquals(1, poolMap.size(randomKey)); + } + poolMap.clear(); + String randomKey = String.valueOf(rand.nextInt()); + for (int i = 0; i < POOL_SIZE - 1; i++) { + String randomValue = String.valueOf(rand.nextInt()); + // As long as the pool is not full, we'll get null back + runThread(randomKey, randomValue, null); + // since we use the same key, the pool size should grow + assertEquals(i + 1, poolMap.size(randomKey)); + } + // at the end of the day, there should be as many values as we put + assertEquals(POOL_SIZE - 1, poolMap.size(randomKey)); + } + + @Test + public void testPoolCap() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + String randomKey = String.valueOf(rand.nextInt()); + List randomValues = new ArrayList<>(); + for (int i = 0; i < POOL_SIZE * 2; i++) { + String randomValue = String.valueOf(rand.nextInt()); + randomValues.add(randomValue); + if (i < POOL_SIZE - 1) { + // As long as the pool is not full, we'll get null back + runThread(randomKey, randomValue, null); + } else { + // when the pool becomes full, we expect the value we get back to be + // what we put earlier, in round-robin order + runThread(randomKey, randomValue, randomValues.get((i - POOL_SIZE + 1) % POOL_SIZE)); + } + } + assertEquals(POOL_SIZE, poolMap.size(randomKey)); + } +} diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestThreadLocalPoolMap.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestThreadLocalPoolMap.java new file mode 100644 index 00000000000..5f047c4f9fc --- /dev/null +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/util/TestThreadLocalPoolMap.java @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.util; + +import static org.junit.Assert.assertEquals; + +import java.util.Random; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.testclassification.MiscTests; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.PoolMap.PoolType; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category({ MiscTests.class, SmallTests.class }) +public class TestThreadLocalPoolMap extends PoolMapTestBase { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestThreadLocalPoolMap.class); + + @Override + protected PoolType getPoolType() { + return PoolType.ThreadLocal; + } + + @Test + public void testSingleThreadedClient() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + // As long as the pool is not full, we should get back what we put + runThread(randomKey, randomValue, randomValue); + assertEquals(1, poolMap.size(randomKey)); + } + + @Test + public void testMultiThreadedClients() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + // As long as the pool is not full, we should get back what we put + for (int i = 0; i < POOL_SIZE; i++) { + String randomKey = String.valueOf(rand.nextInt()); + String randomValue = String.valueOf(rand.nextInt()); + runThread(randomKey, randomValue, randomValue); + assertEquals(1, poolMap.size(randomKey)); + } + String randomKey = String.valueOf(rand.nextInt()); + for (int i = 0; i < POOL_SIZE; i++) { + String randomValue = String.valueOf(rand.nextInt()); + runThread(randomKey, randomValue, randomValue); + assertEquals(i + 1, poolMap.size(randomKey)); + } + } + + @Test + public void testPoolCap() throws InterruptedException, ExecutionException { + Random rand = ThreadLocalRandom.current(); + String randomKey = String.valueOf(rand.nextInt()); + for (int i = 0; i < POOL_SIZE * 2; i++) { + String randomValue = String.valueOf(rand.nextInt()); + // as of HBASE-4150, pool limit is no longer used with ThreadLocalPool + runThread(randomKey, randomValue, randomValue); + } + assertEquals(POOL_SIZE * 2, poolMap.size(randomKey)); + } +} diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/ResourceCheckerJUnitListener.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/ResourceCheckerJUnitListener.java index 709646bcc50..225d94f42b4 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/ResourceCheckerJUnitListener.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/ResourceCheckerJUnitListener.java @@ -1,5 +1,4 @@ -/* - * +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,25 +18,24 @@ package org.apache.hadoop.hbase; - - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - import org.apache.hadoop.hbase.ResourceChecker.Phase; import org.apache.hadoop.hbase.util.JVM; import org.junit.runner.notification.RunListener; /** * Listen to the test progress and check the usage of: - * - threads - * - open file descriptor - * - max open file descriptor - *

+ *

    + *
  • threads
  • + *
  • open file descriptor
  • + *
  • max open file descriptor
  • + *
+ *

* When surefire forkMode=once/always/perthread, this code is executed on the forked process. */ public class ResourceCheckerJUnitListener extends RunListener { @@ -91,7 +89,7 @@ public class ResourceCheckerJUnitListener extends RunListener { return 0; } JVM jvm = new JVM(); - return (int)jvm.getOpenFileDescriptorCount(); + return (int) jvm.getOpenFileDescriptorCount(); } @Override @@ -107,7 +105,7 @@ public class ResourceCheckerJUnitListener extends RunListener { return 0; } JVM jvm = new JVM(); - return (int)jvm.getMaxFileDescriptorCount(); + return (int) jvm.getMaxFileDescriptorCount(); } } @@ -117,7 +115,7 @@ public class ResourceCheckerJUnitListener extends RunListener { if (!JVM.isUnix()) { return 0; } - return (int)(new JVM().getSystemLoadAverage()*100); + return (int) (new JVM().getSystemLoadAverage() * 100); } } @@ -193,4 +191,3 @@ public class ResourceCheckerJUnitListener extends RunListener { end(descriptionToShortTestName(description)); } } - diff --git a/hbase-external-blockcache/pom.xml b/hbase-external-blockcache/pom.xml index 8d3afc2f67c..3d9109bac17 100644 --- a/hbase-external-blockcache/pom.xml +++ b/hbase-external-blockcache/pom.xml @@ -79,17 +79,6 @@ - - maven-surefire-plugin - - - - listener - org.apache.hadoop.hbase.ResourceCheckerJUnitListener - - - - org.apache.maven.plugins diff --git a/hbase-http/pom.xml b/hbase-http/pom.xml index 33ed032513b..1973170e5ae 100644 --- a/hbase-http/pom.xml +++ b/hbase-http/pom.xml @@ -122,12 +122,6 @@ maven-surefire-plugin - - - listener - org.apache.hadoop.hbase.ResourceCheckerJUnitListener - - target/test-classes/webapps diff --git a/hbase-mapreduce/pom.xml b/hbase-mapreduce/pom.xml index 794c4864c2d..850cb7c41f6 100644 --- a/hbase-mapreduce/pom.xml +++ b/hbase-mapreduce/pom.xml @@ -66,18 +66,6 @@ - - - maven-surefire-plugin - - - - listener - org.apache.hadoop.hbase.ServerResourceCheckerJUnitListener - - - - org.apache.maven.plugins diff --git a/hbase-replication/pom.xml b/hbase-replication/pom.xml index 0c5068fed5c..edce3094b34 100644 --- a/hbase-replication/pom.xml +++ b/hbase-replication/pom.xml @@ -47,23 +47,6 @@ true - - maven-surefire-plugin - - - - secondPartTestsExecution - test - - test - - - true - - - - org.apache.maven.plugins diff --git a/hbase-rest/pom.xml b/hbase-rest/pom.xml index ec15104798e..c7af9f57b52 100644 --- a/hbase-rest/pom.xml +++ b/hbase-rest/pom.xml @@ -125,12 +125,6 @@ maven-surefire-plugin - - - listener - org.apache.hadoop.hbase.ServerResourceCheckerJUnitListener - - target/test-classes/webapps diff --git a/hbase-server/pom.xml b/hbase-server/pom.xml index 1d5e9e66415..6c06acfcf22 100644 --- a/hbase-server/pom.xml +++ b/hbase-server/pom.xml @@ -237,12 +237,6 @@ maven-surefire-plugin - - - listener - org.apache.hadoop.hbase.ServerResourceCheckerJUnitListener - - target/test-classes/webapps diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ServerResourceCheckerJUnitListener.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ServerResourceCheckerJUnitListener.java deleted file mode 100644 index 4b750e430ca..00000000000 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ServerResourceCheckerJUnitListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hbase; - -/** - * Monitor the resources. use by the tests All resources in {@link ResourceCheckerJUnitListener} - * plus the number of connection. - */ -public class ServerResourceCheckerJUnitListener extends ResourceCheckerJUnitListener { -} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestPoolMap.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestPoolMap.java deleted file mode 100644 index dcca330f6e0..00000000000 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestPoolMap.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hbase.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; -import junit.framework.TestCase; -import org.apache.hadoop.hbase.HBaseClassTestRule; -import org.apache.hadoop.hbase.testclassification.MiscTests; -import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.apache.hadoop.hbase.util.PoolMap.PoolType; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({TestPoolMap.TestRoundRobinPoolType.class, TestPoolMap.TestThreadLocalPoolType.class, - TestPoolMap.TestReusablePoolType.class}) -@Category({MiscTests.class, SmallTests.class}) -public class TestPoolMap { - - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestPoolMap.class); - - public abstract static class TestPoolType extends TestCase { - protected PoolMap poolMap; - protected Random random = new Random(); - - protected static final int POOL_SIZE = 3; - - @Override - protected void setUp() throws Exception { - this.poolMap = new PoolMap<>(getPoolType(), POOL_SIZE); - } - - protected abstract PoolType getPoolType(); - - @Override - protected void tearDown() throws Exception { - this.poolMap.clear(); - } - - protected void runThread(final String randomKey, final String randomValue, - final String expectedValue) throws InterruptedException { - final AtomicBoolean matchFound = new AtomicBoolean(false); - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - poolMap.put(randomKey, randomValue); - String actualValue = poolMap.get(randomKey); - matchFound.set(expectedValue == null ? actualValue == null - : expectedValue.equals(actualValue)); - } - }); - thread.start(); - thread.join(); - assertTrue(matchFound.get()); - } - } - - @Category({MiscTests.class, SmallTests.class}) - public static class TestRoundRobinPoolType extends TestPoolType { - @Override - protected PoolType getPoolType() { - return PoolType.RoundRobin; - } - - public void testSingleThreadedClient() throws InterruptedException, - ExecutionException { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - // As long as the pool is not full, we'll get null back. - // This forces the user to create new values that can be used to populate - // the pool. - runThread(randomKey, randomValue, null); - assertEquals(1, poolMap.size(randomKey)); - } - - public void testMultiThreadedClients() throws InterruptedException, - ExecutionException { - for (int i = 0; i < POOL_SIZE; i++) { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - // As long as the pool is not full, we'll get null back - runThread(randomKey, randomValue, null); - // As long as we use distinct keys, each pool will have one value - assertEquals(1, poolMap.size(randomKey)); - } - poolMap.clear(); - String randomKey = String.valueOf(random.nextInt()); - for (int i = 0; i < POOL_SIZE - 1; i++) { - String randomValue = String.valueOf(random.nextInt()); - // As long as the pool is not full, we'll get null back - runThread(randomKey, randomValue, null); - // since we use the same key, the pool size should grow - assertEquals(i + 1, poolMap.size(randomKey)); - } - // at the end of the day, there should be as many values as we put - assertEquals(POOL_SIZE - 1, poolMap.size(randomKey)); - } - - public void testPoolCap() throws InterruptedException, ExecutionException { - String randomKey = String.valueOf(random.nextInt()); - List randomValues = new ArrayList<>(); - for (int i = 0; i < POOL_SIZE * 2; i++) { - String randomValue = String.valueOf(random.nextInt()); - randomValues.add(randomValue); - if (i < POOL_SIZE - 1) { - // As long as the pool is not full, we'll get null back - runThread(randomKey, randomValue, null); - } else { - // when the pool becomes full, we expect the value we get back to be - // what we put earlier, in round-robin order - runThread(randomKey, randomValue, - randomValues.get((i - POOL_SIZE + 1) % POOL_SIZE)); - } - } - assertEquals(POOL_SIZE, poolMap.size(randomKey)); - } - - } - - @Category({MiscTests.class, SmallTests.class}) - public static class TestThreadLocalPoolType extends TestPoolType { - @Override - protected PoolType getPoolType() { - return PoolType.ThreadLocal; - } - - public void testSingleThreadedClient() throws InterruptedException, - ExecutionException { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - // As long as the pool is not full, we should get back what we put - runThread(randomKey, randomValue, randomValue); - assertEquals(1, poolMap.size(randomKey)); - } - - public void testMultiThreadedClients() throws InterruptedException, - ExecutionException { - // As long as the pool is not full, we should get back what we put - for (int i = 0; i < POOL_SIZE; i++) { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - runThread(randomKey, randomValue, randomValue); - assertEquals(1, poolMap.size(randomKey)); - } - String randomKey = String.valueOf(random.nextInt()); - for (int i = 0; i < POOL_SIZE; i++) { - String randomValue = String.valueOf(random.nextInt()); - runThread(randomKey, randomValue, randomValue); - assertEquals(i + 1, poolMap.size(randomKey)); - } - } - - public void testPoolCap() throws InterruptedException, ExecutionException { - String randomKey = String.valueOf(random.nextInt()); - for (int i = 0; i < POOL_SIZE * 2; i++) { - String randomValue = String.valueOf(random.nextInt()); - // as of HBASE-4150, pool limit is no longer used with ThreadLocalPool - runThread(randomKey, randomValue, randomValue); - } - assertEquals(POOL_SIZE * 2, poolMap.size(randomKey)); - } - - } - - @Category({MiscTests.class, SmallTests.class}) - public static class TestReusablePoolType extends TestPoolType { - @Override - protected PoolType getPoolType() { - return PoolType.Reusable; - } - - public void testSingleThreadedClient() throws InterruptedException, - ExecutionException { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - // As long as we poll values we put, the pool size should remain zero - runThread(randomKey, randomValue, randomValue); - assertEquals(0, poolMap.size(randomKey)); - } - - public void testMultiThreadedClients() throws InterruptedException, - ExecutionException { - // As long as we poll values we put, the pool size should remain zero - for (int i = 0; i < POOL_SIZE; i++) { - String randomKey = String.valueOf(random.nextInt()); - String randomValue = String.valueOf(random.nextInt()); - runThread(randomKey, randomValue, randomValue); - assertEquals(0, poolMap.size(randomKey)); - } - poolMap.clear(); - String randomKey = String.valueOf(random.nextInt()); - for (int i = 0; i < POOL_SIZE - 1; i++) { - String randomValue = String.valueOf(random.nextInt()); - runThread(randomKey, randomValue, randomValue); - assertEquals(0, poolMap.size(randomKey)); - } - assertEquals(0, poolMap.size(randomKey)); - } - - public void testPoolCap() throws InterruptedException, ExecutionException { - // As long as we poll values we put, the pool size should remain zero - String randomKey = String.valueOf(random.nextInt()); - List randomValues = new ArrayList<>(); - for (int i = 0; i < POOL_SIZE * 2; i++) { - String randomValue = String.valueOf(random.nextInt()); - randomValues.add(randomValue); - runThread(randomKey, randomValue, randomValue); - } - assertEquals(0, poolMap.size(randomKey)); - } - - } - -} - diff --git a/hbase-shell/pom.xml b/hbase-shell/pom.xml index fe7d9c5748e..7e9c8aa95c7 100644 --- a/hbase-shell/pom.xml +++ b/hbase-shell/pom.xml @@ -123,18 +123,6 @@ org.codehaus.mojo findbugs-maven-plugin - - - maven-surefire-plugin - - - - listener - org.apache.hadoop.hbase.ServerResourceCheckerJUnitListener - - - - diff --git a/hbase-zookeeper/pom.xml b/hbase-zookeeper/pom.xml index ed435960a41..5f74fec3719 100644 --- a/hbase-zookeeper/pom.xml +++ b/hbase-zookeeper/pom.xml @@ -98,18 +98,6 @@ org.codehaus.mojo findbugs-maven-plugin - - - maven-surefire-plugin - - - - listener - org.apache.hadoop.hbase.ResourceCheckerJUnitListener - - - -