GEODE-2812: Add API to get list of live locators I fixed 'gradlew spotlessApply' to fix them.
* geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java * geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8239e6fd Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8239e6fd Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8239e6fd Branch: refs/heads/feature/GEODE-2900 Commit: 8239e6fd64e01827d6df78c3c62fc886337cc011 Parents: dbd7c95 Author: masaki.yamakawa <[email protected]> Authored: Tue Apr 25 00:03:24 2017 +0900 Committer: Bruce Schuchardt <[email protected]> Committed: Thu May 11 09:15:27 2017 -0700 ---------------------------------------------------------------------- .../internal/AutoConnectionSourceImpl.java | 3 ++- .../internal/AutoConnectionSourceDUnitTest.java | 22 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/8239e6fd/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java index a9388de..822f449 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java +++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java @@ -263,7 +263,8 @@ public class AutoConnectionSourceImpl implements ConnectionSource { List<ServerLocation> locatorResponse = response.getLocators(); List<InetSocketAddress> newLocators = new ArrayList<InetSocketAddress>(locatorResponse.size()); - List<InetSocketAddress> activeLocators = new ArrayList<InetSocketAddress>(locatorResponse.size()); + List<InetSocketAddress> activeLocators = + new ArrayList<InetSocketAddress>(locatorResponse.size()); Set<InetSocketAddress> badLocators = new HashSet<InetSocketAddress>(initialLocators); for (Iterator<ServerLocation> itr = locatorResponse.iterator(); itr.hasNext();) { http://git-wip-us.apache.org/repos/asf/geode/blob/8239e6fd/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java index 7292515..d944f2d 100644 --- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java @@ -86,7 +86,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase { vm0.invoke("StartBridgeClient", () -> startBridgeClient(null, NetworkUtils.getServerHostName(vm0.getHost()), AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET))); - checkLocators(vm0, new InetSocketAddress[]{}, new InetSocketAddress[]{}); + checkLocators(vm0, new InetSocketAddress[] {}, new InetSocketAddress[] {}); putInVM(vm0, "key", "value"); fail("Client cache should not have been able to start"); } catch (Exception e) { @@ -170,27 +170,34 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase { InetSocketAddress locatorToWaitFor = new InetSocketAddress(hostName, locatorPort1); waitForLocatorDiscovery(vm2, locatorToWaitFor); - InetSocketAddress[] initialLocators = new InetSocketAddress[]{new InetSocketAddress(hostName, locatorPort0)}; - checkLocators(vm2, initialLocators, new InetSocketAddress[]{new InetSocketAddress(hostName, locatorPort0), new InetSocketAddress(hostName, locatorPort1)}); + InetSocketAddress[] initialLocators = + new InetSocketAddress[] {new InetSocketAddress(hostName, locatorPort0)}; + checkLocators(vm2, initialLocators, + new InetSocketAddress[] {new InetSocketAddress(hostName, locatorPort0), + new InetSocketAddress(hostName, locatorPort1)}); vm0.invoke("Stop Locator", () -> stopLocator()); vm0.invoke("Start BridgeServer", () -> startBridgeServer(null, locators)); putAndWaitForSuccess(vm2, REGION_NAME, "key", "value"); Assert.assertEquals("value", getInVM(vm0, "key")); - checkLocators(vm2, initialLocators, new InetSocketAddress[]{new InetSocketAddress(hostName, locatorPort1)}); + checkLocators(vm2, initialLocators, + new InetSocketAddress[] {new InetSocketAddress(hostName, locatorPort1)}); vm3.invoke("Start Locator", () -> startLocator(NetworkUtils.getServerHostName(vm3.getHost()), locatorPort3, locators)); stopBridgeMemberVM(vm0); locatorToWaitFor = new InetSocketAddress(hostName, locatorPort3); waitForLocatorDiscovery(vm2, locatorToWaitFor); - checkLocators(vm2, initialLocators, new InetSocketAddress[]{new InetSocketAddress(hostName, locatorPort1), new InetSocketAddress(hostName, locatorPort3)}); + checkLocators(vm2, initialLocators, + new InetSocketAddress[] {new InetSocketAddress(hostName, locatorPort1), + new InetSocketAddress(hostName, locatorPort3)}); vm1.invoke("Stop Locator", () -> stopLocator()); vm1.invoke("Start BridgeServer", () -> startBridgeServer(null, locators)); putAndWaitForSuccess(vm2, REGION_NAME, "key2", "value2"); Assert.assertEquals("value2", getInVM(vm1, "key2")); - checkLocators(vm2, initialLocators, new InetSocketAddress[]{new InetSocketAddress(hostName, locatorPort3)}); + checkLocators(vm2, initialLocators, + new InetSocketAddress[] {new InetSocketAddress(hostName, locatorPort3)}); } catch (Exception ec) { if (ec.getCause() != null && (ec.getCause().getCause() instanceof BindException)) return;// BindException let it pass @@ -501,7 +508,8 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase { }); } - protected void checkLocators(VM vm, final InetSocketAddress[] expectedInitial, final InetSocketAddress[] expected) { + protected void checkLocators(VM vm, final InetSocketAddress[] expectedInitial, + final InetSocketAddress[] expected) { vm.invoke(new SerializableRunnable("Check locators") { public void run() { Pool pool = PoolManager.find(POOL_NAME);
