Repository: incubator-geode Updated Branches: refs/heads/develop f788d698e -> 2da99e765
Revert "GEODE-613 CI Failure: LocatorLoadSnapshotJUnitTest.testConcurrentBalancing" This reverts commit f788d698e877b15570052f89b9d0b5ab23023f81. This commit accidentally included an unrelated change that broke the build. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/2da99e76 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/2da99e76 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/2da99e76 Branch: refs/heads/develop Commit: 2da99e76593d5dd77ccb54d5763506642ccc9e41 Parents: f788d69 Author: Bruce Schuchardt <bschucha...@pivotal.io> Authored: Thu May 5 15:37:33 2016 -0700 Committer: Bruce Schuchardt <bschucha...@pivotal.io> Committed: Thu May 5 15:37:33 2016 -0700 ---------------------------------------------------------------------- .../execute/EmptyRegionFunctionException.java | 63 ------------------- .../execute/EmtpyRegionFunctionException.java | 63 +++++++++++++++++++ .../internal/LocatorLoadSnapshotJUnitTest.java | 65 +++++++++++++++++--- 3 files changed, 118 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2da99e76/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmptyRegionFunctionException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmptyRegionFunctionException.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmptyRegionFunctionException.java deleted file mode 100644 index a077779..0000000 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmptyRegionFunctionException.java +++ /dev/null @@ -1,63 +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 com.gemstone.gemfire.cache.execute; - -import com.gemstone.gemfire.distributed.DistributedMember; - -/** - * Exception to indicate that Region is empty for data aware functions. - * - * @since 6.5 - * - */ -public class EmptyRegionFunctionException extends FunctionException { - - private static final long serialVersionUID = 1L; - - /** - * Construct an instance of EmtpyRegionFunctionException - * - * @param cause - * a Throwable cause of this exception - */ - public EmptyRegionFunctionException(Throwable cause) { - super(cause); - } - - /** - * Construct an instance of EmtpyRegionFunctionException - * - * @param msg - * Exception message - */ - public EmptyRegionFunctionException(String msg) { - super(msg); - } - - /** - * Construct an instance of EmtpyRegionFunctionException - * - * @param msg - * the error message - * @param cause - * a Throwable cause of this exception - */ - public EmptyRegionFunctionException(String msg, Throwable cause) { - super(msg, cause); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2da99e76/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmtpyRegionFunctionException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmtpyRegionFunctionException.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmtpyRegionFunctionException.java new file mode 100644 index 0000000..6aff9eb --- /dev/null +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/execute/EmtpyRegionFunctionException.java @@ -0,0 +1,63 @@ +/* + * 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 com.gemstone.gemfire.cache.execute; + +import com.gemstone.gemfire.distributed.DistributedMember; + +/** + * Exception to indicate that Region is empty for data aware functions. + * + * @since 6.5 + * + */ +public class EmtpyRegionFunctionException extends FunctionException { + + private static final long serialVersionUID = 1L; + + /** + * Construct an instance of EmtpyRegionFunctionException + * + * @param cause + * a Throwable cause of this exception + */ + public EmtpyRegionFunctionException(Throwable cause) { + super(cause); + } + + /** + * Construct an instance of EmtpyRegionFunctionException + * + * @param msg + * Exception message + */ + public EmtpyRegionFunctionException(String msg) { + super(msg); + } + + /** + * Construct an instance of EmtpyRegionFunctionException + * + * @param msg + * the error message + * @param cause + * a Throwable cause of this exception + */ + public EmtpyRegionFunctionException(String msg, Throwable cause) { + super(msg, cause); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2da99e76/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/LocatorLoadSnapshotJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/LocatorLoadSnapshotJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/LocatorLoadSnapshotJUnitTest.java old mode 100755 new mode 100644 index d8a1290..34ac767 --- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/LocatorLoadSnapshotJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/LocatorLoadSnapshotJUnitTest.java @@ -257,19 +257,21 @@ public class LocatorLoadSnapshotJUnitTest { assertEquals(Arrays.asList(new ServerLocation[] {} ), sn.getServersForQueue(null, excludeAll, 3)); } - + /** - * A basic test of concurrent functionality. Simulate a number of + * A basic test of concurrent functionality. Starts a number of * threads making requests and expects the load to be balanced between * three servers. * @throws InterruptedException */ + @Category(FlakyTest.class) // GEODE-613: lots of threads, async action, IntegrationTest-not-UnitTest, thread joins, time sensitive @Test public void testConcurrentBalancing() throws InterruptedException { int NUM_THREADS = 50; final int NUM_REQUESTS = 10000; int ALLOWED_THRESHOLD = 50; //We should never be off by more than - + //the number of concurrent threads. + final LocatorLoadSnapshot sn = new LocatorLoadSnapshot(); final ServerLocation l1 = new ServerLocation("localhost", 1); final ServerLocation l2 = new ServerLocation("localhost", 2); @@ -288,18 +290,47 @@ public class LocatorLoadSnapshotJUnitTest { loadCounts.put(l2, new AtomicInteger(initialLoad2)); loadCounts.put(l3, new AtomicInteger(initialLoad3)); + Thread[] threads = new Thread[NUM_THREADS]; +// final Object lock = new Object(); for(int i =0; i < NUM_THREADS; i++) { - for(int ii = 0; ii < NUM_REQUESTS; ii++) { - ServerLocation location; - location = sn.getServerForConnection(null, Collections.EMPTY_SET); - AtomicInteger count = (AtomicInteger) loadCounts.get(location); - count.incrementAndGet(); + threads[i] = new Thread("Thread-" + i) { + public void run() { + for(int ii = 0; ii < NUM_REQUESTS; ii++) { + ServerLocation location; +// synchronized(lock) { + location = sn.getServerForConnection(null, Collections.EMPTY_SET); +// } + AtomicInteger count = (AtomicInteger) loadCounts.get(location); + count.incrementAndGet(); + } + } + }; + } + + for(int i =0; i < NUM_THREADS; i++) { + threads[i].start(); + } + + for(int i =0; i < NUM_THREADS; i++) { + Thread t = threads[i]; + long ms = 30 * 1000; + t.join(30 * 1000); + if (t.isAlive()) { + for(int j =0; j < NUM_THREADS; j++) { + threads[j].interrupt(); + } + fail("Thread did not terminate after " + ms + " ms: " + t); } } - double expectedPerServer = ( initialLoad1 + initialLoad2 + initialLoad3 + + double expectedPerServer = ( initialLoad1 + initialLoad2 + initialLoad3 + NUM_REQUESTS * NUM_THREADS) / (double) loadCounts.size(); - +// for(Iterator itr = loadCounts.entrySet().iterator(); itr.hasNext(); ) { +// Map.Entry entry = (Entry) itr.next(); +// ServerLocation location = (ServerLocation) entry.getKey(); +// AI count= (AI) entry.getValue(); +// } + for(Iterator itr = loadCounts.entrySet().iterator(); itr.hasNext(); ) { Map.Entry entry = (Entry) itr.next(); ServerLocation location = (ServerLocation) entry.getKey(); @@ -337,4 +368,18 @@ public class LocatorLoadSnapshotJUnitTest { assertFalse(sn.hasBalancedConnections("b")); } + public void _test2() { // delete this method? + final LocatorLoadSnapshot sn = new LocatorLoadSnapshot(); + sn.addServer(new ServerLocation("hs20h.gemstone.com",28543), new String[0], new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20l.gemstone.com",22385), new String[0], new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20n.gemstone.com",23482), new String[0], new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20m.gemstone.com",23429), new String[0], new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20e.gemstone.com",20154), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20j.gemstone.com",24273), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20g.gemstone.com",27125), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20i.gemstone.com",25201), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20k.gemstone.com",23711), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + sn.addServer(new ServerLocation("hs20f.gemstone.com",21025), new String[0],new ServerLoad(0.0f, 0.00125f, 0.0f, 1.0f)); + } + }