From b4d5a4389f0f252955473840b1fade802b1a7f04 Mon Sep 17 00:00:00 2001 From: Ernie Burghardt Date: Tue, 22 Jun 2021 15:38:58 -0500 Subject: [PATCH] [Revert] Accidental backport to support/1.13 (#6637) This reverts commit 35cbee2c00cf3bf0119b09369631c9f61e293217. This reverts commit aba29fb7dd236ecd8f784672c50236d7983332a0. This reverts commit 844f2a75cacfce0b42f42a37a12819612f00b3e5. This reverts commit a55e472e9fdeb4b0373199463119b340b0cf90a3. This reverts commit 53d32c325c808d6e965a45cdf36aca1a71db2183. --- .../client/sni/ClientSNICQAcceptanceTest.java | 18 +--- .../sni/DualServerSNIAcceptanceTest.java | 28 +---- .../sni/GenerateSNIKeyAndTrustStores.java | 7 +- .../client/sni/dual-server-docker-compose.yml | 70 ------------ .../geode/client/sni/dual-server-haproxy.cfg | 44 -------- .../geode-config/locator-maeve-keystore.jks | Bin 3514 -> 3529 bytes .../server-clementine-keystore.jks | Bin 3520 -> 3537 bytes .../geode-config/server-dolores-keystore.jks | Bin 3515 -> 3533 bytes .../client/sni/geode-config/truststore.jks | Bin 1129 -> 1129 bytes .../client/sni/scripts/create-regions.gfsh | 20 ---- .../client/sni/scripts/geode-starter-2.gfsh | 23 ++++ .../client/sni/scripts/geode-starter.gfsh | 2 +- .../client/sni/scripts/locator-maeve.gfsh | 18 ---- .../client/sni/scripts/server-clementine.gfsh | 18 ---- .../client/sni/scripts/server-dolores.gfsh | 18 ---- .../StartLocatorCommandIntegrationTest.java | 8 +- ...nectWithClusterConfigurationDUnitTest.java | 34 +++--- .../geode/distributed/LocatorDUnitTest.java | 3 +- ...usterManagementServiceIntegrationTest.java | 41 +------ .../InternalLocatorIntegrationTest.java | 8 +- .../membership/MembershipJUnitTest.java | 9 +- .../org/apache/geode/distributed/Locator.java | 39 +++---- .../geode/distributed/LocatorLauncher.java | 78 ++++++-------- .../internal/InternalDistributedSystem.java | 6 +- .../distributed/internal/InternalLocator.java | 66 ++++-------- .../distributed/internal/ServerLocator.java | 7 +- .../membership/adapter/ServiceConfig.java | 5 +- .../geode/internal/DistributionLocator.java | 30 ++++-- .../admin/remote/DistributionLocatorId.java | 7 +- .../geode/internal/net/SocketCreator.java | 12 +++ .../apache/geode/internal/tcp/Connection.java | 8 +- .../cli/commands/StartLocatorCommand.java | 9 +- .../cli/shell/JmxOperationInvoker.java | 3 +- .../GMSLocatorRecoveryIntegrationTest.java | 5 +- .../gms/membership/GMSJoinLeaveJUnitTest.java | 100 ++++-------------- .../api/MembershipLocatorBuilder.java | 4 +- .../membership/gms/GMSMemberData.java | 2 + .../membership/gms/GMSMembership.java | 7 +- .../gms/MembershipLocatorBuilderImpl.java | 6 +- .../membership/gms/interfaces/JoinLeave.java | 12 +-- .../membership/gms/locator/GMSLocator.java | 7 +- .../gms/locator/MembershipLocatorImpl.java | 8 +- .../gms/membership/GMSJoinLeave.java | 76 +++++-------- .../gms/messenger/JGroupsMessenger.java | 7 +- .../internal/tcpserver/HostAddress.java | 56 ---------- .../internal/tcpserver/HostAndPort.java | 81 +++++++++++--- .../internal/tcpserver/InetSocketWrapper.java | 100 ------------------ .../geode/internal/cache/wan/WANTestBase.java | 3 +- 48 files changed, 317 insertions(+), 796 deletions(-) delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-docker-compose.yml delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-haproxy.cfg delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/scripts/create-regions.gfsh create mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/scripts/geode-starter-2.gfsh delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/scripts/locator-maeve.gfsh delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/scripts/server-clementine.gfsh delete mode 100644 geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/scripts/server-dolores.gfsh delete mode 100644 geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAddress.java delete mode 100644 geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/InetSocketWrapper.java diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/ClientSNICQAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/ClientSNICQAcceptanceTest.java index dfe19519a6ca..e1943d5f0cb8 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/ClientSNICQAcceptanceTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/ClientSNICQAcceptanceTest.java @@ -115,19 +115,11 @@ public static void beforeClass() throws IOException, InterruptedException { } @AfterClass - public static void afterClass() { - printlog("locator-maeve"); - printlog("server-dolores"); - } - - private static void printlog(String name) { - try { - String output = - docker.get().exec(options("-T"), "geode", - arguments("cat", name + "/" + name + ".log")); - System.out.println(name + " log file--------------------------------\n" + output); - } catch (Throwable ignore) { - } + public static void afterClass() throws Exception { + String output = + docker.get().exec(options("-T"), "geode", + arguments("cat", "server-dolores/server-dolores.log")); + System.out.println("Server log file--------------------------------\n" + output); } @Before diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/DualServerSNIAcceptanceTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/DualServerSNIAcceptanceTest.java index 7423b9573906..7b08be2b0429 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/DualServerSNIAcceptanceTest.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/DualServerSNIAcceptanceTest.java @@ -31,7 +31,6 @@ import com.palantir.docker.compose.DockerComposeRule; import org.junit.After; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -61,7 +60,7 @@ public class DualServerSNIAcceptanceTest { private static final URL DOCKER_COMPOSE_PATH = - DualServerSNIAcceptanceTest.class.getResource("dual-server-docker-compose.yml"); + SingleServerSNIAcceptanceTest.class.getResource("docker-compose.yml"); // Docker compose does not work on windows in CI. Ignore this test on windows // Using a RuleChain to make sure we ignore the test before the rule comes into play @@ -75,17 +74,8 @@ public class DualServerSNIAcceptanceTest { @BeforeClass public static void beforeClass() throws Exception { - docker.get().exec(options("-T"), "locator-maeve", - arguments("gfsh", "run", "--file=/geode/scripts/locator-maeve.gfsh")); - - docker.get().exec(options("-T"), "server-dolores", - arguments("gfsh", "run", "--file=/geode/scripts/server-dolores.gfsh")); - - docker.get().exec(options("-T"), "server-clementine", - arguments("gfsh", "run", "--file=/geode/scripts/server-clementine.gfsh")); - - docker.get().exec(options("-T"), "locator-maeve", - arguments("gfsh", "run", "--file=/geode/scripts/create-regions.gfsh")); + docker.get().exec(options("-T"), "geode", + arguments("gfsh", "run", "--file=/geode/scripts/geode-starter-2.gfsh")); final String trustStorePath = createTempFileFromResource(SingleServerSNIAcceptanceTest.class, @@ -107,18 +97,6 @@ public void after() { ensureCacheClosed(); } - @AfterClass - public static void afterClass() throws Exception { - // if you need to capture logs for one of the processes use this pattern: - // try { - // String output = - // docker.get().exec(options("-T"), "locator-maeve", - // arguments("cat", "locator-maeve/locator-maeve.log")); - // System.out.println("Locator log file--------------------------------\n" + output); - // } catch (Throwable ignore) { - // } - } - @Test public void successfulRoutingTest() { verifyPutAndGet("group-dolores", "region-dolores"); diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/GenerateSNIKeyAndTrustStores.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/GenerateSNIKeyAndTrustStores.java index b48054afae36..1e5168ccefff 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/GenerateSNIKeyAndTrustStores.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/client/sni/GenerateSNIKeyAndTrustStores.java @@ -15,6 +15,7 @@ package org.apache.geode.client.sni; import java.io.File; +import java.net.InetAddress; import java.net.URL; import org.apache.geode.cache.ssl.CertStores; @@ -50,8 +51,10 @@ public void generateStores() throws Exception { CertificateMaterial certificate = new CertificateBuilder(365 * 100, "SHA256withRSA") .commonName(certName) .issuedBy(ca) - .sanDnsName(certName) - .sanDnsName("geode") + .sanDnsName("geode") // for inside the docker container + .sanDnsName("localhost") // for inside the docker container + .sanIpAddress(InetAddress.getByName("0.0.0.0")) // for inside the docker container + .sanDnsName(certName) // for client endpoint validation .generate(); CertStores store = new CertStores(certName); diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-docker-compose.yml b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-docker-compose.yml deleted file mode 100644 index f22e60a424f9..000000000000 --- a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-docker-compose.yml +++ /dev/null @@ -1,70 +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. -# -version: '3.5' -services: - locator-maeve: - container_name: 'locator-maeve' - image: 'geode:develop' - hostname: locator-maeve - expose: - - '10334' - entrypoint: 'sh' - command: '-c /geode/scripts/forever' - networks: - geode-sni-test: - volumes: - - ./geode-config:/geode/config:ro - - ./scripts:/geode/scripts - server-clementine: - container_name: 'server-clementine' - image: 'geode:develop' - hostname: server-clementine - expose: - - '8501' - entrypoint: 'sh' - command: '-c /geode/scripts/forever' - networks: - geode-sni-test: - volumes: - - ./geode-config:/geode/config:ro - - ./scripts:/geode/scripts - server-dolores: - container_name: 'server-dolores' - image: 'geode:develop' - hostname: server-dolores - expose: - - '8502' - entrypoint: 'sh' - command: '-c /geode/scripts/forever' - networks: - geode-sni-test: - volumes: - - ./geode-config:/geode/config:ro - - ./scripts:/geode/scripts - haproxy: - container_name: 'haproxy' - image: 'haproxy:2.1' - ports: - - "15443" - networks: - geode-sni-test: - volumes: - - ./dual-server-haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro -networks: - geode-sni-test: - name: geode-sni-test - diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-haproxy.cfg b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-haproxy.cfg deleted file mode 100644 index 130f8049f40e..000000000000 --- a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/dual-server-haproxy.cfg +++ /dev/null @@ -1,44 +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. -# - -defaults - timeout client 1000 - timeout connect 1000 - timeout server 1000 - -frontend sniproxy - bind *:15443 - mode tcp - tcp-request inspect-delay 5s - tcp-request content accept if { req_ssl_hello_type 1 } - use_backend locators-maeve if { req.ssl_sni -i locator-maeve } - use_backend servers-dolores if { req.ssl_sni -i server-dolores } - use_backend servers-clementine if { req.ssl_sni -i server-clementine } - default_backend locators-maeve - log stdout format raw local0 debug - -backend locators-maeve - mode tcp - server locator1 locator-maeve:10334 - -backend servers-dolores - mode tcp - server server1 server-dolores:8501 - -backend servers-clementine - mode tcp - server server1 server-clementine:8502 diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/locator-maeve-keystore.jks b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/locator-maeve-keystore.jks index cce17bd30a2edcc639a72adf8f2e57ec151de1cf..ec2feb85baa0e5d128fb95c66e31c2d3355434bd 100644 GIT binary patch literal 3529 zcmeH|XHe7G8piVv2_>|I7FqzK6bVQOf)oKMB2opF66paFVgf?w-9SL3ElLv*P!ti6 zMUr%$L4TMg<0TRMV3PykDZe8mcI!Z4fw1W*Pe000Vt&>>4mt&jpM zr&Rkd6TxC42d=IuKMLvYsE|Zj(S^@a+M}bE{yc@5_vbQ8oY0gnn{c| zTX{e8k`fO(r&40jytIhl{&j-Tq%b0>maSqQKAi}UX<@-1?B2T36i-k)s;aW*SFtEw zGc#9){eVh;tJC`mX0Z`^y{hQcl)=`yt;IRG`rTGjzQ%Xfc0;LLjjoufNgG@7*GR2} zdazdtd7&;vt9ePK+Um7;PbXFEsd=7+dx?twFK6F3F_rF)mogX#VmqWpj~p0swSZ`s zxRKywxskt2ROkZ4LS~#%C&ds2!eQFUDTS><4E$(HI8#8mu4DN@*8%k82uWowqSWSH75%m4|^9akO$g%QbL$cjeQyM0bhogIagv-T{L?BQ1SUs{Lm zQ^t-40LElTe{8T^?bzEF_Y9|aQ)OMaz>{9^-0r(c9CnXFX*HU+n6K~e2=yffSCD!7 zmwpki*I5`{z{4-?`8urDqw2XoC~%6ZdXO;KU?3>bl%2fEDAGC}x~*k4)*Xo=+q)XQzF(BVoJd}7sY ztn6afJz4afr)901b#7(XH{>_AqHd?E2+7)*fPOBTK>cI7QjJltAT4O`!>aj=2)xSgvpQtYMfWu(%+P?Pe3D(I|3YzRncD5>lTh%;Z`T?xyYbfjsu-&-+Rd5_&p<#YwZ}0HM}bOavdtc=gO^e zA&qW**f+kiIu$i@jGVSoslR7N#KSiAk?c?Q2kAidz4k!<8vbE}r_L|JQl3Ddj$dH0 zPL_$!6MV&BE4bZBL(O{=Tk>kc`fIDJgGlB zc-~t&q7oxL6fdzjzAj`Yn=JckcY~&DJRfu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+q&?71CU6leLWVvaK>s)8QX zn}#7rFdK{Wv4zYKZ0X6mn=4hf}z27Nva0lvU`K--Gt{>+H0&`57Oi~Lyv&sx*W?h`Ue)f22=n5 diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/server-clementine-keystore.jks b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/server-clementine-keystore.jks index 5eb5b8881d08d8c230d2a4bf7a528aa9e788c152..626269da26f2dc3fd1155d2434b78d63bead048a 100644 GIT binary patch literal 3537 zcmeH|XHe7G8piVv2@pa8p(@=h0#ZX2q!&RD5mc%WN{m1tL)aA_XcDJ@FJgOAYJ?TUUTUPyj=N>|&7YTng*}1ds=#000Vt&>%}h3T#W* zPXhY5{d4Y``ZEp3wtF>H^bU8|qB{~Fsu>|b=uxohy8BuG!Nq*US>~#3vuVu*%#^xm z!N2yIhDPjzUFWWJ2}lkUoi;<7-Zz1DP4GQ!Xklh1T^;_RzHC!+!bQuvewn+k5;JT z$}V+Hx?{~+eZz0MZ2V25Dq5DPF>zWMZq7LPzWR{oPgbeTkk;S>(+AvBXMF@CC@WA4* z8L*n()s{`yB$saWXh5gpR%>{I-Is>3SX-IbjwPH&7RRFl;QMt`HOJPKh9KZbs~NN4 zv6vbD4hJJ#X`}Jiq2?+bXZgGY8*T_>9#z=uD}UZwWh7q0IT3!JsNL(s+G?ccSlkOZ2-DDnbnz^^cBr}UCY{9C>a~S1=PtDLGm2CC35+>E zA>u40;R!wYmKz_#tiQ4%9b*r}UJ4ydI5|$i+{NySbp5h(WvSDDeZJ_t?1m^#@x6pa zn(3jrrL5Hb>Vffq5`(&2-j=2CaQH{wBN3i?^6r{9bLdU_tuy%hkt9oFg{dGJX@@Di z!x+b@b)&3`( z4lq*^L+0qdra7d+OMgMC#ZAZKZFAOC?PPBAxsF-hZ(Hb0?8yv`-?{$kCF1bIX&0## zM?qqkSCWfEsUIox`WwZ-ODSa|UaFq!PJ3+CE4lUcWoSKXn=8{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{1&n-`ZRc1R8Eewk3*UCs+!bCF({~Cv zP=AEq>)Lc7KU>eEVZbY--de=?S3gtN*avg&oNDEAhXU2@TDA#r2ZKfCqt5!+!rtzB ze*=e;xrSHb@0NP+8ofu^#*88lu}s(R9mQ0b;iGBO>6kf!sfdV*pH=y+-lvuaM-AY#OjzGq%dTg6CUT)C@ z=`i0)M0B6zjP{zKC7h!?q^^Oup#!h%Kd;BH)TU!%4M`l=i4Z_kOTu5KD&HpJ33Ttl z?&96ITGZ!ye4pFN9PLtA0lRYtP7!Ps?gxfSCmaRiH7{9v%-yR-eS z*e*w~1^3&Nx_15ikB>fXPPZ?O6sH%IrcKcEFY9!5!91$IbS)Gi|1HOH-u`?3bX^_+ z0Gm)K1Pq3vBz_RF<;Oig3dXyDfgk4nk8u1QF%RcIY`{-Az>yOfy~Bz*>m8o!6|XW& z3_0M-44!?`j_nu%F9rW7h-^W#|q;1i;W zaF@+45AfBii=qjWL3ZyY@}RLb=@DoV2Z5170dZMxuXSVN7x{GNV&DijdP!+JQpGJe z@q(ds*iu6IMemN=Z@1kze_IIMmFL7wl62EnLY|#$J1N8+O}VbzXXUxj9}kW9&oFmc zE9#27AFTd%uC>+||2@xeTLLOvYVK)enMo*m0qc9h`9V F{GZ*|>FfXi diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/server-dolores-keystore.jks b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/server-dolores-keystore.jks index 490c75af8b481613efd31f4118b1069d835211d7..54de8d6b0abb6feabc3afa88b7a3d9bdc62f2da3 100644 GIT binary patch literal 3533 zcmeH|XHe7G8pi*BQb0ONQ$mZ<5fdUsiiRSBQluj&(jtPvAb|*qlmHI{1OY>{ zA)tgJN?UpnK?FpkC^ZNXSQO%o?!9+*ydU z{wx7J!P_&K5VSkM6Gy^v)SwnFn@j+JK~QAqca$KUR}BtAK~*jh5QG6xGIY-8s|yQ; z{&r}IeX+EVbj_kO-l5Bx@%)=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AS)@|bbaQ6maU{AKD~HA82$xaIDv8|;H5zfwO9<8Kh*8c#>ng#;2WxW4Q!*Q@PT zSRU{gwv@8p^Z4dYPHIlcQMO5Uq1ZiV5J#Du>tR4 zZuQ;n)h=3iw7{D0U8k0luT@^0zEE^YokHPsssBv*R4V=l8}97=$Nv(28$STBpil@H z3`Gn5BtrP-JvW+@eE|bM!TlfM_&Z{@%)f2GFF3#v)7ei)Wv_mJi2r_TBIi1e9;Y0R znM}|Mi5c=ZQkJy;(VDL4?T#4iZC`#d&N1`UdosNSR!jw6xa0}d>oO?b&y4I z0q5ndArfW+Ea!v@p)t+m(-^olj9LN{lyW`xU0;8!=t9MsFO?a!E+-?t!!aoN9ByCm zdcw^#*N1hp$g;C_yckNMEi*;LQB6)fe&)UxFLUyIG3uE){?kw#G|oHQ^x)T0O6kWTMGXfB1Mzp?ob>t!FTnT( diff --git a/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/truststore.jks b/geode-assembly/src/acceptanceTest/resources/org/apache/geode/client/sni/geode-config/truststore.jks index 69b434607380454267f12ca670c956e7f5307cb3..a381a9a1b4bcc48ec5e357ec93632b182365de55 100644 GIT binary patch literal 1129 zcmezO_TO6u1_mY|W(3nr$%#N_(FrE+bOzQ4JyQcq1_l;AgC-U&gC=I71YkdPl4_tJ&TC{~U}k7xXbQweQ4;({hCl&RBU7jVQKmF8Dj{3W$jZRn#K_NJ(8S2a z)Wpch(05rRH?AT~?&!ms%DU#c9^dPW?|-eIy5L{KrZTArQMcClRlQf|y8YYs>$do+ z$cZYVvpVj{aW!vER_Xa>yh|{6zANuaYq_3d;)UbJ7zvGm8g)w1V^adh6!vSyt3m?!)0&#Y-Xh3jwY96DjVX5&#y1;JMe2VX5-k#kw6 zORm>8U8EZwvJZvHm8iQD^)(&FbAMRR3+-IEY#-YyZ4*g~4x7QYBxy#;yxE7|^?mFM zXn1=l0^~d*RcP zGeha}j*BxrTaDJA6EOJfeBR-zcATt5@Qz1{CDUG4E_)?Z{4r|dxdjYyj`phI9jgTo zKKsdYMYfyk{lCve%s!Ik87<9+Gp8MydTysplv3`e)lb&3e7nK@fg!n~ah^G&{=<{4 z(`6F1H{8r`el$HYPoZCQMsj)v*Sh)QD}2QqyI0v)hQ+(*YP_wyk*R*d%TDlN?unvm z1An6yjS9CLr%bH3PA)z(_u9rK7iu?ry1l$5%IlWeR~bj^VxyKtyoWNqKJ1+@;p#K# NnwWi{)zumQ8vt=sx5@wj literal 1129 zcmezO_TO6u1_mY|W(3nr$%#N_#k!tlRSc{VdZq@J3=AxK22Ctl22IRD3z(T0nV2{k z{;plt)HG?GxdAU5r&gOs+jm|@Ms8LH10_QN13ot9P!?t$_K?)#5(Q^RLp}o@kO&tK zt9xpGN~(c^IIoeRfr){+k&!77L`m=)83F~24Naf|M48gWsDx}eBP#=Q6C*!^K@%ev zQxhX2!;)?6p0B0re)3rI^u#6Hc&TLA7FQB?|5)_fLYbn~yjt1zVMkdSP78PYbx+bM zJgw`^xO$FiS8JK=zlHZof?2EDkNTMrx0eSY-$|7VB4TwgqC-m<=X zU2`Yuo;=AGwf^(Tj|;__m>C%u7dJ7+14ASl94E5;jEw(TSeTiZSPX=KF(NAr;&T|V z0VyU%P{{4Ja@g!~}yFIS~SL05B0UGBB0jn|$`F!puKMqW`SCIc162 zyIRdM!&~)6Mb+mM!WT7q9Q|Z2x^+*r>DDxUF}7_PueMlnsB_KC0lezxZmp*bwonBeuBD&SuK%n2 zq9`w}9GctQVdhrwrG7 commandLines = ArgumentCaptor.forClass(String[].class); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithClusterConfigurationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithClusterConfigurationDUnitTest.java index 8288ac21d6d5..d2c6d950bfcf 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithClusterConfigurationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectWithClusterConfigurationDUnitTest.java @@ -31,8 +31,6 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; -import java.net.UnknownHostException; -import java.nio.file.Paths; import java.util.List; import java.util.Properties; import java.util.concurrent.TimeUnit; @@ -41,18 +39,16 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TemporaryFolder; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.Locator; +import org.apache.geode.distributed.internal.InternalConfigurationPersistenceService; import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.distributed.internal.membership.api.MembershipManagerHelper; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.internal.inet.LocalHostUtil; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.AsyncInvocation; @@ -72,14 +68,10 @@ public class ReconnectWithClusterConfigurationDUnitTest implements Serializable static Properties dsProperties; @Rule - public transient DistributedRule distributedRule = - DistributedRule.builder().withVMCount(NUM_VMS).build(); - - @Rule - public transient TemporaryFolder temporaryFolder = new TemporaryFolder(); + public DistributedRule distributedRule = DistributedRule.builder().withVMCount(NUM_VMS).build(); @Before - public void setup() throws IOException { + public void setup() { List randomAvailableTCPPortKeepers = AvailablePortHelper.getRandomAvailableTCPPortKeepers(NUM_LOCATORS); for (int i = 0; i < NUM_LOCATORS; i++) { @@ -89,7 +81,6 @@ public void setup() throws IOException { final int[] locPorts = locatorPorts; Invoke.invokeInEveryVM("set locator ports", () -> locatorPorts = locPorts); for (int i = 0; i < NUM_LOCATORS; i++) { - final String workingDir = temporaryFolder.newFolder().getAbsolutePath(); final int locatorNumber = i; randomAvailableTCPPortKeepers.get(locatorNumber).release(); VM.getVM(i).invoke("start locator", () -> { @@ -97,9 +88,7 @@ public void setup() throws IOException { Disconnect.disconnectFromDS(); dsProperties = null; Properties props = getDistributedSystemProperties(); - locator = InternalLocator.startLocator(locatorPorts[locatorNumber], new File(""), - null, null, new HostAddress(LocalHostUtil.getLocalHost()), true, - props, null, Paths.get(workingDir)); + locator = Locator.startLocatorAndDS(locatorPorts[locatorNumber], new File(""), props); system = locator.getDistributedSystem(); cache = ((InternalLocator) locator).getCache(); IgnoredException.addIgnoredException( @@ -117,8 +106,10 @@ public void teardown() { VM.getVM(i).invoke(() -> { InternalLocator locator = InternalLocator.getLocator(); if (locator != null) { - if (cache != null && cache.isReconnecting()) { - cache.stopReconnecting(); + InternalConfigurationPersistenceService sharedConfig = + locator.getConfigurationPersistenceService(); + if (sharedConfig != null) { + sharedConfig.destroySharedConfiguration(); } locator.stop(); } @@ -133,7 +124,7 @@ public void teardown() { }); } - public Properties getDistributedSystemProperties() throws UnknownHostException { + public Properties getDistributedSystemProperties() { dsProperties = new Properties(); dsProperties.put(MAX_WAIT_TIME_RECONNECT, "" + (5000 * NUM_VMS)); dsProperties.put(ENABLE_NETWORK_PARTITION_DETECTION, "true"); @@ -142,13 +133,12 @@ public Properties getDistributedSystemProperties() throws UnknownHostException { dsProperties.put(USE_CLUSTER_CONFIGURATION, "true"); dsProperties.put(HTTP_SERVICE_PORT, "0"); StringBuilder stringBuilder = new StringBuilder(); - final String localHostName = LocalHostUtil.getLocalHostName(); - stringBuilder.append(localHostName + "[") + stringBuilder.append("localHost[") .append(locatorPorts[0]) .append(']'); for (int i = 1; i < NUM_LOCATORS; i++) { - stringBuilder.append("," + localHostName + "[") - .append(locatorPorts[i]) + stringBuilder.append(",localHost[") + .append(locatorPorts[0]) .append(']'); } dsProperties.put(LOCATORS, stringBuilder.toString()); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java index e0f8966c281d..d3c17332f4ae 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java @@ -1002,8 +1002,7 @@ public void testNoLocator() { } catch (GemFireConfigException ex) { String s = ex.getMessage(); - assertThat(s.contains("Could not contact any of the locators")) - .isTrue(); + assertThat(s.contains("Locator does not exist")).isTrue(); } } diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorClusterManagementServiceIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorClusterManagementServiceIntegrationTest.java index 58598c0a87e7..0e0226ee6606 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorClusterManagementServiceIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorClusterManagementServiceIntegrationTest.java @@ -28,12 +28,10 @@ import java.util.Optional; import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.internal.HttpService; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.cache.InternalCacheForClientAccess; import org.apache.geode.internal.cache.InternalRegionFactory; @@ -45,40 +43,11 @@ public class InternalLocatorClusterManagementServiceIntegrationTest { private InternalLocator internalLocator; // the instance under test - private DistributionConfigImpl distributionConfig; - private InternalCacheForClientAccess cache; - private BaseManagementService managementService; - private AgentUtil agentUtil; - private HttpService httpService; - - @Before - public void setup() throws URISyntaxException { - distributionConfig = mock(DistributionConfigImpl.class); - cache = mock(InternalCacheForClientAccess.class); - managementService = mock(BaseManagementService.class); - agentUtil = mock(AgentUtil.class); - httpService = mock(HttpService.class); - InternalRegionFactory regionFactory = mock(InternalRegionFactory.class); - LoggingSession loggingSession = mock(LoggingSession.class); - URI uri = new URI("file", "/management.war", null); - - when(distributionConfig.getJmxManager()).thenReturn(true); - when(distributionConfig.getJmxManagerPort()) - .thenReturn(AvailablePortHelper.getRandomAvailableTCPPort()); - when(distributionConfig.getLocators()).thenReturn(""); - when(distributionConfig.getSecurableCommunicationChannels()) - .thenReturn(new SecurableCommunicationChannel[] {}); - when(distributionConfig.getSecurityAuthTokenEnabledComponents()).thenReturn(new String[] {}); - when(cache.createInternalRegionFactory(RegionShortcut.REPLICATE)).thenReturn(regionFactory); - when(cache.getOptionalService(HttpService.class)) - .thenReturn(Optional.of(httpService)); - when(cache.getCacheForProcessingClientRequests()).thenReturn(cache); - when(agentUtil.findWarLocation("geode-web-management")).thenReturn(uri); - BaseManagementService.setManagementService(cache, managementService); - - internalLocator = new InternalLocator(0, loggingSession, null, null, null, (HostAddress) null, - null, null, distributionConfig, null); - } + private DistributionConfigImpl distributionConfig = mock(DistributionConfigImpl.class); + private InternalCacheForClientAccess cache = mock(InternalCacheForClientAccess.class); + private BaseManagementService managementService = mock(BaseManagementService.class); + private AgentUtil agentUtil = mock(AgentUtil.class); + private HttpService httpService = mock(HttpService.class); @After public void tearDown() { diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java index f5041d42a0ae..09efe36b3596 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalLocatorIntegrationTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.net.InetAddress; import java.nio.file.Path; import java.util.Properties; @@ -36,7 +37,6 @@ import org.mockito.quality.Strictness; import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.internal.logging.InternalLogWriter; import org.apache.geode.internal.security.SecurableCommunicationChannel; import org.apache.geode.logging.internal.LoggingSession; @@ -58,7 +58,7 @@ public class InternalLocatorIntegrationTest { private InternalLogWriter logWriter; @Mock private InternalLogWriter securityLogWriter; - private HostAddress bindAddress; + private InetAddress bindAddress; private String hostnameForClients; @Mock private Properties distributedSystemProperties; @@ -98,9 +98,7 @@ public void constructs() { assertThatCode(() -> { internalLocator = new InternalLocator(port, loggingSession, logFile, logWriter, securityLogWriter, - bindAddress, - hostnameForClients, - distributedSystemProperties, distributionConfig, + bindAddress, hostnameForClients, distributedSystemProperties, distributionConfig, workingDirectory); }).doesNotThrowAnyException(); } diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java index 08f4fe1f7b1a..cb3c19a370c2 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.io.File; +import java.net.InetAddress; import java.util.Comparator; import java.util.List; import java.util.Properties; @@ -65,7 +66,6 @@ import org.apache.geode.distributed.internal.membership.api.MembershipLocator; import org.apache.geode.distributed.internal.membership.api.MembershipView; import org.apache.geode.distributed.internal.membership.api.MessageListener; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.TcpClient; import org.apache.geode.distributed.internal.tcpserver.TcpSocketCreator; import org.apache.geode.distributed.internal.tcpserver.TcpSocketFactory; @@ -137,7 +137,7 @@ private List doTestMultipleManagersInSameProcessWithGroups(String groups // boot up a locator int port = AvailablePortHelper.getRandomAvailableTCPPort(); - HostAddress localHost = new HostAddress(LocalHostUtil.getLocalHost()); + InetAddress localHost = LocalHostUtil.getLocalHost(); // this locator will hook itself up with the first Membership // to be created @@ -328,14 +328,13 @@ public void testLocatorAndTwoServersJoinUsingDiffeHellman() throws Exception { // boot up a locator int port = AvailablePortHelper.getRandomAvailableTCPPort(); - HostAddress localHost = new HostAddress(LocalHostUtil.getLocalHost()); + InetAddress localHost = LocalHostUtil.getLocalHost(); Properties p = new Properties(); p.setProperty(ConfigurationProperties.SECURITY_UDP_DHALGO, "AES:128"); // this locator will hook itself up with the first Membership // to be created internalLocator = - InternalLocator.startLocator(port, new File(""), null, null, localHost, false, p, - null, + InternalLocator.startLocator(port, new File(""), null, null, localHost, false, p, null, temporaryFolder.getRoot().toPath()); // create configuration objects diff --git a/geode-core/src/main/java/org/apache/geode/distributed/Locator.java b/geode-core/src/main/java/org/apache/geode/distributed/Locator.java index 0a62382e5dcc..e4b2c9883319 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/Locator.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/Locator.java @@ -22,7 +22,6 @@ import java.util.Properties; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.internal.inet.LocalHostUtil; /** @@ -64,11 +63,8 @@ public abstract class Locator { /** The file to which this locator logs */ protected File logFile; - /** no longer used but kept for binary compatibility */ - protected InetAddress bindAddress; - /** The bind address for this locator */ - protected HostAddress hostAddress; + protected InetAddress bindAddress; /** * the hostname to give to clients so they can connect to this locator. @@ -105,7 +101,7 @@ public abstract class Locator { */ public static Locator startLocator(int port, File logFile) throws IOException { - return startLocator(port, logFile, false, null, null, true, true, + return startLocator(port, logFile, false, (InetAddress) null, (Properties) null, true, true, null); } @@ -140,7 +136,7 @@ public static Locator startLocator(int port, File logFile) throws IOException { public static Locator startLocatorAndDS(int port, File logFile, Properties distributedSystemProperties) throws IOException { - return startLocator(port, logFile, null, distributedSystemProperties, true, true, + return startLocator(port, logFile, (InetAddress) null, distributedSystemProperties, true, true, null); } @@ -169,9 +165,8 @@ public static Locator startLocatorAndDS(int port, File logFile, */ public static Locator startLocator(int port, File logFile, InetAddress bindAddress) throws IOException { - HostAddress hostAddress = bindAddress == null ? null : new HostAddress(bindAddress); - return startLocator(port, logFile, false, hostAddress, null, true, - true, null); + + return startLocator(port, logFile, false, bindAddress, (Properties) null, true, true, null); } @@ -203,9 +198,7 @@ public static Locator startLocator(int port, File logFile, InetAddress bindAddre */ public static Locator startLocatorAndDS(int port, File logFile, InetAddress bindAddress, java.util.Properties dsProperties) throws IOException { - HostAddress hostAddress = bindAddress == null ? null : new HostAddress(bindAddress); - return startLocator(port, logFile, hostAddress, dsProperties, true, true, - null); + return startLocator(port, logFile, bindAddress, dsProperties, true, true, null); } /** @@ -246,16 +239,14 @@ public static Locator startLocatorAndDS(int port, File logFile, InetAddress bind public static Locator startLocatorAndDS(int port, File logFile, InetAddress bindAddress, java.util.Properties dsProperties, boolean peerLocator, boolean serverLocator, String hostnameForClients) throws IOException { - HostAddress hostAddress = bindAddress == null ? null : new HostAddress(bindAddress); - return startLocator(port, logFile, hostAddress, dsProperties, true, true, - hostnameForClients); + return startLocator(port, logFile, bindAddress, dsProperties, true, true, hostnameForClients); } /** * all Locator methods that start locators should use this method to start the locator and its * distributed system */ - private static Locator startLocator(int port, File logFile, HostAddress bindAddress, + private static Locator startLocator(int port, File logFile, InetAddress bindAddress, java.util.Properties dsProperties, boolean peerLocator, boolean serverLocator, String hostnameForClients) throws IOException { return InternalLocator.startLocator(port, logFile, null, null, bindAddress, true, dsProperties, @@ -267,7 +258,7 @@ private static Locator startLocator(int port, File logFile, HostAddress bindAddr * peerLocator, serverLocator, hostnameForClients) instead. */ private static Locator startLocator(int port, File logFile, boolean startDistributedSystem, - HostAddress bindAddress, java.util.Properties dsProperties, boolean peerLocator, + InetAddress bindAddress, java.util.Properties dsProperties, boolean peerLocator, boolean serverLocator, String hostnameForClients) throws IOException { return InternalLocator.startLocator(port, logFile, null, null, bindAddress, startDistributedSystem, dsProperties, hostnameForClients); @@ -341,7 +332,7 @@ public File getLogFile() { * Returns the IP address to which this locator's listening socket is bound. */ public InetAddress getBindAddress() { - return bindAddress; + return this.bindAddress; } /** @@ -391,16 +382,14 @@ public String toString() { * Get the string representation of this Locator in host[port] format. */ public String asString() { - String bindAddressString = null; - if (hostAddress == null) { + Object ba = this.bindAddress; + if (ba == null) { try { - bindAddressString = LocalHostUtil.getLocalHostName(); + ba = LocalHostUtil.getLocalHostName(); } catch (java.net.UnknownHostException uh) { } - } else { - bindAddressString = hostAddress.getHostName(); } - StringBuilder locatorString = new StringBuilder(String.valueOf(bindAddressString)); + StringBuilder locatorString = new StringBuilder(String.valueOf(ba)); Integer port = getPort(); if (port != null && port.intValue() > 0) { locatorString.append('[').append(this.getPort()).append(']'); diff --git a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java index bab4a14c1ece..0cd015e27ece 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java @@ -60,7 +60,6 @@ import org.apache.geode.cache.client.internal.locator.LocatorStatusRequest; import org.apache.geode.cache.client.internal.locator.LocatorStatusResponse; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.HostAndPort; import org.apache.geode.distributed.internal.tcpserver.TcpClient; import org.apache.geode.distributed.internal.tcpserver.TcpSocketCreator; @@ -188,7 +187,7 @@ public class LocatorLauncher extends AbstractLauncher { private final boolean portSpecified; private final boolean workingDirectorySpecified; - private final HostAddress bindAddress; + private final InetAddress bindAddress; private final Integer pid; private final Integer port; @@ -260,7 +259,7 @@ private LocatorLauncher(final Builder builder) { this.command = builder.getCommand(); this.help = Boolean.TRUE.equals(builder.getHelp()); this.bindAddressSpecified = builder.isBindAddressSpecified(); - this.bindAddress = builder.getHostAddress(); + this.bindAddress = builder.getBindAddress(); setDebug(Boolean.TRUE.equals(builder.getDebug())); this.deletePidFileOnStop = Boolean.TRUE.equals(builder.getDeletePidFileOnStop()); this.distributedSystemProperties = builder.getDistributedSystemProperties(); @@ -298,31 +297,19 @@ public ServiceState handleStatus() { @Deprecated public static LocatorStatusResponse statusLocator(int port, InetAddress bindAddress) throws IOException { - return statusLocator(port, bindAddress == null ? null : bindAddress.getCanonicalHostName(), - new Properties()); - } - - /** - * Returns the status of the locator on the given host & port. If you have endpoint - * identification enabled the preferred method is statusForLocator(int, String), which - * lets you specify the locator's name that the locator has stored in its TLS certificate - */ - public LocatorStatusResponse statusForLocator(int port, InetAddress bindAddress) - throws IOException { - return statusLocator(port, bindAddress == null ? null : bindAddress.getCanonicalHostName(), - getProperties()); + return statusLocator(port, bindAddress, new Properties()); } /** * Returns the status of the locator on the given host & port */ - public LocatorStatusResponse statusForLocator(int port, String hostname) + public LocatorStatusResponse statusForLocator(int port, InetAddress bindAddress) throws IOException { - return statusLocator(port, hostname, getProperties()); + return statusLocator(port, bindAddress, getProperties()); } private static LocatorStatusResponse statusLocator( - final int port, String bindAddress, + final int port, InetAddress bindAddress, final Properties properties) throws IOException { @@ -341,7 +328,7 @@ private static LocatorStatusResponse statusLocator( TcpSocketFactory.DEFAULT); return (LocatorStatusResponse) client.requestToServer( - new HostAndPort(bindAddress == null ? HostUtils.getLocalHost() : bindAddress, port), + new HostAndPort(bindAddress == null ? null : bindAddress.getCanonicalHostName(), port), new LocatorStatusRequest(), timeout, true); } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -442,7 +429,7 @@ public boolean isRedirectingOutput() { * @see java.net.InetAddress */ public InetAddress getBindAddress() { - return bindAddress == null ? null : bindAddress.getAddress(); + return this.bindAddress; } /** @@ -461,9 +448,10 @@ public InetAddress getBindAddress() { */ protected String getBindAddressAsString() { try { - if (bindAddress != null) { - return bindAddress.getHostName(); + if (getBindAddress() != null) { + return getBindAddress().getCanonicalHostName(); } + return LocalHostUtil.getCanonicalLocalHostName(); } catch (UnknownHostException handled) { // Returning localhost/127.0.0.1 implies the bindAddress was null and no IP address for @@ -726,8 +714,7 @@ public LocatorState start() { try { this.locator = InternalLocator.startLocator(getPort(), getLogFile(), null, null, - bindAddress, true, getDistributedSystemProperties(), - getHostnameForClients(), + getBindAddress(), true, getDistributedSystemProperties(), getHostnameForClients(), Paths.get(workingDirectory)); } finally { ProcessLauncherContext.remove(); @@ -873,7 +860,7 @@ public LocatorState waitOnStatusResponse(final long timeout, final long interval while (System.currentTimeMillis() < endTimeInMilliseconds) { try { - LocatorStatusResponse response = statusForLocator(getPort(), getBindAddressString()); + LocatorStatusResponse response = statusForLocator(getPort(), getBindAddress()); return new LocatorState(this, Status.ONLINE, response); } catch (Exception handled) { timedWait(interval, timeUnit); @@ -998,7 +985,7 @@ private LocatorState statusWithPid() { private LocatorState statusWithPort() { try { - LocatorStatusResponse response = statusForLocator(getPort(), getBindAddressString()); + LocatorStatusResponse response = statusForLocator(getPort(), getBindAddress()); return new LocatorState(this, Status.ONLINE, response); } catch (Exception handled) { return createNoResponseState(handled, @@ -1199,10 +1186,6 @@ private Properties getOverriddenDefaults() throws IOException { return overriddenDefaults; } - public String getBindAddressString() { - return bindAddress == null ? null : bindAddress.getHostName(); - } - private class LocatorControllerParameters implements ProcessControllerParameters { @Override public File getPidFile() { @@ -1277,7 +1260,7 @@ public static class Builder { private Boolean loadSharedConfigFromDir; private Command command; - private HostAddress bindAddress; + private InetAddress bindAddress; private Integer pid; private Integer port; @@ -1588,18 +1571,14 @@ boolean isBindAddressSpecified() { * @see java.net.InetAddress */ public InetAddress getBindAddress() { - return bindAddress == null ? null : bindAddress.getAddress(); - } - - HostAddress getHostAddress() { - return bindAddress; + return this.bindAddress; } /** * Sets the IP address as an java.net.InetAddress to which the Locator has bound itself * listening for client requests. * - * @param addressString the InetAddress with the IP address or hostname on which the Locator is + * @param bindAddress the InetAddress with the IP address or hostname on which the Locator is * bound and listening. * @return this Builder instance. * @throws IllegalArgumentException wrapping the UnknownHostException if the IP address or @@ -1607,23 +1586,24 @@ HostAddress getHostAddress() { * @see #getBindAddress() * @see java.net.InetAddress */ - public Builder setBindAddress(final String addressString) { - if (isBlank(addressString)) { + public Builder setBindAddress(final String bindAddress) { + if (isBlank(bindAddress)) { this.bindAddress = null; return this; } else { try { - InetAddress address = InetAddress.getByName(addressString); + InetAddress address = InetAddress.getByName(bindAddress); if (LocalHostUtil.isLocalHost(address)) { - this.bindAddress = new HostAddress(addressString); + this.bindAddress = address; return this; } else { throw new IllegalArgumentException( - addressString + " is not an address for this machine."); + bindAddress + " is not an address for this machine."); } } catch (UnknownHostException e) { - throw new IllegalArgumentException("The hostname/IP address (" + addressString - + ") to which the Locator will be bound is unknown.", + throw new IllegalArgumentException( + String.format("The hostname/IP address to which the %s will be bound is unknown.", + "Locator"), e); } } @@ -2150,9 +2130,11 @@ private static String getLocatorLocation(LocatorLauncher launcher) { private static String getBindAddressAsString(LocatorLauncher launcher) { if (InternalLocator.hasLocator()) { final InternalLocator locator = InternalLocator.getLocator(); - String bindAddress = locator.getBindAddressString(); - if (bindAddress != null && !bindAddress.isEmpty()) { - return bindAddress; + final InetAddress bindAddress = locator.getBindAddress(); + if (bindAddress != null) { + if (isNotBlank(bindAddress.getHostAddress())) { + return bindAddress.getHostAddress(); + } } } return launcher.getBindAddressAsString(); diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java index 847e581e70cb..d45df2e0e154 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java @@ -79,7 +79,6 @@ import org.apache.geode.distributed.internal.membership.api.MembershipInformation; import org.apache.geode.distributed.internal.membership.api.MembershipLocator; import org.apache.geode.distributed.internal.membership.api.QuorumChecker; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.internal.Assert; import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.InternalInstantiator; @@ -915,9 +914,8 @@ private void startInitLocator( try { startedLocator = InternalLocator.createLocator(locId.getPort(), NullLoggingSession.create(), null, - logWriter, securityLogWriter, new HostAddress(locId.getHost()), - locId.getHostnameForClients(), originalConfig.toProperties(), - false); + logWriter, securityLogWriter, locId.getHost().getAddress(), + locId.getHostnameForClients(), originalConfig.toProperties(), false); // if locator is started this way, cluster config is not enabled, set the flag correctly startedLocator.getConfig().setEnableClusterConfiguration(false); diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java index 543e1e36fff4..52dad50b8367 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; +import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import java.nio.file.Path; @@ -68,7 +69,6 @@ import org.apache.geode.distributed.internal.membership.api.MembershipLocator; import org.apache.geode.distributed.internal.membership.api.MembershipLocatorBuilder; import org.apache.geode.distributed.internal.membership.api.QuorumChecker; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.InfoRequest; import org.apache.geode.distributed.internal.tcpserver.TcpHandler; import org.apache.geode.distributed.internal.tcpserver.TcpServer; @@ -258,16 +258,13 @@ private static void removeLocator(InternalLocator locator) { * @param startDistributedSystem if true then this locator will also start its own ds * * @deprecated Please use - * {@link #createLocator(int, LoggingSession, File, InternalLogWriter, InternalLogWriter, HostAddress, String, Properties, Path)} + * {@link #createLocator(int, LoggingSession, File, InternalLogWriter, InternalLogWriter, InetAddress, String, Properties, Path)} * instead. */ @Deprecated public static InternalLocator createLocator(int port, LoggingSession loggingSession, File logFile, - InternalLogWriter logWriter, - InternalLogWriter securityLogWriter, - HostAddress bindAddress, - String hostnameForClients, - Properties distributedSystemProperties, + InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress, + String hostnameForClients, Properties distributedSystemProperties, boolean startDistributedSystem) { return createLocator(port, loggingSession, logFile, logWriter, securityLogWriter, bindAddress, hostnameForClients, distributedSystemProperties, @@ -285,18 +282,13 @@ public static InternalLocator createLocator(int port, LoggingSession loggingSess * @param logFile the file that log messages should be written to * @param logWriter a log writer that should be used (logFile parameter is ignored) * @param securityLogWriter the logWriter to be used for security related log messages - * @param bindAddress the bind address for the locator * @param distributedSystemProperties optional properties to configure the distributed system * (e.g., mcast addr/port, other locators) * @param workingDirectory the working directory to use for any files */ public static InternalLocator createLocator(int port, LoggingSession loggingSession, File logFile, - InternalLogWriter logWriter, - InternalLogWriter securityLogWriter, - HostAddress bindAddress, - String hostnameForClients, - Properties distributedSystemProperties, - Path workingDirectory) { + InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress, + String hostnameForClients, Properties distributedSystemProperties, Path workingDirectory) { synchronized (locatorLock) { if (hasLocator()) { throw new IllegalStateException( @@ -340,7 +332,7 @@ private static void setLocator(InternalLocator locator) { * @param hostnameForClients the name to give to clients for connecting to this locator */ public static InternalLocator startLocator(int port, File logFile, InternalLogWriter logWriter, - InternalLogWriter securityLogWriter, HostAddress bindAddress, boolean startDistributedSystem, + InternalLogWriter securityLogWriter, InetAddress bindAddress, boolean startDistributedSystem, Properties distributedSystemProperties, String hostnameForClients) throws IOException { return startLocator(port, logFile, logWriter, securityLogWriter, bindAddress, @@ -359,7 +351,6 @@ public static InternalLocator startLocator(int port, File logFile, InternalLogWr * @param logFile the file that log messages should be written to * @param logWriter a log writer that should be used (logFile parameter is ignored) * @param securityLogWriter the logWriter to be used for security related log messages - * @param bindAddress the bind address for the locator * @param startDistributedSystem if true, a distributed system is started * @param distributedSystemProperties optional properties to configure the distributed system * (e.g., mcast @@ -368,11 +359,8 @@ public static InternalLocator startLocator(int port, File logFile, InternalLogWr * @param workingDirectory the working directory to use for any files */ public static InternalLocator startLocator(int port, File logFile, InternalLogWriter logWriter, - InternalLogWriter securityLogWriter, - HostAddress bindAddress, - boolean startDistributedSystem, - Properties distributedSystemProperties, - String hostnameForClients, Path workingDirectory) + InternalLogWriter securityLogWriter, InetAddress bindAddress, boolean startDistributedSystem, + Properties distributedSystemProperties, String hostnameForClients, Path workingDirectory) throws IOException { System.setProperty(FORCE_LOCATOR_DM_TYPE, "true"); InternalLocator newLocator = null; @@ -477,17 +465,11 @@ public static boolean isDedicatedLocator() { */ @VisibleForTesting InternalLocator(int port, LoggingSession loggingSession, File logFile, - InternalLogWriter logWriter, InternalLogWriter securityLogWriter, - HostAddress hostAddress, String hostnameForClients, - Properties distributedSystemProperties, + InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress, + String hostnameForClients, Properties distributedSystemProperties, DistributionConfigImpl distributionConfig, Path workingDirectory) { this.logFile = logFile; - this.hostAddress = hostAddress; - // bindAddress is superceded by hostAddress but must be kept for Locator API backward - // compatibility - if (hostAddress != null) { - this.bindAddress = hostAddress.getAddress(); - } + this.bindAddress = bindAddress; this.hostnameForClients = hostnameForClients; this.workingDirectory = workingDirectory; @@ -497,8 +479,8 @@ public static boolean isDedicatedLocator() { // set bind-address explicitly only if not wildcard and let any explicit // value in distributedSystemProperties take precedence - if (hostAddress != null) { - env.setProperty(BIND_ADDRESS, hostAddress.getHostName()); + if (bindAddress != null && !bindAddress.isAnyLocalAddress()) { + env.setProperty(BIND_ADDRESS, bindAddress.getHostAddress()); } if (distributedSystemProperties != null) { @@ -573,7 +555,7 @@ MAX_POOL_SIZE, new DelayedPoolStatHelper(), executor) .setConfig(config) .setPort(port) - .setBindAddress(hostAddress) + .setBindAddress(bindAddress) .setProtocolChecker(new ProtocolCheckerImpl(this, new ClientProtocolServiceLoader())) .setFallbackHandler(handler) .setLocatorsAreCoordinators(shouldLocatorsBeCoordinators()) @@ -693,7 +675,7 @@ public MembershipLocator getMembershipLocator() { */ @Deprecated public static InternalLocator startLocator(int locatorPort, File logFile, - InternalLogWriter logWriter, InternalLogWriter securityLogWriter, HostAddress bindAddress, + InternalLogWriter logWriter, InternalLogWriter securityLogWriter, InetAddress bindAddress, Properties distributedSystemProperties, boolean peerLocator, boolean serverLocator, String hostnameForClients, boolean b1) throws IOException { return startLocator(locatorPort, logFile, logWriter, securityLogWriter, bindAddress, true, @@ -716,8 +698,8 @@ private void startDistributedSystem() throws IOException { } else { StringBuilder sb = new StringBuilder(100); - if (hostAddress != null && !StringUtils.isEmpty(hostAddress.getHostName())) { - sb.append(hostAddress.getHostName()); + if (bindAddress != null) { + sb.append(bindAddress.getHostAddress()); } else { sb.append(LocalHostUtil.getLocalHost().getCanonicalHostName()); } @@ -906,9 +888,8 @@ void startServerLocation(InternalDistributedSystem distributedSystem) throws IOE } } - ServerLocator serverLocator = - new ServerLocator(getPort(), getBindAddressString(), hostnameForClients, - logFile, productUseLog, getConfig().getName(), distributedSystem, locatorStats); + ServerLocator serverLocator = new ServerLocator(getPort(), bindAddress, hostnameForClients, + logFile, productUseLog, getConfig().getName(), distributedSystem, locatorStats); restartHandlers.add(serverLocator); membershipLocator.addHandler(LocatorListRequest.class, serverLocator); membershipLocator.addHandler(ClientConnectionRequest.class, serverLocator); @@ -1440,13 +1421,6 @@ public boolean hasHandlerForClass(Class messageClass) { return membershipLocator.isHandled(messageClass); } - public String getBindAddressString() { - if (hostAddress != null) { - return hostAddress.getHostName(); - } - return null; - } - class FetchSharedConfigStatus implements Callable { @Override diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocator.java index 5064d99dba9d..075489fefe5a 100755 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocator.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ServerLocator.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; +import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -107,15 +108,15 @@ public LocatorLoadSnapshot getLoadSnapshot() { return loadSnapshot; } - public ServerLocator(int port, String bindAddress, String hostNameForClients, File logFile, + public ServerLocator(int port, InetAddress bindAddress, String hostNameForClients, File logFile, ProductUseLog productUseLogWriter, String memberName, InternalDistributedSystem ds, LocatorStats stats) throws IOException { this.port = port; - if (bindAddress == null || bindAddress.isEmpty()) { + if (bindAddress == null) { this.hostName = LocalHostUtil.getCanonicalLocalHostName(); } else { - this.hostName = bindAddress; + this.hostName = bindAddress.getHostAddress(); } if (hostNameForClients != null && !hostNameForClients.equals("")) { diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/adapter/ServiceConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/adapter/ServiceConfig.java index de568821fe9f..8788f3412a37 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/adapter/ServiceConfig.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/adapter/ServiceConfig.java @@ -66,9 +66,10 @@ public ServiceConfig(RemoteTransportConfig transport, DistributionConfig theConf joinTimeout = Long.getLong("p2p.joinTimeout", defaultJoinTimeout).longValue(); + // if network partition detection is enabled, we must connect to the locators + // more frequently in order to make sure we're not isolated from them SocketCreator.resolve_dns = true; - if (theConfig.getEnableNetworkPartitionDetection() && - !theConfig.getSSLEndPointIdentificationEnabled()) { + if (theConfig.getEnableNetworkPartitionDetection()) { if (!SocketCreator.FORCE_DNS_USE) { SocketCreator.resolve_dns = false; } diff --git a/geode-core/src/main/java/org/apache/geode/internal/DistributionLocator.java b/geode-core/src/main/java/org/apache/geode/internal/DistributionLocator.java index 8815a6aa1627..731459cd329c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/DistributionLocator.java +++ b/geode-core/src/main/java/org/apache/geode/internal/DistributionLocator.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; import java.net.InetAddress; +import java.util.Properties; import org.apache.logging.log4j.Logger; @@ -25,7 +26,6 @@ import org.apache.geode.annotations.internal.MakeNotStatic; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.logging.internal.executors.LoggingThread; import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.util.internal.GeodeGlossary; @@ -109,7 +109,9 @@ public static void main(String args[]) { SystemFailure.loadEmergencyClasses(); final int port = parsePort(args[0]); - HostAddress hostAddress = null; + InetAddress address = null; + boolean peerLocator = true; + boolean serverLocator = true; String hostnameForClients = null; try { if (args.length > 1 && !args[1].equals("")) { @@ -119,37 +121,43 @@ public static void main(String args[]) { args[1])); ExitCode.FATAL.doSystemExit(); } - hostAddress = new HostAddress(args[1]); - // do a look-up to ensure that the name can be resolved to an address - InetAddress.getByName(args[1]); + address = InetAddress.getByName(args[1]); } else { // address = null; // was InetAddress.getLocalHost(); (redundant assignment) } + if (args.length > 2) { + peerLocator = "true".equalsIgnoreCase(args[2]); + } + if (args.length > 3) { + serverLocator = "true".equalsIgnoreCase(args[3]); + } if (args.length > 4) { hostnameForClients = args[4]; } - final InetAddress inetAddress = hostAddress == null ? null : hostAddress.getAddress(); if (!Boolean.getBoolean(InternalDistributedSystem.DISABLE_SHUTDOWN_HOOK_PROPERTY)) { + final InetAddress faddress = address; Runtime.getRuntime() .addShutdownHook(new LoggingThread("LocatorShutdownThread", false, () -> { try { - DistributionLocator.shutdown(port, inetAddress); + DistributionLocator.shutdown(port, faddress); } catch (IOException e) { e.printStackTrace(); } })); } - lockFile = ManagerInfo.setLocatorStarting(directory, port, inetAddress); + lockFile = ManagerInfo.setLocatorStarting(directory, port, address); lockFile.deleteOnExit(); - InetAddress address = hostAddress == null ? null : hostAddress.getAddress(); try { + InternalLocator locator = InternalLocator.startLocator(port, new File(DEFAULT_LOG_FILE), - null, null, hostAddress, true, null, hostnameForClients); + null, null, address, true, (Properties) null, hostnameForClients); + ManagerInfo.setLocatorStarted(directory, port, address); locator.waitToStop(); + } finally { shutdown(port, address); } @@ -160,7 +168,7 @@ public static void main(String args[]) { } catch (java.net.BindException ex) { logger.fatal("Could not bind locator to {}[{}]", - new Object[] {hostAddress, port}); + new Object[] {address, port}); ExitCode.FATAL.doSystemExit(); } catch (Exception ex) { diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/DistributionLocatorId.java b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/DistributionLocatorId.java index b5572a824336..c4ecb46b964d 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/DistributionLocatorId.java +++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/DistributionLocatorId.java @@ -26,7 +26,6 @@ import org.apache.geode.InternalGemFireException; import org.apache.geode.distributed.Locator; import org.apache.geode.distributed.internal.DistributionConfig; -import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.distributed.internal.tcpserver.HostAndPort; import org.apache.geode.internal.inet.LocalHostUtil; import org.apache.geode.internal.net.SSLConfig; @@ -174,11 +173,7 @@ public DistributionLocatorId(String marshalled) { public DistributionLocatorId(InetAddress address, Locator locator) { this(address, locator.getPort(), - (((InternalLocator) locator).getBindAddressString() != null - ? ((InternalLocator) locator).getBindAddressString() - : (locator.getBindAddress() != null ? locator.getBindAddress().getHostAddress() - : null)), - null, + locator.getBindAddress() == null ? null : locator.getBindAddress().getHostAddress(), null, locator.getHostnameForClients()); } diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java index 4ac863b3dd96..22f2e96a690f 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java +++ b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java @@ -62,6 +62,7 @@ import javax.net.ssl.X509ExtendedKeyManager; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.logging.log4j.Logger; import org.apache.geode.GemFireConfigException; @@ -833,6 +834,17 @@ private boolean setServerNames(SSLParameters modifiedParams, HostAndPort addr) { } String hostName = addr.getHostName(); + if (this.sslConfig.doEndpointIdentification() + && InetAddressValidator.getInstance().isValid(hostName)) { + // endpoint validation typically uses a hostname in the sniServer parameter that the handshake + // will compare against the subject alternative addresses in the server's certificate. Here + // we attempt to get a hostname instead of the proffered numeric address + try { + hostName = InetAddress.getByName(hostName).getCanonicalHostName(); + } catch (UnknownHostException e) { + // ignore - we'll see what happens with endpoint validation using a numeric address... + } + } serverNames.add(new SNIHostName(hostName)); modifiedParams.setServerNames(serverNames); return true; diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java index 9e0e96e03a99..24b1d7f07d4a 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java +++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java @@ -1725,14 +1725,8 @@ private void readMessages() { private void createIoFilter(SocketChannel channel, boolean clientSocket) throws IOException { if (getConduit().useSSL() && channel != null) { InetSocketAddress address = (InetSocketAddress) channel.getRemoteAddress(); - String hostName; - if (remoteAddr != null) { - hostName = remoteAddr.getHostName(); - } else { - hostName = SocketCreator.getHostName(address.getAddress()); - } SSLEngine engine = - getConduit().getSocketCreator().createSSLEngine(hostName, + getConduit().getSocketCreator().createSSLEngine(address.getHostString(), address.getPort(), clientSocket); int packetBufferSize = engine.getSession().getPacketBufferSize(); diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java index 7180a9d8bf35..5a98dcaa9557 100644 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java +++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java @@ -17,6 +17,7 @@ import java.io.File; import java.io.IOException; +import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -315,9 +316,9 @@ ResultModel doStartLocator( infoResult.addLine(locatorState.toString()); String locatorHostName; - String bindAddr = locatorLauncher.getBindAddressString(); + InetAddress bindAddr = locatorLauncher.getBindAddress(); if (bindAddr != null) { - locatorHostName = bindAddr; + locatorHostName = bindAddr.getCanonicalHostName(); } else { locatorHostName = StringUtils.defaultIfBlank(locatorLauncher.getHostnameForClients(), HostUtils.getLocalHost()); @@ -482,8 +483,8 @@ String[] createStartLocatorCommandLine(final LocatorLauncher launcher, commandLine.add(launcher.getMemberName()); } - if (launcher.getBindAddressString() != null) { - commandLine.add("--bind-address=" + launcher.getBindAddressString()); + if (launcher.getBindAddress() != null) { + commandLine.add("--bind-address=" + launcher.getBindAddress().getHostAddress()); } if (launcher.isDebugging() || isDebugging()) { diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java index ee7759bf6317..2433387fa43e 100644 --- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java +++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/JmxOperationInvoker.java @@ -130,9 +130,8 @@ public JmxOperationInvoker(final String host, final int port, Properties gfPrope env.put("com.sun.jndi.rmi.factory.socket", new ContextAwareSSLRMIClientSocketFactory()); } - final String hostName = checkAndConvertToCompatibleIPv6Syntax(host); this.url = new JMXServiceURL(MessageFormat.format(JMX_URL_FORMAT, - hostName, String.valueOf(port))); + checkAndConvertToCompatibleIPv6Syntax(host), String.valueOf(port))); this.connector = JMXConnectorFactory.connect(url, env); this.mbsc = connector.getMBeanServerConnection(); this.connector.addConnectionNotificationListener(new JMXConnectionListener(this), null, null); diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java index bfe48191cc78..16b09e6a2325 100644 --- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java +++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java @@ -49,7 +49,6 @@ import org.apache.geode.distributed.internal.membership.gms.MembershipLocatorStatisticsNoOp; import org.apache.geode.distributed.internal.membership.gms.Services; import org.apache.geode.distributed.internal.membership.gms.util.MemberIdentifierUtil; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.TcpClient; import org.apache.geode.distributed.internal.tcpserver.TcpServer; import org.apache.geode.distributed.internal.tcpserver.TcpSocketCreatorImpl; @@ -155,7 +154,7 @@ public void testRecoverFromOther() throws Exception { final TcpSocketCreatorImpl socketCreator = new TcpSocketCreatorImpl(); locator = MembershipLocatorBuilder.newLocatorBuilder(socketCreator, serializer, temporaryFolder.getRoot().toPath(), executorServiceSupplier) - .setBindAddress(new HostAddress(localHost)).create(); + .setBindAddress(localHost).create(); final int port = locator.start(); try { @@ -183,7 +182,7 @@ public String getLocators() { // now create a peer location handler that should recover from our real locator and know // that real locator's identifier - GMSLocator gmsLocator = new GMSLocator(new HostAddress(localHost), + GMSLocator gmsLocator = new GMSLocator(localHost, membership.getLocalMember().getHost() + "[" + port + "]", true, true, new MembershipLocatorStatisticsNoOp(), "", temporaryFolder.getRoot().toPath(), locatorClient, diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java index 47ec0ffaede1..3a86a1e5a320 100644 --- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java +++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java @@ -22,14 +22,12 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -117,18 +115,11 @@ public void initMocks(boolean enableNetworkPartition) throws Exception { public void initMocks(boolean enableNetworkPartition, boolean useTestGMSJoinLeave) throws Exception { - String locator = "localhost[12345]"; - initMocks(enableNetworkPartition, useTestGMSJoinLeave, locator, locator); - } - - public void initMocks(boolean enableNetworkPartition, boolean useTestGMSJoinLeave, - String locators, String startLocator) - throws Exception { mockConfig = mock(MembershipConfig.class); when(mockConfig.isNetworkPartitionDetectionEnabled()).thenReturn(enableNetworkPartition); when(mockConfig.getSecurityUDPDHAlgo()).thenReturn(""); - when(mockConfig.getStartLocator()).thenReturn(startLocator); - when(mockConfig.getLocators()).thenReturn(locators); + when(mockConfig.getStartLocator()).thenReturn("localhost[12345]"); + when(mockConfig.getLocators()).thenReturn("localhost[12345]"); when(mockConfig.getMcastPort()).thenReturn(0); when(mockConfig.getMemberTimeout()).thenReturn(2000L); @@ -1432,7 +1423,14 @@ private GMSMembershipView createView() { @Test public void testCoordinatorFindRequestSuccess() throws Exception { initMocks(false); - mockRequestToServer(isA(HostAndPort.class)); + HashSet registrants = new HashSet<>(); + registrants.add(mockMembers[0]); + FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, + null, registrants, false, true, null); + + when(locatorClient.requestToServer(isA(HostAndPort.class), + isA(FindCoordinatorRequest.class), anyInt(), anyBoolean())) + .thenReturn(fcr); boolean foundCoordinator = gmsJoinLeave.findCoordinator(); assertTrue(gmsJoinLeave.searchState.toString(), foundCoordinator); @@ -1443,80 +1441,22 @@ public void testCoordinatorFindRequestSuccess() throws Exception { public void testCoordinatorFindRequestFailure() throws Exception { try { initMocks(false); - mockRequestToServer(eq(new HostAndPort("localhost", 12346))); + HashSet registrants = new HashSet<>(); + registrants.add(mockMembers[0]); + FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], + false, null, registrants, false, true, null); GMSMembershipView view = createView(); JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 0); gmsJoinLeave.setJoinResponseMessage(jrm); - assertThatThrownBy(gmsJoinLeave::join) - .isInstanceOf(MembershipConfigurationException.class); - } finally { - } - } - - @Test - public void testJoinFailureWhenSleepInterrupted() throws Exception { - initMocks(false); - mockRequestToServer(isA(HostAndPort.class)); - - when(mockConfig.getMemberTimeout()).thenReturn(100L); - when(mockConfig.getJoinTimeout()).thenReturn(1000L); - - GMSJoinLeave spyGmsJoinLeave = spy(gmsJoinLeave); - when(spyGmsJoinLeave.pauseIfThereIsNoCoordinator(-1, GMSJoinLeave.JOIN_RETRY_SLEEP)) - .thenThrow(new InterruptedException()); - - assertThatThrownBy(spyGmsJoinLeave::join) - .isInstanceOf(MembershipConfigurationException.class) - .hasMessageContaining("Retry sleep interrupted"); - } - - @Test - public void testJoinFailureWhenTimeout() throws Exception { - initMocks(false); - mockRequestToServer(isA(HostAndPort.class)); - - assertThatThrownBy(() -> gmsJoinLeave.join()) - .isInstanceOf(MembershipConfigurationException.class) - .hasMessageContaining("Operation timed out"); - } - - @Test - public void testPauseIfThereIsNoCoordinator() throws InterruptedException { - locatorClient = mock(TcpClient.class); - gmsJoinLeave = new GMSJoinLeave(locatorClient); - assertThat(gmsJoinLeave.pauseIfThereIsNoCoordinator(-1, GMSJoinLeave.JOIN_RETRY_SLEEP)) - .isFalse(); - assertThat(gmsJoinLeave.pauseIfThereIsNoCoordinator(1, GMSJoinLeave.JOIN_RETRY_SLEEP)).isTrue(); - } - - @Test - public void testJoinFailureWhenNoLocator() throws Exception { - final String locator1 = "locator1[12345]"; - final String locator2 = "locator2[54321]"; - locatorClient = mock(TcpClient.class); + when(locatorClient.requestToServer(eq(new HostAndPort("localhost", 12346)), + isA(FindCoordinatorRequest.class), anyInt(), anyBoolean())) + .thenReturn(fcr); - initMocks(false, false, locator1 + ',' + locator2, locator1); - when(locatorClient.requestToServer(any(), any(), anyInt(), anyBoolean())) - .thenThrow(IOException.class); - - assertThatThrownBy(gmsJoinLeave::join) - .isInstanceOf(MembershipConfigurationException.class) - .hasMessageContaining( - "Could not contact any of the locators: [locator1:12345, locator2:54321]") - .hasCauseInstanceOf(IOException.class); - } - - private void mockRequestToServer(HostAndPort hostAndPort) - throws IOException, ClassNotFoundException { - HashSet registrants = new HashSet<>(); - registrants.add(mockMembers[0]); + assertFalse("Should not be able to join ", gmsJoinLeave.join()); + } finally { - FindCoordinatorResponse fcr = new FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, - null, registrants, false, true, null); - when(locatorClient.requestToServer(hostAndPort, - isA(FindCoordinatorRequest.class), anyInt(), anyBoolean())) - .thenReturn(fcr); + } } private void waitForViewAndFinalCheckInProgress(int viewId) throws InterruptedException { diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipLocatorBuilder.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipLocatorBuilder.java index 131e1ebd418a..3c7704c70592 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipLocatorBuilder.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/api/MembershipLocatorBuilder.java @@ -14,13 +14,13 @@ */ package org.apache.geode.distributed.internal.membership.api; +import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.file.Path; import java.util.concurrent.ExecutorService; import java.util.function.Supplier; import org.apache.geode.distributed.internal.membership.gms.MembershipLocatorBuilderImpl; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.ProtocolChecker; import org.apache.geode.distributed.internal.tcpserver.TcpHandler; import org.apache.geode.distributed.internal.tcpserver.TcpSocketCreator; @@ -29,7 +29,7 @@ public interface MembershipLocatorBuilder { MembershipLocatorBuilder setPort(int port); - MembershipLocatorBuilder setBindAddress(HostAddress bindAddress); + MembershipLocatorBuilder setBindAddress(InetAddress bindAddress); MembershipLocatorBuilder setConfig(MembershipConfig membershipConfig); diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberData.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberData.java index 250a64086b94..55aba28b9327 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberData.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberData.java @@ -595,6 +595,8 @@ public void readEssentialData(DataInput in, this.inetAddr = StaticSerialization.readInetAddress(in); if (this.inetAddr != null) { + // use address as hostname at this level. getHostName() will do a reverse-dns lookup, + // which is very expensive this.hostName = inetAddr.getHostAddress(); } this.udpPort = in.readInt(); diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java index 2d88312dbd32..e1d1b5573de6 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMembership.java @@ -571,7 +571,12 @@ private void join() throws MemberStartupException { this.isJoining = true; // added for bug #44373 // connect - services.getJoinLeave().join(); + boolean ok = services.getJoinLeave().join(); + + if (!ok) { + throw new MembershipConfigurationException("Unable to join the distributed system. " + + "Operation either timed out, was stopped or Locator does not exist."); + } MembershipView initialView = createGeodeView(services.getJoinLeave().getView()); latestView = new MembershipView<>(initialView, initialView.getViewId()); diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipLocatorBuilderImpl.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipLocatorBuilderImpl.java index 98be6b46f556..4ee88472fdbf 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipLocatorBuilderImpl.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/MembershipLocatorBuilderImpl.java @@ -14,6 +14,7 @@ */ package org.apache.geode.distributed.internal.membership.gms; +import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.file.Path; import java.util.concurrent.ExecutorService; @@ -26,7 +27,6 @@ import org.apache.geode.distributed.internal.membership.api.MembershipLocatorBuilder; import org.apache.geode.distributed.internal.membership.api.MembershipLocatorStatistics; import org.apache.geode.distributed.internal.membership.gms.locator.MembershipLocatorImpl; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.ProtocolChecker; import org.apache.geode.distributed.internal.tcpserver.TcpHandler; import org.apache.geode.distributed.internal.tcpserver.TcpSocketCreator; @@ -37,7 +37,7 @@ public final class MembershipLocatorBuilderImpl imp MembershipLocatorBuilder { private final DSFIDSerializer serializer; private int port = 0; - private HostAddress bindAddress = null; + private InetAddress bindAddress = null; private ProtocolChecker protocolChecker = (socket, input, firstByte) -> false; private TcpHandler fallbackHandler = new TcpHandlerNoOp(); private MembershipLocatorStatistics locatorStats = new MembershipLocatorStatisticsNoOp(); @@ -65,7 +65,7 @@ public MembershipLocatorBuilder setPort(int port) { } @Override - public MembershipLocatorBuilder setBindAddress(HostAddress bindAddress) { + public MembershipLocatorBuilder setBindAddress(InetAddress bindAddress) { this.bindAddress = bindAddress; return this; } diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/JoinLeave.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/JoinLeave.java index 1880a2679e7d..722816277e94 100755 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/JoinLeave.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/JoinLeave.java @@ -16,7 +16,6 @@ import org.apache.geode.distributed.internal.membership.api.MemberIdentifier; import org.apache.geode.distributed.internal.membership.api.MemberStartupException; -import org.apache.geode.distributed.internal.membership.api.MembershipConfigurationException; import org.apache.geode.distributed.internal.membership.gms.GMSMembershipView; /** @@ -27,15 +26,10 @@ public interface JoinLeave extends Service { /** - * joins the distributed system. - * - * @throws MemberStartupException if there was a problem joining the cluster after membership - * configuration has - * completed. - * @throws MembershipConfigurationException if operation either timed out, was stopped or locator - * does not exist. + * joins the distributed system and returns true if successful, false if not. Throws + * MemberStartupException and MemberConfigurationException */ - void join() throws MemberStartupException; + boolean join() throws MemberStartupException; /** * leaves the distributed system. Should be invoked before stop() diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java index c87fcf8b554a..3cc10eb7a783 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.net.InetAddress; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; @@ -44,7 +45,6 @@ import org.apache.geode.distributed.internal.membership.gms.Services; import org.apache.geode.distributed.internal.membership.gms.interfaces.Locator; import org.apache.geode.distributed.internal.membership.gms.messenger.GMSMemberWrapper; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.HostAndPort; import org.apache.geode.distributed.internal.tcpserver.TcpClient; import org.apache.geode.distributed.internal.tcpserver.TcpHandler; @@ -107,7 +107,7 @@ public class GMSLocator implements Locator, Tcp * @param objectSerializer a serializer used to persist the membership view * @param objectDeserializer a deserializer used to recover the membership view */ - public GMSLocator(HostAddress bindAddress, String locatorString, boolean usePreferredCoordinators, + public GMSLocator(InetAddress bindAddress, String locatorString, boolean usePreferredCoordinators, boolean networkPartitionDetectionEnabled, MembershipLocatorStatistics locatorStats, String securityUDPDHAlgo, Path workingDirectory, final TcpClient locatorClient, ObjectSerializer objectSerializer, @@ -120,8 +120,7 @@ public GMSLocator(HostAddress bindAddress, String locatorString, boolean usePref if (this.locatorString == null || this.locatorString.isEmpty()) { locators = new ArrayList<>(0); } else { - locators = GMSUtil.parseLocators(locatorString, - bindAddress == null ? null : bindAddress.getAddress()); + locators = GMSUtil.parseLocators(locatorString, bindAddress); } this.locatorStats = locatorStats; this.workingDirectory = workingDirectory; diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java index 3f86f2aa9594..c4d2333d15fb 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java @@ -38,7 +38,6 @@ import org.apache.geode.distributed.internal.membership.api.MembershipLocatorStatistics; import org.apache.geode.distributed.internal.membership.gms.GMSMembership; import org.apache.geode.distributed.internal.membership.gms.Services; -import org.apache.geode.distributed.internal.tcpserver.HostAddress; import org.apache.geode.distributed.internal.tcpserver.HostAndPort; import org.apache.geode.distributed.internal.tcpserver.ProtocolChecker; import org.apache.geode.distributed.internal.tcpserver.TcpClient; @@ -62,7 +61,7 @@ public class MembershipLocatorImpl implements Membe private final GMSLocator gmsLocator; private final TcpClient locatorClient; - public MembershipLocatorImpl(int port, HostAddress bindAddress, + public MembershipLocatorImpl(int port, InetAddress bindAddress, ProtocolChecker protocolChecker, Supplier executorServiceSupplier, TcpSocketCreator socketCreator, @@ -76,10 +75,9 @@ public MembershipLocatorImpl(int port, HostAddress bindAddress, handler = new PrimaryHandler(fallbackHandler, config.getLocatorWaitTime()); String host = bindAddress == null ? LocalHostUtil.getLocalHostName() : bindAddress.getHostName(); - InetAddress inetAddress = bindAddress == null ? null : bindAddress.getAddress(); String threadName = "Distribution Locator on " + host + ": " + port; - this.server = new TcpServer(port, inetAddress, handler, + this.server = new TcpServer(port, bindAddress, handler, threadName, protocolChecker, locatorStats::getStatTime, executorServiceSupplier, @@ -93,7 +91,7 @@ public MembershipLocatorImpl(int port, HostAddress bindAddress, objectSerializer, objectDeserializer, Socket::new); gmsLocator = - new GMSLocator(bindAddress, config.getLocators(), locatorsAreCoordinators, + new GMSLocator<>(bindAddress, config.getLocators(), locatorsAreCoordinators, config.isNetworkPartitionDetectionEnabled(), locatorStats, config.getSecurityUDPDHAlgo(), workingDirectory, locatorClient, objectSerializer, diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java index 7328ae358428..ff5c619b49a1 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java @@ -273,13 +273,11 @@ static class SearchState { int lastFindCoordinatorInViewId = -1000; final Set> responses = new HashSet<>(); public int responsesExpected; - Exception lastLocatorException; void cleanup() { alreadyTried.clear(); possibleCoordinator = null; view = null; - lastLocatorException = null; synchronized (responses) { responses.clear(); } @@ -317,14 +315,14 @@ public static int getMinimumRetriesBeforeBecomingCoordinator(int locatorsSize) { * @return true if successful, false if not */ @Override - public void join() throws MemberStartupException { + public boolean join() throws MemberStartupException { try { if (Boolean.getBoolean(BYPASS_DISCOVERY_PROPERTY)) { synchronized (viewInstallationLock) { becomeCoordinator(); } - return; + return true; } SearchState state = searchState; @@ -357,11 +355,11 @@ public void join() throws MemberStartupException { synchronized (viewInstallationLock) { becomeCoordinator(); } - return; + return true; } } else { if (attemptToJoin()) { - return; + return true; } if (this.isStopping) { break; @@ -385,45 +383,40 @@ public void join() throws MemberStartupException { break; } } - if (found && !state.hasContactedAJoinedLocator) { - try { - if (pauseIfThereIsNoCoordinator(state.possibleCoordinator.getVmViewId(), retrySleep)) { + try { + if (found && !state.hasContactedAJoinedLocator) { + // if locators are restarting they may be handing out IDs from a stale view that + // we should go through quickly. Otherwise we should sleep a bit to let failure + // detection select a new coordinator + if (state.possibleCoordinator.getVmViewId() < 0) { + logger.debug("sleeping for {} before making another attempt to find the coordinator", + retrySleep); + Thread.sleep(retrySleep); + } else { // since we were given a coordinator that couldn't be used we should keep trying tries = 0; giveupTime = System.currentTimeMillis() + timeout; } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new MembershipConfigurationException( - "Retry sleep interrupted. Giving up on joining the distributed system."); } + } catch (InterruptedException e) { + logger.debug("retry sleep interrupted - giving up on joining the distributed system"); + return false; } } // for if (!this.isJoined) { logger.debug("giving up attempting to join the distributed system after " + (System.currentTimeMillis() - startTime) + "ms"); + } - // to preserve old behavior we need to throw a MemberStartupException if - // unable to contact any of the locators - if (state.hasContactedAJoinedLocator) { - throw new MemberStartupException("Unable to join the distributed system in " - + (System.currentTimeMillis() - startTime) + "ms"); - } - - if (state.locatorsContacted == 0) { - throw new MembershipConfigurationException( - "Unable to join the distributed system. Could not contact any of the locators: " - + locators, - state.lastLocatorException); - } - - if (System.currentTimeMillis() > giveupTime) { - throw new MembershipConfigurationException( - "Unable to join the distributed system. Operation timed out"); - } + // to preserve old behavior we need to throw a MemberStartupException if + // unable to contact any of the locators + if (!this.isJoined && state.hasContactedAJoinedLocator) { + throw new MemberStartupException("Unable to join the distributed system in " + + (System.currentTimeMillis() - startTime) + "ms"); } - return; + + return this.isJoined; } finally { // notify anyone waiting on the address to be completed if (this.isJoined) { @@ -435,24 +428,6 @@ public void join() throws MemberStartupException { } } - boolean pauseIfThereIsNoCoordinator(int viewId, long retrySleep) - throws InterruptedException { - // if locators are restarting they may be handing out IDs from a stale view that - // we should go through quickly. Otherwise we should sleep a bit to let failure - // detection select a new coordinator - if (viewId < 0) { - // the process hasn't finished joining the cluster. - logger.debug("sleeping for {} before making another attempt to find the coordinator", - retrySleep); - Thread.sleep(retrySleep); - } else { - // the member has joined the cluster. - return true; - } - - return false; - } - /** * send a join request and wait for a reply. Process the reply. This may throw a * MemberStartupException or an exception from the authenticator, if present. @@ -1224,7 +1199,6 @@ boolean findCoordinator() throws MemberStartupException { } catch (IOException | ClassNotFoundException problem) { logger.info("Unable to contact locator " + laddr + ": " + problem); logger.debug("Exception thrown when contacting a locator", problem); - state.lastLocatorException = problem; if (state.locatorsContacted == 0 && System.currentTimeMillis() < giveUpTime) { try { Thread.sleep(FIND_LOCATOR_RETRY_SLEEP); diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java index 8da3f2fecdc9..a695a2dce27c 100644 --- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java +++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java @@ -556,10 +556,9 @@ private void establishLocalAddress() throws MemberStartupException { || !config.getStartLocator().isEmpty(); // establish the DistributedSystem's address - String hostname = config.getBindAddress(); - if (hostname == null || hostname.isEmpty()) { - hostname = jgAddress.getInetAddress().getHostName(); - } + String hostname = + !config.isNetworkPartitionDetectionEnabled() ? jgAddress.getInetAddress().getHostName() + : jgAddress.getInetAddress().getHostAddress(); GMSMemberData gmsMember = new GMSMemberData(jgAddress.getInetAddress(), hostname, jgAddress.getPort(), OSProcess.getId(), (byte) services.getConfig().getVmKind(), diff --git a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAddress.java b/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAddress.java deleted file mode 100644 index 9f32dfd1e1ac..000000000000 --- a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAddress.java +++ /dev/null @@ -1,56 +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.geode.distributed.internal.tcpserver; - -import java.net.InetAddress; -import java.net.InetSocketAddress; - - -/** - * HostAddress is a holder of a host name/address. It is the primary - * way to specify a host address that may or may not be resolvable to an InetAddress. - *

- * This class preserves the hostName string passed in to its constructor that takes a - * hostName string and will respond with that string when asked for a hostName. - * - * @See HostAndPort which can hold both a host name and a port - */ -public class HostAddress extends InetSocketWrapper { - - public HostAddress(String hostName) { - super(hostName, 0); - } - - public HostAddress(InetAddress address) { - if (address == null) { - throw new IllegalArgumentException("null parameters are not allowed"); - } - inetSocketAddress = new InetSocketAddress(address, 0); - } - - public HostAddress(HostAndPort hostAndPort) { - hostName = hostAndPort.hostName; - inetSocketAddress = hostAndPort.inetSocketAddress; - } - - @Override - public String toString() { - if (hostName != null) { - return hostName; - } else { - return inetSocketAddress.getAddress().toString(); - } - } -} diff --git a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAndPort.java b/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAndPort.java index 73ae77580e78..f7d6805c0528 100644 --- a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAndPort.java +++ b/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/HostAndPort.java @@ -19,6 +19,9 @@ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.Objects; + +import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.geode.internal.serialization.DataSerializableFixedID; import org.apache.geode.internal.serialization.DeserializationContext; @@ -30,9 +33,6 @@ * HostAndPort is a holder of a host name/address and a port. It is the primary * way to specify a connection endpoint in the socket-creator methods. *

- * This class preserves the hostName string passed in to its constructor that takes a - * hostName string and will respond with that string when asked for a hostName. - *

* Note: This class is serializable for testing. A number of client/server and WAN tests * transmit PoolAttributes between unit test JVMs using RMI. PoolAttributes are * Externalizable for this purpose and use Geode serialization to transmit HostAndPort @@ -43,20 +43,73 @@ * @see ClientSocketCreator * @see AdvancedSocketCreator * @see TcpClient - * @see HostAddress */ -public class HostAndPort extends InetSocketWrapper implements DataSerializableFixedID { +public class HostAndPort implements DataSerializableFixedID { + + private InetSocketAddress socketInetAddress; public HostAndPort() { // serialization constructor } public HostAndPort(String hostName, int port) { - super(hostName, port); + if (hostName == null) { + socketInetAddress = new InetSocketAddress(port); + } else if (InetAddressValidator.getInstance().isValid(hostName)) { + // numeric address - use as-is + socketInetAddress = new InetSocketAddress(hostName, port); + } else { + // non-numeric address - resolve hostname when needed + socketInetAddress = InetSocketAddress.createUnresolved(hostName, port); + } + } + + /** + * Returns an InetSocketAddress for this host and port. An attempt is made to resolve the + * host name but if resolution fails an unresolved InetSocketAddress is returned. This return + * value will not hold an InetAddress, so calling getAddress() on it will return null. + */ + public InetSocketAddress getSocketInetAddress() { + if (socketInetAddress.isUnresolved()) { + // note that this leaves the InetAddress null if the hostname isn't resolvable + return new InetSocketAddress(socketInetAddress.getHostString(), socketInetAddress.getPort()); + } else { + return this.socketInetAddress; + } + } + + public String getHostName() { + return socketInetAddress.getHostString(); } public int getPort() { - return inetSocketAddress.getPort(); + return socketInetAddress.getPort(); + } + + @Override + public int hashCode() { + return socketInetAddress.hashCode(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HostAndPort that = (HostAndPort) o; + return Objects.equals(socketInetAddress, that.socketInetAddress); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + socketInetAddress + "]"; + } + + public InetAddress getAddress() { + return getSocketInetAddress().getAddress(); } @Override @@ -66,13 +119,13 @@ public int getDSFID() { @Override public void toData(DataOutput out, SerializationContext context) throws IOException { - if (inetSocketAddress.isUnresolved()) { + if (socketInetAddress.isUnresolved()) { out.writeByte(0); StaticSerialization.writeString(getHostName(), out); out.writeInt(getPort()); } else { out.writeByte(1); - StaticSerialization.writeInetAddress(inetSocketAddress.getAddress(), out); + StaticSerialization.writeInetAddress(socketInetAddress.getAddress(), out); out.writeInt(getPort()); } } @@ -80,20 +133,20 @@ public void toData(DataOutput out, SerializationContext context) throws IOExcept @Override public void fromData(DataInput in, DeserializationContext context) throws IOException, ClassNotFoundException { - InetAddress address; + InetAddress address = null; byte flags = in.readByte(); if ((flags & 1) == 0) { String hostName = StaticSerialization.readString(in); int port = in.readInt(); if (hostName == null || hostName.isEmpty()) { - inetSocketAddress = new InetSocketAddress(port); + socketInetAddress = new InetSocketAddress(port); } else { - inetSocketAddress = InetSocketAddress.createUnresolved(hostName, port); + socketInetAddress = InetSocketAddress.createUnresolved(hostName, port); } } else { address = StaticSerialization.readInetAddress(in); int port = in.readInt(); - inetSocketAddress = new InetSocketAddress(address, port); + socketInetAddress = new InetSocketAddress(address, port); } } @@ -101,4 +154,6 @@ public void fromData(DataInput in, DeserializationContext context) public Version[] getSerializationVersions() { return null; } + + } diff --git a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/InetSocketWrapper.java b/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/InetSocketWrapper.java deleted file mode 100644 index 168fc3f4cabf..000000000000 --- a/geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/InetSocketWrapper.java +++ /dev/null @@ -1,100 +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.geode.distributed.internal.tcpserver; - -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.util.Objects; - -import org.apache.commons.validator.routines.InetAddressValidator; - -class InetSocketWrapper { - String hostName; - protected InetSocketAddress inetSocketAddress; - private InetSocketAddress attemptedToResolve; - - protected InetSocketWrapper() {} - - protected InetSocketWrapper(String hostName, int port) { - // preserve the hostName string since InetSocketAddress will throw it away if it's a numeric - // address. Invoking getHostName on the InetSocketAddress would possibly return a different - // string. - this.hostName = hostName; - if (hostName == null) { - inetSocketAddress = new InetSocketAddress(port); - } else if (InetAddressValidator.getInstance().isValid(hostName)) { - // numeric address - use as-is - inetSocketAddress = new InetSocketAddress(hostName, port); - } else { - // non-numeric address - resolve hostname when needed - inetSocketAddress = InetSocketAddress.createUnresolved(hostName, port); - } - } - - public String getHostName() { - if (hostName != null) { - return hostName; - } - return inetSocketAddress.getHostName(); - } - - public InetAddress getAddress() { - return getSocketInetAddress().getAddress(); - } - - @Override - public int hashCode() { - return inetSocketAddress.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InetSocketWrapper that = (InetSocketWrapper) o; - return Objects.equals(inetSocketAddress, that.inetSocketAddress); - } - - /** - * Returns an InetSocketAddress for this host and port. An attempt is made to resolve the - * host name but if resolution fails an unresolved InetSocketAddress is returned. This return - * value will not hold an InetAddress, so calling getAddress() on it will return null. - */ - public InetSocketAddress getSocketInetAddress() { - if (attemptedToResolve == null) { - attemptedToResolve = basicGetInetSocketAddress(); - } - return attemptedToResolve; - } - - private InetSocketAddress basicGetInetSocketAddress() { - if (inetSocketAddress.isUnresolved()) { - // note that this leaves the InetAddress null if the hostname isn't resolvable - return new InetSocketAddress(inetSocketAddress.getHostString(), inetSocketAddress.getPort()); - } else { - return inetSocketAddress; - } - } - - @Override - public String toString() { - return inetSocketAddress.toString(); - } - -} diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java index 655926b45e4f..ab6933a13f43 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java @@ -52,6 +52,7 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.Arrays; @@ -380,7 +381,7 @@ public static Integer createSecondRemoteLocatorWithAPI(int dsId, int localPort, props.setProperty(DISTRIBUTED_SYSTEM_ID, "" + dsId); props.setProperty(LOCATORS, "localhost[" + localPort + "]"); props.setProperty(REMOTE_LOCATORS, "localhost[" + remoteLocPort + "]"); - Locator locator = Locator.startLocatorAndDS(0, null, null, props, + Locator locator = Locator.startLocatorAndDS(0, null, InetAddress.getByName("0.0.0.0"), props, true, true, hostnameForClients); return locator.getPort(); }