diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ManagementRequestLoggingDistributedTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ManagementRequestLoggingDistributedTest.java index 6a578aeb894c..677b77eaa0a6 100644 --- a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ManagementRequestLoggingDistributedTest.java +++ b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/ManagementRequestLoggingDistributedTest.java @@ -21,8 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.VM.getVM; import static org.assertj.core.api.Assertions.assertThat; @@ -79,7 +78,7 @@ public void setUp() throws Exception { serverName = "server1"; locatorDir = temporaryFolder.newFolder(locatorName); serverDir = temporaryFolder.newFolder(serverName); - httpPort = getRandomAvailablePort(SOCKET); + httpPort = getRandomAvailableTCPPort(); locatorPort = locatorVM.invoke(this::startLocator); serverVM.invoke(this::startServer); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java index 41b48080105a..75f03b8a6d00 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -29,7 +30,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheWriterAdapter; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.NetworkUtils; import org.apache.geode.test.dunit.SerializableCallable; @@ -65,7 +65,7 @@ public void testPoolAndLoader() throws Exception { VM server = host.getVM(0); VM client = host.getVM(1); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); server.invoke(new SerializableCallable() { @Override public Object call() throws IOException { @@ -147,7 +147,7 @@ public void testPoolAndWriter() throws Exception { VM server = host.getVM(0); VM client = host.getVM(1); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); server.invoke(new SerializableCallable() { @Override public Object call() throws IOException { @@ -249,7 +249,7 @@ public void testPoolLoadAndPeer() throws Exception { VM client1 = host.getVM(1); VM client2 = host.getVM(2); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); server.invoke(new SerializableCallable() { @Override public Object call() throws IOException { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java index fe56f4e9d208..eebbde3f1da4 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceDUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.cache.client.internal; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName; @@ -42,7 +43,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.internal.ServerLocationAndMemberId; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.management.membership.ClientMembership; import org.apache.geode.management.membership.ClientMembershipEvent; import org.apache.geode.management.membership.ClientMembershipListenerAdapter; @@ -106,8 +106,7 @@ public void testNoLocators() { try { vm0.invoke("StartBridgeClient", - () -> startBridgeClient(null, getServerHostName(), - AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET))); + () -> startBridgeClient(null, getServerHostName(), getRandomAvailableTCPPort())); checkLocators(vm0, new InetSocketAddress[] {}, new InetSocketAddress[] {}); putInVM(vm0); fail("Client cache should not have been able to start"); @@ -250,7 +249,7 @@ public void testClientCanUseAnEmbeddedLocator() { VM vm0 = VM.getVM(0); VM vm1 = VM.getVM(1); - int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int locatorPort = getRandomAvailableTCPPort(); String locators = getLocatorString(getServerHostName(), locatorPort); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java index b8d918a273cb..e8f85b28661c 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheXml66DUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.ROLES; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; import static org.junit.Assert.assertEquals; @@ -109,7 +110,6 @@ import org.apache.geode.cache.server.ServerMetrics; import org.apache.geode.cache.util.ObjectSizer; import org.apache.geode.cache.util.TransactionListenerAdapter; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.InternalInstantiator; @@ -2433,7 +2433,7 @@ public void testDynamicRegionFactoryConnectionPool() throws Exception, IOExcepti addIgnoredException("Socket Closed"); getSystem(); VM vm0 = Host.getHost(0).getVM(0); - final int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int port = getRandomAvailableTCPPort(); vm0.invoke(new SerializableCallable("Create cache server") { @Override public Object call() throws IOException { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java index 315a7004bbe6..a6fa38a4c46b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java @@ -38,6 +38,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; import static org.apache.geode.distributed.Locator.getLocator; import static org.apache.geode.distributed.internal.membership.api.MembershipManagerHelper.getDistribution; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; import static org.apache.geode.test.dunit.Host.getHost; @@ -94,7 +95,6 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMember; import org.apache.geode.distributed.internal.membership.api.MembershipManagerHelper; import org.apache.geode.examples.SimpleSecurityManager; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.InternalCache; @@ -136,7 +136,7 @@ public ReconnectDUnitTest() { public final void postSetUp() throws Exception { IgnoredException.addIgnoredException("ForcedDisconnectException"); IgnoredException.addIgnoredException("Possible loss of quorum"); - locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + locatorPort = getRandomAvailableTCPPort(); final int locPort = locatorPort; Host.getHost(0).getVM(locatorVMNumber).invoke(new SerializableRunnable("start locator") { @Override diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java index bde5458fd657..3c02b7f9c472 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedSystemDUnitTest.java @@ -30,10 +30,9 @@ import static org.apache.geode.distributed.ConfigurationProperties.TCP_PORT; import static org.apache.geode.distributed.internal.DistributionConfig.DEFAULT_ACK_WAIT_THRESHOLD; import static org.apache.geode.distributed.internal.OperationExecutors.SERIAL_EXECUTOR; -import static org.apache.geode.internal.AvailablePort.MULTICAST; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPortRange; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableUDPPort; import static org.apache.geode.internal.inet.LocalHostUtil.getLocalHost; import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort; import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; @@ -98,9 +97,9 @@ public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase { public void before() throws Exception { disconnectAllFromDS(); - this.mcastPort = getRandomAvailablePort(MULTICAST); - this.locatorPort = getRandomAvailablePort(SOCKET); - this.tcpPort = getRandomAvailablePort(SOCKET); + this.mcastPort = getRandomAvailableUDPPort(); + this.locatorPort = getRandomAvailableTCPPort(); + this.tcpPort = getRandomAvailableTCPPort(); int[] portRange = getRandomAvailableTCPPortRange(3, true); this.lowerBoundOfPortRange = portRange[0]; 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 52c99c1ad880..55cf06423b2b 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 @@ -41,6 +41,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.security.SecurableCommunicationChannel.LOCATOR; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.Disconnect.disconnectFromDS; @@ -258,7 +259,7 @@ protected static void stopLocator() { @Test @Ignore("GEODE=7760 - test sometimes hangs due to product issue") public void testCrashLocatorMultipleTimes() throws Exception { - port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + port1 = getRandomAvailableTCPPort(); DistributedTestUtils.deleteLocatorStateFile(port1); File logFile = new File(""); File stateFile = new File("locator" + port1 + "state.dat"); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ProductUseLogDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ProductUseLogDUnitTest.java index 663ffcd0087c..af4148beb183 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ProductUseLogDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/ProductUseLogDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertTrue; import java.io.BufferedReader; @@ -35,7 +36,6 @@ import org.apache.geode.cache.client.ClientRegionShortcut; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.Locator; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.SerializableCallable; @@ -66,7 +66,7 @@ public void testMembershipMonitoring() throws Exception { VM vm1 = host.getVM(1); // use a locator so we will monitor server load and record member->server mappings - int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int locatorPort = getRandomAvailableTCPPort(); Properties p = new Properties(); p.put(START_LOCATOR, "localhost[" + locatorPort + "],peer=false"); p.put(USE_CLUSTER_CONFIGURATION, "false"); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java index 6c390540625b..01ac95f0173e 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.disttx; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -44,7 +45,6 @@ import org.apache.geode.cache.Scope; import org.apache.geode.cache.SubscriptionAttributes; import org.apache.geode.cache.server.CacheServer; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.BucketRegion; import org.apache.geode.internal.cache.DistTXState; import org.apache.geode.internal.cache.GemFireCacheImpl; @@ -136,7 +136,7 @@ public int startServer(VM vm) { return (Integer) vm.invoke(new SerializableCallable() { @Override public Object call() throws Exception { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = getCache().addCacheServer(); s.setPort(port); s.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerGetAllDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerGetAllDUnitTest.java index c007a2230ba2..f2b5cd13c747 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerGetAllDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerGetAllDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.OFF_HEAP_MEMORY_SIZE; import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertTrue; import static org.apache.geode.test.dunit.Assert.fail; @@ -48,7 +49,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.cache30.ClientServerTestCase; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.offheap.MemoryAllocatorImpl; import org.apache.geode.test.dunit.Assert; @@ -79,7 +79,7 @@ public void testGetAllFromServer() throws Exception { final VM server = host.getVM(0); final VM client = host.getVM(1); final String regionName = getUniqueName(); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false); @@ -429,7 +429,7 @@ public void testGetAllWithCallbackFromServer() throws Exception { final VM server = host.getVM(0); final VM client = host.getVM(1); final String regionName = getUniqueName(); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, true); @@ -559,7 +559,7 @@ private void testGetFromServer(final int numLocalValues) { final VM server = host.getVM(0); final VM client = host.getVM(1); final String regionName = getUniqueName(); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); final String serverHost = NetworkUtils.getServerHostName(server.getHost()); createBridgeServer(server, regionName, serverPort, false, false); @@ -623,7 +623,7 @@ public void testGetAllWithExtraKeyFromServer() throws Exception { final VM server = host.getVM(0); final VM client = host.getVM(1); final String regionName = getUniqueName(); - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); final String serverHost = NetworkUtils.getServerHostName(server.getHost()); final int numLocalValues = 101; diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java index 5f46a564d207..3f52430c4d85 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ClientServerTransactionDUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.ConfigurationProperties.OFF_HEAP_MEMORY_SIZE; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.LogWriterUtils.getDUnitLogLevel; import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; @@ -100,7 +101,6 @@ import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.distributed.internal.membership.InternalDistributedMember; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.execute.data.CustId; import org.apache.geode.internal.cache.execute.data.Customer; import org.apache.geode.internal.cache.execute.data.Order; @@ -195,7 +195,7 @@ public Object call() throws Exception { TXManagerImpl txMgr = (TXManagerImpl) getCache().getCacheTransactionManager(); txMgr.setTransactionTimeToLiveForTest(txTimeoutSecs); if (startServer) { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = getCache().addCacheServer(); s.setPort(port); s.start(); @@ -222,7 +222,7 @@ public Object call() throws Exception { TXManagerImpl txMgr = (TXManagerImpl) cache.getCacheTransactionManager(); txMgr.setTransactionTimeToLiveForTest(10); if (startServer) { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = cache.addCacheServer(); s.setPort(port); s.start(); @@ -295,7 +295,7 @@ public VM getVMForTransactions(VM accessor, VM datastore) { public Object call() throws Exception { TXManagerImpl txMgr = (TXManagerImpl) getCache().getCacheTransactionManager(); txMgr.setTransactionTimeToLiveForTest(10); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = getCache().addCacheServer(); s.setPort(port); s.start(); @@ -2994,7 +2994,7 @@ public void testFailoverAfterCommitDistribution() { final int port2 = (Integer) datastore1.invoke(new SerializableCallable() { @Override public Object call() throws Exception { - return AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + return getRandomAvailableTCPPort(); } }); @@ -3106,7 +3106,7 @@ public void testFailoverAfterCommitDistributionInvokesListenerInClientOnlyOnce() VM client = host.getVM(3); final int port1 = createRegionsAndStartServer(server, false); - final int port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int port2 = getRandomAvailableTCPPort(); server.invoke(new CreateReplicateRegion("r1")); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ConcurrentMapOpsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ConcurrentMapOpsDUnitTest.java index c2ef40a9dacb..2bd848fc1e69 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ConcurrentMapOpsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ConcurrentMapOpsDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertFalse; import static org.apache.geode.test.dunit.Assert.assertNotNull; @@ -62,7 +63,6 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMember; import org.apache.geode.distributed.internal.membership.api.MemberDisconnectedException; import org.apache.geode.distributed.internal.membership.api.MembershipManagerHelper; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.IgnoredException; @@ -172,7 +172,7 @@ public Object call() throws Exception { } else { getCache().createRegionFactory(RegionShortcut.PARTITION).create(PR_REG_NAME); } - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = getCache().addCacheServer(); s.setPort(port); s.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationDUnitTest.java index 86707e36885c..0e252ef46616 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationDUnitTest.java @@ -26,8 +26,7 @@ import static org.apache.geode.distributed.internal.DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_DEFAULT; import static org.apache.geode.distributed.internal.DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_OFF; import static org.apache.geode.distributed.internal.DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_ON; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.cache.CacheServerImpl.generateNameForClientMsgsRegion; import static org.apache.geode.internal.cache.tier.sockets.CacheClientProxyFactory.INTERNAL_FACTORY_PROPERTY; import static org.apache.geode.internal.lang.SystemPropertyHelper.GEMFIRE_PREFIX; @@ -1347,7 +1346,7 @@ private int doCreate() throws IOException { factory.create(regionName); - int port = getRandomAvailablePort(SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer cacheServer = getCache().addCacheServer(); cacheServer.setPort(port); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationStatsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationStatsDUnitTest.java index 3865d9628b51..fb76dbff1f93 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationStatsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/DeltaPropagationStatsDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -42,7 +43,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.DistributionStats; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier; import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy; import org.apache.geode.internal.tcp.ConnectionTable; @@ -569,7 +569,7 @@ public void afterCreate(EntryEvent event) { } region.getAttributesMutator().setCloningEnabled(false); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/FixedPRSinglehopDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/FixedPRSinglehopDUnitTest.java index 6dd89b9b6c82..5cf0d33e6936 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/FixedPRSinglehopDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/FixedPRSinglehopDUnitTest.java @@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -52,7 +53,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.Locator; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.partitioned.fixed.QuarterPartitionResolver; import org.apache.geode.internal.cache.partitioned.fixed.SingleHopQuarterPartitionResolver; import org.apache.geode.internal.cache.tier.sockets.CacheServerTestUtil; @@ -274,7 +274,7 @@ public void testMetadataInClientWithFixedPartitions() throws Exception { VM server3 = host.getVM(2); VM server4 = host.getVM(3); Boolean simpleFPR = false; - final int portLocator = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int portLocator = getRandomAvailableTCPPort(); final String hostLocator = NetworkUtils.getServerHostName(server1.getHost()); final String locator = hostLocator + "[" + portLocator + "]"; server3.invoke(() -> FixedPRSinglehopDUnitTest.startLocatorInVM(portLocator)); @@ -366,7 +366,7 @@ public static int createServer(boolean isAccessor, List HAGIIDUnitTest.setSystemProperty()); - PORT2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + PORT2 = getRandomAvailableTCPPort(); // Start the client client0.invoke(() -> HAGIIDUnitTest.createClientCache(NetworkUtils.getServerHostName(host), new Integer(PORT1), new Integer(PORT2))); @@ -161,7 +161,7 @@ public static Integer createServer1Cache() throws Exception { factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java index 9df26afb6b27..02072d58eb9b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.cache.CacheServerImpl.generateNameForClientMsgsRegion; import static org.apache.geode.internal.lang.SystemPropertyHelper.GEMFIRE_PREFIX; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; @@ -56,7 +57,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.InternalCacheServer; import org.apache.geode.internal.cache.LocalRegion; @@ -176,7 +176,7 @@ public static Integer createServerCache(String ePolicy, Integer cap) throws Exce factory.setDataPolicy(DataPolicy.REPLICATE); factory.create(regionName); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); if (ePolicy != null) { @@ -196,7 +196,7 @@ public static Integer createServerCache(String ePolicy, Integer cap) throws Exce } private static Integer createOneMoreBridgeServer(Boolean notifyBySubscription) throws Exception { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(notifyBySubscription); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HASlowReceiverDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HASlowReceiverDUnitTest.java index 146f79b47dfe..fd4cecad590f 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HASlowReceiverDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HASlowReceiverDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.ConfigurationProperties.REMOVE_UNRESPONSIVE_CLIENT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -42,7 +43,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; import org.apache.geode.internal.cache.tier.sockets.CacheServerTestUtil; @@ -134,7 +134,7 @@ public static Integer createServerCache(String ePolicy, Integer cap) throws Exce cache.createRegion(regionName, attrs); logger = cache.getLogger(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/OperationsPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/OperationsPropagationDUnitTest.java index 1631eadade0d..fa9c172abac4 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/OperationsPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/OperationsPropagationDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertNotNull; import java.util.Arrays; @@ -35,7 +36,6 @@ import org.apache.geode.cache.Scope; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; @@ -139,7 +139,7 @@ public static Integer createServerCache() throws Exception { CacheServerImpl server = (CacheServerImpl) cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/PutAllDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/PutAllDUnitTest.java index 9fec579e4a7d..0ad6a40ae2c0 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/PutAllDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/PutAllDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -47,7 +48,6 @@ import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.EntryEventImpl; import org.apache.geode.internal.cache.EventID; @@ -158,7 +158,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); server = (CacheServerImpl) cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/StatsBugDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/StatsBugDUnitTest.java index daf058019a2e..94203ed68095 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/StatsBugDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/StatsBugDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.fail; import java.util.Iterator; @@ -37,7 +38,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.LogWriterUtils; import org.apache.geode.test.dunit.NetworkUtils; @@ -189,7 +189,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(false); server.setSocketBufferSize(32768); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java index a2560549e749..9387434c89b1 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java @@ -28,8 +28,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER; import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT; import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; @@ -157,7 +156,7 @@ public void setUp() throws Exception { } regionName = getUniqueName() + "Region"; - jmxManagerPort = getRandomAvailablePort(SOCKET); + jmxManagerPort = getRandomAvailableTCPPort(); } @After diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/BackwardCompatibilityHigherVersionClientDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/BackwardCompatibilityHigherVersionClientDUnitTest.java index 4d6d2d46da0c..0ae230642f43 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/BackwardCompatibilityHigherVersionClientDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/BackwardCompatibilityHigherVersionClientDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -38,7 +39,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.tier.ConnectionProxy; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.Host; @@ -121,7 +121,7 @@ public static Integer createServerCache() throws Exception { factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTransactionsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTransactionsDUnitTest.java index 945e87efa7e7..9e1f15fa5476 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTransactionsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTransactionsDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -47,7 +48,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.Host; @@ -764,7 +764,7 @@ public void afterInvalidate(EntryEvent event) { Region r1 = cache.createRegion(REGION_NAME, factory.create()); assertNotNull(r1); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setMaxThreads(maxThreads.intValue()); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClearPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClearPropagationDUnitTest.java index ce0c7c99d6c8..06da66ebac56 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClearPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClearPropagationDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -48,7 +49,6 @@ import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheObserverAdapter; import org.apache.geode.internal.cache.CacheObserverHolder; import org.apache.geode.internal.cache.EventID; @@ -386,7 +386,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientConflationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientConflationDUnitTest.java index 2e78fa32645b..e659f06e5c17 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientConflationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientConflationDUnitTest.java @@ -22,6 +22,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.internal.DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_OFF; import static org.apache.geode.distributed.internal.DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_ON; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -48,7 +49,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.DistributionConfig; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -418,7 +418,7 @@ public static Integer createServerCache() throws Exception { cacheServer.createRegion(REGION_NAME1, attrs1); cacheServer.createRegion(REGION_NAME2, attrs2); CacheServer server = cacheServer.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.setSocketBufferSize(32768); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientInterestNotifyDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientInterestNotifyDUnitTest.java index 74cafa22721a..4eb487dda55c 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientInterestNotifyDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientInterestNotifyDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -45,7 +46,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -429,7 +429,7 @@ public static Integer createServerCache() throws Exception { cacheServer.createRegion(REGION_NAME2, attrs); cacheServer.createRegion(REGION_NAME3, attrs); CacheServer server = cacheServer.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.setSocketBufferSize(32768); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientServerForceInvalidateDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientServerForceInvalidateDUnitTest.java index dab992fd5b17..43b1c1e28c70 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientServerForceInvalidateDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientServerForceInvalidateDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -44,7 +45,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.AbstractRegionMap; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -292,7 +292,7 @@ private static Integer createServerCache(Boolean concurrencyChecksEnabled, Boole assertNotNull(r1); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); logger.info("Starting server on port " + port); server.setPort(port); server.setMaxThreads(maxThreads.intValue()); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ConflationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ConflationDUnitTest.java index 8e4026fb5fbb..03a5ab683ee3 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ConflationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ConflationDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -44,7 +45,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -558,7 +558,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME1, attrs); cache.createRegion(REGION_NAME2, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.setSocketBufferSize(32768); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java index 887f524bbb4d..5d0326bc75da 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DataSerializerPropagationDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -45,7 +46,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; @@ -533,7 +533,7 @@ private static Integer createServerCache() throws Exception { RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setMaxThreads(0); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java index 48d7073005de..872933e8d8cf 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DestroyEntryPropagationDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.client.PoolManager.find; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertNotNull; import static org.apache.geode.test.dunit.Assert.assertNull; @@ -50,7 +51,6 @@ import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.cache30.CertifiableTestCacheListener; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.EventID; import org.apache.geode.internal.cache.EventIDHolder; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -454,7 +454,7 @@ private static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java index fea4f040ce58..182c1fd0599e 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientQueueSizeDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_ID; import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_TIMEOUT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; @@ -43,7 +44,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.test.dunit.DistributedTestUtils; import org.apache.geode.test.dunit.Host; @@ -296,7 +296,7 @@ public static Boolean isPrimary() throws Exception { } public static Integer createCacheServer() throws Exception { - return createCacheServer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + return createCacheServer(getRandomAvailableTCPPort()); } @SuppressWarnings("deprecation") diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java index bbc367729588..ce65ff78a3b7 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientReconnectDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_TIMEOUT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -51,7 +52,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; @@ -498,7 +498,7 @@ private static Integer createServerCache() throws Exception { Region r = cache.createRegion(REGION_NAME, attrs); assertNotNull(r); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setNotifyBySubscription(true); server1.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java index c58066ac97f3..9680f06f7581 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_TIMEOUT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -40,7 +41,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.internal.DistributionConfig; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.FilterProfile; import org.apache.geode.internal.cache.GemFireCacheImpl; @@ -413,7 +413,7 @@ public void run2() throws CacheException { public void testDurableClientWithRegistrationHA() { // Step 1: Start server1 - PORT2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + PORT2 = getRandomAvailableTCPPort(); PORT1 = ((Integer) this.server1VM .invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true)))) @@ -514,7 +514,7 @@ public void run2() throws CacheException { public void testDurableClientDisConnectWithRegistrationHA() { // Step 1: Start server1 - PORT2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + PORT2 = getRandomAvailableTCPPort(); PORT1 = ((Integer) this.server1VM .invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true)))) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java index be3c88d5620d..cdb1f0c87256 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java @@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_TIMEOUT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -43,7 +44,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -458,7 +458,7 @@ public static Integer createServerCache() throws Exception { Region r = cache.createRegion(REGION_NAME, attrs); assertNotNull(r); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setNotifyBySubscription(true); server1.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java index c2309051a82b..2ffafd494cd7 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -44,7 +45,6 @@ import org.apache.geode.cache.util.CacheWriterAdapter; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheObserverAdapter; import org.apache.geode.internal.cache.CacheObserverHolder; import org.apache.geode.internal.cache.EntryEventImpl; @@ -345,7 +345,7 @@ public void afterRegionClear(RegionEvent event) { RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ForceInvalidateEvictionDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ForceInvalidateEvictionDUnitTest.java index 3f07c9d5cd23..021a3bb77c93 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ForceInvalidateEvictionDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ForceInvalidateEvictionDUnitTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.internal.cache.tier.sockets; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertFalse; import java.io.IOException; @@ -41,7 +42,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CachedDeserializable; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.internal.cache.Token; @@ -380,7 +380,7 @@ public void run() { } private int addCacheServer(VM vm) { - final int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int port = getRandomAvailableTCPPort(); vm.invoke(new SerializableRunnable("add cache server") { @Override public void run() { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAInterestTestCase.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAInterestTestCase.java index 6444b7ad7463..af5f92b5c0ef 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAInterestTestCase.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAInterestTestCase.java @@ -20,6 +20,7 @@ import static org.apache.geode.cache.client.internal.RegisterInterestTracker.interestListIndex; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.cache.tier.InterestType.KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -51,7 +52,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -1015,7 +1015,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, factory.create()); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setMaximumTimeBetweenPings(180000); // ensures updates to be sent instead of invalidations @@ -1033,7 +1033,7 @@ public static Integer createServerCacheWithLocalRegion() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); // ensures updates to be sent instead of invalidations server.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java index f1a2ad9ea3b2..f70234d2b1e2 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/HAStartupAndFailoverDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -47,7 +48,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -659,7 +659,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); // ensures updates to be sent instead of invalidations server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java index 8e7bb3b547d0..9f20fac993b6 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InstantiatorPropagationDUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.InternalInstantiator.getInstantiators; import static org.apache.geode.test.dunit.DistributedTestUtils.unregisterInstantiatorsInThisVM; import static org.junit.Assert.assertEquals; @@ -50,7 +51,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -146,7 +146,7 @@ public static Integer createServerCache(Integer maxThreads) throws Exception { factory.setMirrorType(MirrorType.KEYS_VALUES); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setMaxThreads(maxThreads.intValue()); @@ -813,7 +813,7 @@ public static Integer createServerCacheTwo(Integer maxThreads) throws Exception RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setMaxThreads(maxThreads.intValue()); @@ -832,7 +832,7 @@ public static Integer createServerCacheOne(Integer maxThreads) throws Exception factory.setMirrorType(MirrorType.KEYS_VALUES); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setMaxThreads(maxThreads.intValue()); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java index a7a784663b7a..36d35ec10689 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -55,7 +56,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; @@ -626,7 +626,7 @@ private static void addPartitionedRegion() { private static CacheServer addCacheServer() throws Exception { CacheServer s = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); s.setPort(port); s.start(); return s; diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java index 44bb6d2f1420..f9c19ef4d096 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.cache.client.PoolManager.find; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -51,7 +52,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Host; @@ -360,7 +360,7 @@ public static Integer createServerCache(Integer maxThreads) throws Exception { RegionAttributes attrs = impl.createServerCacheAttributes(); cache.createRegion(REGION_NAME, attrs); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setMaxThreads(maxThreads.intValue()); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java index ce267e2b1c76..f7f23f4cd33b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListRecoveryDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -49,7 +50,6 @@ import org.apache.geode.cache.client.internal.RegisterInterestTracker; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -231,7 +231,7 @@ public static Integer createServerCache() throws Exception { factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestResultPolicyDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestResultPolicyDUnitTest.java index 37cebd4c04ce..1ab613eb4421 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestResultPolicyDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestResultPolicyDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import java.util.ArrayList; @@ -40,7 +41,6 @@ import org.apache.geode.cache.client.ServerConnectivityException; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.IgnoredException; @@ -242,7 +242,7 @@ public static Integer createServerCache() throws Exception { RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.setSocketBufferSize(32768); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelTestBase.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelTestBase.java index 4b2f1fd60d6e..352076212f9b 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelTestBase.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RedundancyLevelTestBase.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.equalTo; @@ -47,7 +48,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.ClientServerObserver; import org.apache.geode.internal.cache.ClientServerObserverAdapter; @@ -393,7 +393,7 @@ private static Integer createServerCache() throws Exception { CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setMaximumTimeBetweenPings(180000); server1.setPort(port); server1.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegionCloseDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegionCloseDUnitTest.java index e921f1b097c8..c081dad3f2d3 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegionCloseDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegionCloseDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -38,7 +39,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Assert; @@ -134,7 +134,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestBeforeRegionCreationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestBeforeRegionCreationDUnitTest.java index 94181ee3ac20..29b21a3f61fa 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestBeforeRegionCreationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestBeforeRegionCreationDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertNotNull; import java.util.Properties; @@ -38,7 +39,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheObserverAdapter; import org.apache.geode.internal.cache.CacheObserverHolder; import org.apache.geode.internal.cache.CacheServerImpl; @@ -207,7 +207,7 @@ public static Integer createServer(Boolean createRegion) throws Exception { } CacheServerImpl server = (CacheServerImpl) cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestKeysDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestKeysDUnitTest.java index fd1dcb7ddbbc..329e89fbbb20 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestKeysDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestKeysDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -40,7 +41,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Assert; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.LogWriterUtils; @@ -188,7 +188,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ReliableMessagingDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ReliableMessagingDUnitTest.java index bc8ff50d088f..e1f96471d990 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ReliableMessagingDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ReliableMessagingDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -44,7 +45,6 @@ import org.apache.geode.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.ClientServerObserver; import org.apache.geode.internal.cache.ClientServerObserverAdapter; import org.apache.geode.internal.cache.ClientServerObserverHolder; @@ -353,7 +353,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UnregisterInterestDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UnregisterInterestDUnitTest.java index 9d337f921656..f23fc90fe710 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UnregisterInterestDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UnregisterInterestDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.client.PoolManager.find; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import java.util.ArrayList; @@ -37,7 +38,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.FilterProfile; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -332,7 +332,7 @@ public static Integer createCacheAndStartServer() throws Exception { RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory(RegionShortcut.REPLICATE); rf.create(regionname); CacheServer server = ((GemFireCacheImpl) cache).addCacheServer(); - server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + server.setPort(getRandomAvailableTCPPort()); server.start(); return server.getPort(); } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UpdatePropagationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UpdatePropagationDUnitTest.java index b4c717ee2d5b..b3d5dc5336e5 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UpdatePropagationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/UpdatePropagationDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; @@ -49,7 +50,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache30.CacheSerializableRunnable; import org.apache.geode.distributed.internal.ServerLocationAndMemberId; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.dunit.NetworkUtils; @@ -254,7 +254,7 @@ private Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME, attrs); CacheServer server = cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/VerifyUpdatesFromNonInterestEndPointDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/VerifyUpdatesFromNonInterestEndPointDUnitTest.java index 0f3e618af5dd..3c94b0dacc76 100755 --- a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/VerifyUpdatesFromNonInterestEndPointDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/VerifyUpdatesFromNonInterestEndPointDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -40,7 +41,6 @@ import org.apache.geode.cache.client.internal.ServerRegionProxy; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.EventID; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.test.dunit.Assert; @@ -197,7 +197,7 @@ public static Integer createServerCache() throws Exception { RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setNotifyBySubscription(true); server1.start(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/UniversalMembershipListenerAdapterDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/UniversalMembershipListenerAdapterDUnitTest.java index 2a56fb1771ec..9e2de28bfd87 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/UniversalMembershipListenerAdapterDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/UniversalMembershipListenerAdapterDUnitTest.java @@ -23,8 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.internal.DistributionConfig.RESTRICT_MEMBERSHIP_PORT_RANGE; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName; @@ -1151,7 +1150,7 @@ public synchronized void memberCrashed(MembershipEvent event) { Host host = Host.getHost(0); VM vm0 = host.getVM(0); String name = this.getUniqueName(); - int[] ports = new int[] {getRandomAvailablePort(SOCKET)}; + int[] ports = getRandomAvailableTCPPorts(1); assertThat(ports[0] != 0).isTrue(); // create BridgeServer in controller vm... @@ -1400,7 +1399,7 @@ public synchronized void memberCrashed(ClientMembershipEvent event) { Host host = Host.getHost(0); VM vm0 = host.getVM(0); String name = getUniqueName(); - int[] ports = new int[] {getRandomAvailablePort(SOCKET)}; + int[] ports = getRandomAvailableTCPPorts(1); assertThat(ports[0] != 0).isTrue(); Properties config = new Properties(); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientAuthenticationTestCase.java b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientAuthenticationTestCase.java index 9bc3b7112611..77762c468a7f 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/security/ClientAuthenticationTestCase.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/security/ClientAuthenticationTestCase.java @@ -14,8 +14,7 @@ */ package org.apache.geode.security; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.security.ClientAuthenticationTestUtils.createCacheClient; import static org.apache.geode.security.ClientAuthenticationTestUtils.createCacheServer; import static org.apache.geode.security.ClientAuthenticationTestUtils.registerAllInterest; @@ -483,7 +482,7 @@ protected void doTestCredentialsWithFailover(final boolean multiUser) throws Exc // Get a port for second server but do not start it // This forces the clients to connect to the first server - int port2 = getRandomAvailablePort(SOCKET); + int port2 = getRandomAvailableTCPPort(); // Start the clients with valid credentials Properties credentials1 = gen.getValidCredentials(5); @@ -564,7 +563,7 @@ protected void doTestCredentialsForNotifications(final boolean multiUser) throws // Get a port for second server but do not start it // This forces the clients to connect to the first server - int port2 = getRandomAvailablePort(SOCKET); + int port2 = getRandomAvailableTCPPort(); // Start the clients with valid credentials Properties credentials1 = gen.getValidCredentials(3); diff --git a/geode-core/src/distributedTest/java/org/apache/geode/security/IntegratedSecurityPeerAuthDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/security/IntegratedSecurityPeerAuthDistributedTest.java index 0333f815decb..698e840ec492 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/security/IntegratedSecurityPeerAuthDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/security/IntegratedSecurityPeerAuthDistributedTest.java @@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT; import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -28,7 +29,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.security.templates.UserPasswordAuthInit; import org.apache.geode.test.dunit.DistributedTestUtils; import org.apache.geode.test.dunit.Host; @@ -55,7 +55,7 @@ public final void postSetUp() throws Exception { server1 = host.getVM(1); server2 = host.getVM(2); - int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int locatorPort = getRandomAvailableTCPPort(); locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]"; locator.invoke(() -> { diff --git a/geode-core/src/distributedTest/java/org/apache/geode/security/P2PAuthenticationDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/security/P2PAuthenticationDUnitTest.java index 6616d91fc8a5..0c06c387a63e 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/security/P2PAuthenticationDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/security/P2PAuthenticationDUnitTest.java @@ -19,8 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR; import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.security.SecurityTestUtils.startLocator; import static org.apache.geode.security.SecurityTestUtils.stopLocator; import static org.apache.geode.test.dunit.Assert.assertEquals; @@ -86,7 +85,7 @@ public final void postSetUp() throws Exception { */ @Test public void testIllegalPropertyCombos() throws Exception { - int port = getRandomAvailablePort(SOCKET); + int port = getRandomAvailableTCPPort(); Properties props = new Properties(); props.setProperty(MCAST_PORT, "26753"); @@ -151,7 +150,7 @@ public void testIllegalPropertyCombos() throws Exception { */ @Test public void testP2PAuthenticationWithInvalidAuthInitialize() throws Exception { - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); CredentialGenerator gen = new DummyCredentialGenerator(); assertNotNull(gen.getAuthenticator()); @@ -183,7 +182,7 @@ public void testP2PAuthenticationWithInvalidAuthInitialize() throws Exception { */ @Test public void testP2PAuthenticationWithInvalidAuthenticator() throws Exception { - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); CredentialGenerator gen = new DummyCredentialGenerator(); assertNotNull(gen.getAuthInit()); @@ -212,7 +211,7 @@ public void testP2PAuthenticationWithInvalidAuthenticator() throws Exception { @Test public void testP2PAuthenticationWithNoCredentials() throws Exception { - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); CredentialGenerator gen = new DummyCredentialGenerator(); assertNotNull(gen.getAuthenticator()); @@ -242,7 +241,7 @@ public void testP2PAuthenticationWithNoCredentials() throws Exception { @Test public void testP2PAuthenticationWithValidCredentials() throws Exception { - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); CredentialGenerator gen = new DummyCredentialGenerator(); assertNotNull(gen.getAuthenticator()); @@ -274,7 +273,7 @@ public void testP2PAuthenticationWithValidCredentials() throws Exception { public void testP2PAuthenticationWithBothValidAndInValidCredentials() throws Exception { addIgnoredException("Authentication failed"); - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); CredentialGenerator gen = new DummyCredentialGenerator(); assertNotNull(gen.getAuthenticator()); @@ -353,7 +352,7 @@ public void testP2PViewChangeReject() throws Exception { // Start the locator with the LDAP authenticator Properties props = new Properties(); - int port = getRandomAvailablePort(SOCKET); + int port = getRandomAvailableTCPPort(); final String locators = getIPLiteral() + "[" + port + "]"; props.setProperty(SECURITY_PEER_AUTH_INIT, authInit); @@ -440,7 +439,7 @@ public void testP2PViewChangeReject() throws Exception { */ @Test public void testP2PLargeCredentialSucceeds() throws Exception { - int locatorPort = getRandomAvailablePort(SOCKET); + int locatorPort = getRandomAvailableTCPPort(); final Host host = Host.getHost(0); final VM peer2 = host.getVM(1); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/ConnectionPoolImplJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/ConnectionPoolImplJUnitTest.java index f08206d529a1..fff097f3eff4 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/ConnectionPoolImplJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/ConnectionPoolImplJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -38,7 +39,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.internal.ServerLocation; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.test.junit.categories.ClientServerTest; @@ -59,7 +59,7 @@ public void setUp() { props.setProperty(MCAST_PORT, "0"); props.setProperty(LOCATORS, ""); cache = CacheFactory.create(DistributedSystem.connect(props)); - port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + port = getRandomAvailableTCPPort(); } @After diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java index fafb051d2479..329197e6f5bb 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java @@ -21,8 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATOR_WAIT_TIME; import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.util.internal.GeodeGlossary.GEMFIRE_PREFIX; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; @@ -129,7 +128,7 @@ public void testThatLocatorDoesNotCreateFileWithZeroPort() throws Exception { */ @Test public void testGfshConnectShouldSucceedIfJmxManagerStartIsTrueInLocator() throws Exception { - int jmxPort = getRandomAvailablePort(SOCKET); + int jmxPort = getRandomAvailableTCPPort(); Properties configProperties = new Properties(); configProperties.setProperty(MCAST_PORT, "0"); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java index eb36865a3ac1..63165bf48e5b 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java @@ -37,6 +37,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE; import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLE_RATE; import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -70,7 +71,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.DistributedSystemDisconnectedException; import org.apache.geode.distributed.Locator; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.Config; import org.apache.geode.internal.ConfigSource; import org.apache.geode.internal.logging.InternalLogWriter; @@ -629,7 +629,7 @@ public void testNonDefaultLogLevel() { @Test public void testStartLocator() { Properties props = new Properties(); - int unusedPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int unusedPort = getRandomAvailableTCPPort(); props.setProperty(MCAST_PORT, "0"); props.setProperty(START_LOCATOR, "localhost[" + unusedPort + "],server=false,peer=true"); deleteStateFile(unusedPort); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPClientSSLIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPClientSSLIntegrationTest.java index 8ab0a8e907fe..a8b54538621e 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPClientSSLIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/tcpserver/TCPClientSSLIntegrationTest.java @@ -14,6 +14,7 @@ */ package org.apache.geode.distributed.internal.tcpserver; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.security.SecurableCommunicationChannels.LOCATOR; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -43,7 +44,6 @@ import org.apache.geode.cache.ssl.CertificateMaterial; import org.apache.geode.distributed.internal.DistributionConfigImpl; import org.apache.geode.distributed.internal.DistributionStats; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.net.SSLConfigurationFactory; import org.apache.geode.internal.net.SocketCreator; @@ -128,7 +128,7 @@ private void startServerAndClient(CertificateMaterial serverCertificate, private void startTcpServer(Properties sslProperties) throws IOException { localhost = InetAddress.getLocalHost(); - port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + port = getRandomAvailableTCPPort(); TcpHandler tcpHandler = Mockito.mock(TcpHandler.class); when(tcpHandler.processRequest(any())).thenReturn("Running!"); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/ClientMessagesRegionCreationAndDestroyJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/ClientMessagesRegionCreationAndDestroyJUnitTest.java index 4404265da2a5..d89f44dab6cf 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/ClientMessagesRegionCreationAndDestroyJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/ClientMessagesRegionCreationAndDestroyJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -33,7 +34,6 @@ import org.apache.geode.cache.CacheException; import org.apache.geode.cache.CacheFactory; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.ha.HAContainerWrapper; import org.apache.geode.internal.cache.ha.HARegionQueue; @@ -71,7 +71,7 @@ public void setUp() throws Exception { private void attachBridgeServer() throws IOException { CacheServerImpl server = (CacheServerImpl) cache.addCacheServer(); assertNotNull(server); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.getClientSubscriptionConfig().setEvictionPolicy(HARegionQueue.HA_EVICTION_POLICY_ENTRY); server.start(); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerMaxConnectionsJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerMaxConnectionsJUnitTest.java index 55160cf3514d..29b2ad19100d 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerMaxConnectionsJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/CacheServerMaxConnectionsJUnitTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -40,7 +41,6 @@ import org.apache.geode.cache.client.internal.PoolImpl; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.WaitCriterion; import org.apache.geode.test.junit.categories.ClientServerTest; @@ -114,7 +114,7 @@ private int createServer() throws IOException { this.system = DistributedSystem.connect(p); this.cache = CacheFactory.create(system); server = this.cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setMaxConnections(MAX_CNXS); server.setMaxThreads(getMaxThreads()); server.setPort(port); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitorIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitorIntegrationTest.java index 4b7e7f99a3ad..ac37b339f570 100755 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitorIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitorIntegrationTest.java @@ -16,6 +16,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -44,7 +45,6 @@ import org.apache.geode.cache.client.internal.ServerRegionProxy; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.EventID; import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.test.junit.categories.ClientServerTest; @@ -126,7 +126,7 @@ private int createServer() throws Exception { this.system = DistributedSystem.connect(p); this.cache = CacheFactory.create(system); server = this.cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setMaximumTimeBetweenPings(TIME_BETWEEN_PINGS); server.setMaxThreads(getMaxThreads()); server.setPort(port); diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ConnectionProxyJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ConnectionProxyJUnitTest.java index 10ad07027523..7b6be7e3847a 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ConnectionProxyJUnitTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/tier/sockets/ConnectionProxyJUnitTest.java @@ -21,6 +21,7 @@ import static org.apache.geode.cache.client.PoolManager.createFactory; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -52,7 +53,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.EntryEventImpl; import org.apache.geode.internal.cache.EventID; import org.apache.geode.internal.cache.ha.ThreadIdentifier; @@ -129,7 +129,7 @@ public void tearDown() throws Exception { @Ignore @Test public void testListenerOnServerSitForever() throws Exception { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); Region testRegion = null; CacheServer server = this.cache.addCacheServer(); @@ -198,7 +198,7 @@ public void afterCreate(EntryEvent event) { */ @Test public void testDeadServerMonitorPingNature1() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); // final int maxWaitTime = 10000; try { @@ -258,7 +258,7 @@ public void testDeadServerMonitorPingNature1() { */ @Test public void testDeadServerMonitorPingNature2() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); // final int maxWaitTime = 10000; try { @@ -303,7 +303,7 @@ public void testDeadServerMonitorPingNature2() { @Test public void testThreadIdToSequenceIdMapCreation() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -342,7 +342,7 @@ public void testThreadIdToSequenceIdMapCreation() { @Test public void testThreadIdToSequenceIdMapExpiryPositive() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -388,7 +388,7 @@ public void testThreadIdToSequenceIdMapExpiryPositive() { @Test public void testThreadIdToSequenceIdMapExpiryNegative() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -428,7 +428,7 @@ public void testThreadIdToSequenceIdMapExpiryNegative() { @Test public void testThreadIdToSequenceIdMapConcurrency() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -480,7 +480,7 @@ public void testThreadIdToSequenceIdMapConcurrency() { @Test public void testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -534,7 +534,7 @@ public void testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored() { @Test public void testCleanCloseOfThreadIdToSeqId() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -588,7 +588,7 @@ public void testCleanCloseOfThreadIdToSeqId() { @Test public void testTwoClientsHavingDifferentThreadIdMaps() { - int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port3 = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -636,7 +636,7 @@ public void testTwoClientsHavingDifferentThreadIdMaps() { @Test public void testPeriodicAckSendByClient() { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server = null; try { try { @@ -703,7 +703,7 @@ public void testPeriodicAckSendByClient() { // No ack will be send if Redundancy level = 0 @Test public void testNoAckSendByClient() { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server = null; try { try { diff --git a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/api/LoggingWithLocatorIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/api/LoggingWithLocatorIntegrationTest.java index 91d36916bd30..94ef245f26a0 100644 --- a/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/api/LoggingWithLocatorIntegrationTest.java +++ b/geode-core/src/integrationTest/java/org/apache/geode/logging/internal/api/LoggingWithLocatorIntegrationTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE; import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.logging.internal.spi.LogWriterLevel.CONFIG; import static org.apache.geode.logging.internal.spi.LogWriterLevel.INFO; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; @@ -40,7 +41,6 @@ import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.logging.internal.log4j.LogWriterLogger; import org.apache.geode.logging.internal.log4j.api.LogService; import org.apache.geode.logging.internal.spi.LogConfig; @@ -77,7 +77,7 @@ public void setUp() throws Exception { testName.getMethodName() + "-system-" + System.currentTimeMillis() + ".log"); securityLogFile = new File(""); - port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + port = getRandomAvailableTCPPort(); } @After diff --git a/geode-core/src/upgradeTest/java/org/apache/geode/internal/cache/TxCommitMessageBCTestBase.java b/geode-core/src/upgradeTest/java/org/apache/geode/internal/cache/TxCommitMessageBCTestBase.java index 32eed52d594f..c4a8399b1334 100644 --- a/geode-core/src/upgradeTest/java/org/apache/geode/internal/cache/TxCommitMessageBCTestBase.java +++ b/geode-core/src/upgradeTest/java/org/apache/geode/internal/cache/TxCommitMessageBCTestBase.java @@ -14,6 +14,8 @@ */ package org.apache.geode.internal.cache; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Arrays; @@ -43,7 +45,6 @@ import org.apache.geode.cache.client.PoolManager; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; @@ -171,7 +172,7 @@ public void close() {} rf2.create(PARTITION_REGION_NAME); CacheServer server = cache.addCacheServer(); - server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + server.setPort(getRandomAvailableTCPPort()); server.start(); return server.getPort(); } diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/PRDeltaPropagationDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/PRDeltaPropagationDUnitTest.java index 2e223857e6c2..9f016e50f2ba 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/PRDeltaPropagationDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/PRDeltaPropagationDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.internal.Assert.fail; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Host.getHost; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -63,7 +64,6 @@ import org.apache.geode.compression.Compressor; import org.apache.geode.compression.SnappyCompressor; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier; import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy; import org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTestHelper; @@ -786,7 +786,7 @@ private int createCacheServerWithPR(String partitionedRegionName, int redundancy CacheServer server1 = cache.addCacheServer(); assertNotNull(server1); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.start(); assertTrue(server1.isRunning()); @@ -830,7 +830,7 @@ public void afterUpdate(EntryEvent event) { } CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); // ensures updates to be sent instead of invalidations server.setNotifyBySubscription(true); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/RemoteCQTransactionDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/RemoteCQTransactionDUnitTest.java index 78f5a2e59e2e..0bb891f501f4 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/RemoteCQTransactionDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/RemoteCQTransactionDUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.internal.cache; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; @@ -63,7 +64,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache.util.CacheWriterAdapter; import org.apache.geode.distributed.DistributedMember; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.execute.CustomerIDPartitionResolver; import org.apache.geode.internal.cache.execute.data.CustId; import org.apache.geode.internal.cache.execute.data.Customer; @@ -751,7 +751,7 @@ protected Integer startServer(VM vm) { return (Integer) vm.invoke(new SerializableCallable() { @Override public Object call() throws Exception { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer s = getCache().addCacheServer(); s.setPort(port); s.start(); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java index da51ee2a1d35..d6c314763d84 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/CQListGIIDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertNotNull; import static org.apache.geode.test.dunit.Assert.assertTrue; @@ -59,7 +60,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache30.CertifiableTestCacheListener; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.InternalRegionArguments; import org.apache.geode.internal.cache.LocalRegion; @@ -202,7 +202,7 @@ public static Integer createServerCache(String ePolicy, Integer cap) throws Exce Thread.sleep(2000); logger = cache.getLogger(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); @@ -224,7 +224,7 @@ public static Integer createServerCache(String ePolicy, Integer cap) throws Exce } public static Integer createOneMoreBridgeServer(Boolean notifyBySubscription) throws Exception { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(notifyBySubscription.booleanValue()); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/HADispatcherDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/HADispatcherDUnitTest.java index 00321848f751..f2d0adbb8457 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/HADispatcherDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/ha/HADispatcherDUnitTest.java @@ -17,8 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertNotNull; import static org.apache.geode.test.dunit.Assert.assertTrue; @@ -311,7 +310,7 @@ private Integer createServerCache(Boolean isListenerPresent) throws IOException cache.createRegion(REGION_NAME, attrs); CacheServerImpl server = (CacheServerImpl) cache.addCacheServer(); assertNotNull(server); - int port = getRandomAvailablePort(SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setNotifyBySubscription(true); server.start(); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientToServerDeltaDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientToServerDeltaDUnitTest.java index 96516e73a352..284810021c46 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientToServerDeltaDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/ClientToServerDeltaDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -55,7 +56,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache.util.CqListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.internal.cache.TestObjectWithIdentifier; @@ -666,7 +666,7 @@ public void afterCreate(EntryEvent event) { } CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); // ensures updates to be sent instead of invalidations server.setNotifyBySubscription(true); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaPropagationWithCQDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaPropagationWithCQDUnitTest.java index 894e2857fe40..bcafc2f8ace2 100644 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaPropagationWithCQDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaPropagationWithCQDUnitTest.java @@ -19,6 +19,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -51,7 +52,6 @@ import org.apache.geode.cache.util.CqListenerAdapter; import org.apache.geode.cache30.ClientServerTestCase; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; @@ -251,7 +251,7 @@ public static Integer createCacheServer() throws Exception { ((Cache) cache).createRegionFactory(RegionShortcut.REPLICATE); rf.create(regionName); CacheServer server = ((Cache) cache).addCacheServer(); - server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); + server.setPort(getRandomAvailableTCPPort()); server.start(); return server.getPort(); } diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaToRegionRelationCQRegistrationDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaToRegionRelationCQRegistrationDUnitTest.java index 0635f11189c4..5249156bc72b 100755 --- a/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaToRegionRelationCQRegistrationDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DeltaToRegionRelationCQRegistrationDUnitTest.java @@ -17,6 +17,7 @@ import static org.apache.geode.cache.Region.SEPARATOR; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertEquals; import static org.apache.geode.test.dunit.Assert.assertFalse; import static org.apache.geode.test.dunit.Assert.assertNotNull; @@ -44,7 +45,6 @@ import org.apache.geode.cache.query.QueryService; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.test.awaitility.GeodeAwaitility; import org.apache.geode.test.dunit.Host; @@ -479,7 +479,7 @@ public static Integer createServerCache() throws Exception { cache.createRegion(REGION_NAME2, attrs); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); // ensures updates to be sent instead of invalidations server.setNotifyBySubscription(true); diff --git a/geode-cq/src/distributedTest/java/org/apache/geode/management/CacheServerManagementDUnitTest.java b/geode-cq/src/distributedTest/java/org/apache/geode/management/CacheServerManagementDUnitTest.java index a559bb05d66b..d129c0a41b6e 100644 --- a/geode-cq/src/distributedTest/java/org/apache/geode/management/CacheServerManagementDUnitTest.java +++ b/geode-cq/src/distributedTest/java/org/apache/geode/management/CacheServerManagementDUnitTest.java @@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.internal.cache.GemFireCacheImpl.getInstance; import static org.apache.geode.management.ManagementService.getManagementService; import static org.apache.geode.management.internal.MBeanJMXAdapter.getClientServiceMBeanName; @@ -58,7 +59,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.Locator; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.management.internal.JmxManagerLocatorRequest; @@ -180,7 +180,7 @@ public void testCacheClient() throws Exception { VM server = host.getVM(1); VM client = host.getVM(2); - int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int locatorPort = getRandomAvailableTCPPort(); locator.invoke("Start Locator", () -> startLocator(locator.getHost(), locatorPort, "")); String locators = NetworkUtils.getServerHostName(locator.getHost()) + "[" + locatorPort + "]"; @@ -219,7 +219,7 @@ public void testBug46049() throws Exception { VM server = host.getVM(1); // Step 1: - final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int locatorPort = getRandomAvailableTCPPort(); locator.invoke("Start Locator", () -> startLocator(locator.getHost(), locatorPort, "")); String locators = NetworkUtils.getServerHostName(locator.getHost()) + "[" + locatorPort + "]"; diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/MemberStarterRuleIntegrationTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/MemberStarterRuleIntegrationTest.java index 278e34393f0a..c93521a587dd 100644 --- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/MemberStarterRuleIntegrationTest.java +++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/MemberStarterRuleIntegrationTest.java @@ -15,6 +15,7 @@ package org.apache.geode.test.dunit.rules.tests; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.assertj.core.api.Assertions.assertThat; import org.junit.After; @@ -22,7 +23,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.test.junit.rules.LocatorStarterRule; import org.apache.geode.test.junit.rules.ServerStarterRule; @@ -44,7 +44,7 @@ public void cleanupAnyStartedMembers() { @Test public void testWithPortOnLocator() { - int targetPort = AvailablePort.getRandomAvailablePort(1); + int targetPort = getRandomAvailableTCPPort(); locator = new LocatorStarterRule().withPort(targetPort).withAutoStart(); locator.before(); @@ -59,7 +59,7 @@ public void testWithPortOnLocator() { @Test public void testWithPortOnServer() { - int targetPort = AvailablePort.getRandomAvailablePort(1); + int targetPort = getRandomAvailableTCPPort(); server = new ServerStarterRule().withPort(targetPort).withAutoStart(); server.before(); diff --git a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTestUtil.java b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTestUtil.java index 3b24d9121867..dbc1e7afecf2 100755 --- a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTestUtil.java +++ b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheServerTestUtil.java @@ -21,6 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.dunit.Assert.assertNotNull; import static org.apache.geode.test.dunit.Assert.fail; @@ -52,7 +53,6 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache.util.CqListenerAdapter; import org.apache.geode.distributed.DistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.PoolFactoryImpl; import org.apache.geode.internal.cache.PoolFactoryImpl.PoolAttributes; @@ -320,7 +320,7 @@ private static Properties getClientProperties(boolean durable) { public static Integer createCacheServer(String regionName, Boolean notifyBySubscription) throws Exception { - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); createCacheServer(regionName, notifyBySubscription, port); return port; @@ -365,7 +365,7 @@ public static Integer createCacheServer(String regionName1, String regionName2, cache.createRegion(regionName2, attrs); } CacheServer server1 = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server1.setPort(port); server1.setNotifyBySubscription(notifyBySubscription.booleanValue()); server1.start(); diff --git a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java index a2bb445716c2..4336e1a3ad87 100755 --- a/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java +++ b/geode-dunit/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTestBase.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.assertj.core.api.Assertions.assertThat; @@ -75,7 +76,6 @@ import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.DistributedSystemDisconnectedException; import org.apache.geode.distributed.internal.membership.InternalDistributedMember; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CachePerfStats; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.GemFireCacheImpl; @@ -971,7 +971,7 @@ public static Integer createServerCache(Boolean notifyBySubscription, Integer ma assertNotNull(pr); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); r1.getCache().getDistributedSystem().getLogWriter().info("Starting server on port " + port); server.setPort(port); server.setMaxThreads(maxThreads); diff --git a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java index f0e60193fb48..1e704e70c1d6 100644 --- a/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java +++ b/geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java @@ -20,8 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; import static org.apache.geode.distributed.ConfigurationProperties.NAME; -import static org.apache.geode.internal.AvailablePort.SOCKET; -import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -63,7 +62,7 @@ public class HeadlessGfshIntegrationTest { @Before public void setup() throws IOException { - port = getRandomAvailablePort(SOCKET); + port = getRandomAvailableTCPPort(); Properties properties = new Properties(); properties.put(NAME, this.testName.getMethodName()); diff --git a/geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java b/geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java index ce1290378a19..30b7d4c88f4f 100644 --- a/geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java +++ b/geode-membership/src/main/java/org/apache/geode/internal/AvailablePort.java @@ -41,16 +41,14 @@ * selected available port. */ public class AvailablePort { + public static final int AVAILABLE_PORTS_LOWER_BOUND = 20001;// 20000/udp is securid + public static final int AVAILABLE_PORTS_UPPER_BOUND = 29999;// 30000/tcp is spoolfax /** Is the port available for a Socket (TCP) connection? */ public static final int SOCKET = 0; - public static final int AVAILABLE_PORTS_LOWER_BOUND = 20001;// 20000/udp is securid - public static final int AVAILABLE_PORTS_UPPER_BOUND = 29999;// 30000/tcp is spoolfax /** Is the port available for a JGroups (UDP) multicast connection */ public static final int MULTICAST = 1; - /////////////////////// Static Methods /////////////////////// - /** * see if there is a gemfire system property that establishes a default address for the given * protocol, and return it @@ -72,7 +70,6 @@ public static InetAddress getAddress(int protocol) { return null; } - /** * Returns whether or not the given port on the local host is available (that is, unused). * @@ -85,7 +82,6 @@ public static boolean isPortAvailable(final int port, int protocol) { return isPortAvailable(port, protocol, getAddress(protocol)); } - /** * Returns whether or not the given port on the local host is available (that is, unused). * @@ -284,7 +280,6 @@ private static Keeper keepAllInterfaces(int port) { return keepOneInterface(null, port); } - /** * Returns a randomly selected available port in the range 5001 to 32767. * @@ -296,33 +291,6 @@ public static int getRandomAvailablePort(int protocol) { return getRandomAvailablePort(protocol, getAddress(protocol)); } - public static Keeper getRandomAvailablePortKeeper(int protocol) { - return getRandomAvailablePortKeeper(protocol, getAddress(protocol)); - } - - /** - * Returns a randomly selected available port in the provided range. - * - * @param protocol The protocol to check (either {@link #SOCKET} or {@link #MULTICAST}). - * - * @throws IllegalArgumentException protocol is unknown - */ - public static int getAvailablePortInRange(int rangeBase, int rangeTop, int protocol) { - return getAvailablePortInRange(protocol, getAddress(protocol), rangeBase, rangeTop); - } - - /** - * Returns a randomly selected available port in the range 5001 to 32767 that satisfies a modulus - * - * @param protocol The protocol to check (either {@link #SOCKET} or {@link #MULTICAST}). - * - * @throws IllegalArgumentException protocol is unknown - */ - public static int getRandomAvailablePortWithMod(int protocol, int mod) { - return getRandomAvailablePortWithMod(protocol, getAddress(protocol), mod); - } - - /** * Returns a randomly selected available port in the range 5001 to 32767. * @@ -357,58 +325,6 @@ public static int getRandomAvailablePort(int protocol, InetAddress addr, } } - public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr) { - return getRandomAvailablePortKeeper(protocol, addr, false); - } - - public static Keeper getRandomAvailablePortKeeper(int protocol, InetAddress addr, - boolean useMembershipPortRange) { - while (true) { - int port = getRandomWildcardBindPortNumber(useMembershipPortRange); - Keeper result = isPortKeepable(port, protocol, addr); - if (result != null) { - return result; - } - } - } - - /** - * Returns a randomly selected available port in the provided range. - * - * @param protocol The protocol to check (either {@link #SOCKET} or {@link #MULTICAST}). - * @param addr the bind-address or mcast address to use - * - * @throws IllegalArgumentException protocol is unknown - */ - public static int getAvailablePortInRange(int protocol, InetAddress addr, int rangeBase, - int rangeTop) { - for (int port = rangeBase; port <= rangeTop; port++) { - if (isPortAvailable(port, protocol, addr)) { - return port; - } - } - return -1; - } - - /** - * Returns a randomly selected available port in the range 5001 to 32767 that satisfies a modulus - * and the provided protocol - * - * @param protocol The protocol to check (either {@link #SOCKET} or {@link #MULTICAST}). - * @param addr the bind-address or mcast address to use - * - * @throws IllegalArgumentException protocol is unknown - */ - public static int getRandomAvailablePortWithMod(int protocol, InetAddress addr, int mod) { - while (true) { - int port = getRandomWildcardBindPortNumber(); - if (isPortAvailable(port, protocol, addr) && (port % mod) == 0) { - return port; - } - } - } - - @Immutable public static final Random rand; @@ -420,10 +336,6 @@ public static int getRandomAvailablePortWithMod(int protocol, InetAddress addr, rand = new java.security.SecureRandom(); } - private static int getRandomWildcardBindPortNumber() { - return getRandomWildcardBindPortNumber(false); - } - private static int getRandomWildcardBindPortNumber(boolean useMembershipPortRange) { int rangeBase; int rangeTop; @@ -438,10 +350,6 @@ private static int getRandomWildcardBindPortNumber(boolean useMembershipPortRang return rand.nextInt(rangeTop - rangeBase) + rangeBase; } - private static int getRandomPortNumberInRange(int rangeBase, int rangeTop) { - return rand.nextInt(rangeTop - rangeBase) + rangeBase; - } - public static int getRandomAvailablePortInRange(int rangeBase, int rangeTop, int protocol) { int numberOfPorts = rangeTop - rangeBase; // do "5 times the numberOfPorts" iterations to select a port number. This will ensure that @@ -571,5 +479,4 @@ public static void main(String[] args) throws UnknownHostException { } } - } diff --git a/geode-memcached/src/integrationTest/java/org/apache/geode/memcached/GemcachedDevelopmentJUnitTest.java b/geode-memcached/src/integrationTest/java/org/apache/geode/memcached/GemcachedDevelopmentJUnitTest.java index 9c231e83b57d..fb698630deb8 100644 --- a/geode-memcached/src/integrationTest/java/org/apache/geode/memcached/GemcachedDevelopmentJUnitTest.java +++ b/geode-memcached/src/integrationTest/java/org/apache/geode/memcached/GemcachedDevelopmentJUnitTest.java @@ -15,6 +15,7 @@ package org.apache.geode.memcached; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -39,7 +40,6 @@ import org.junit.Before; import org.junit.Test; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.memcached.GemFireMemcachedServer.Protocol; import org.apache.geode.util.internal.GeodeGlossary; @@ -55,7 +55,7 @@ public class GemcachedDevelopmentJUnitTest { @Before public void setUp() throws Exception { System.setProperty(GeodeGlossary.GEMFIRE_PREFIX + MCAST_PORT, "0"); - PORT = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + PORT = getRandomAvailableTCPPort(); this.server = new GemFireMemcachedServer("", PORT, getProtocol()); server.start(); logger.addHandler(new StreamHandler()); diff --git a/geode-pulse/geode-pulse-test/src/main/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java b/geode-pulse/geode-pulse-test/src/main/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java index db3b181a0022..d44c9d74adbf 100644 --- a/geode-pulse/geode-pulse-test/src/main/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java +++ b/geode-pulse/geode-pulse-test/src/main/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java @@ -16,6 +16,8 @@ +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; + import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; @@ -25,7 +27,6 @@ import org.junit.rules.ExternalResource; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.InternalHttpService; import org.apache.geode.internal.net.SSLConfig; import org.apache.geode.tools.pulse.internal.data.PulseConstants; @@ -67,7 +68,7 @@ protected void after() { private void startServer() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); String jmxPropertiesFile = classLoader.getResource("test.properties").getPath(); - int jmxPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int jmxPort = getRandomAvailableTCPPort(); System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, Integer.toString(jmxPort)); server = Server.createServer(jmxPort, jmxPropertiesFile, jsonAuthFile); server.start(); @@ -78,7 +79,7 @@ private void startJetty() throws Exception { System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED, String.valueOf(Boolean.TRUE)); - int httpPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int httpPort = getRandomAvailableTCPPort(); jetty = new InternalHttpService(); jetty.createJettyServer(LOCALHOST, httpPort, new SSLConfig.Builder().build()); jetty.addWebApplication(PULSE_CONTEXT, getPulseWarPath(), new HashMap<>()); diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java index 7cb771577b25..7a5009d57532 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java @@ -18,6 +18,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_TIMEOUT; import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -44,7 +45,6 @@ import org.apache.geode.cache.server.CacheServer; import org.apache.geode.cache.server.ClientSubscriptionConfig; import org.apache.geode.distributed.internal.InternalDistributedSystem; -import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.cache.CacheServerImpl; import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.cache.InternalCacheServer; @@ -63,7 +63,7 @@ public class CacheClientNotifierDUnitTest extends WANTestBase { private int createCacheServerWithCSC(VM vm, final boolean withCSC, final int capacity, final String policy, final String diskStoreName) { - final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + final int serverPort = getRandomAvailableTCPPort(); SerializableRunnable createCacheServer = new SerializableRunnable() { @Override 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 b75e0688677b..9292baeaf499 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 @@ -36,6 +36,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.OFF_HEAP_MEMORY_SIZE; import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS; import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; +import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.dunit.Host.getHost; import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; @@ -131,8 +132,6 @@ import org.apache.geode.distributed.internal.InternalLocator; import org.apache.geode.distributed.internal.ServerLocation; import org.apache.geode.distributed.internal.membership.InternalDistributedMember; -import org.apache.geode.internal.AvailablePort; -import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.admin.remote.DistributionLocatorId; import org.apache.geode.internal.cache.BucketRegion; import org.apache.geode.internal.cache.CacheServerImpl; @@ -315,7 +314,7 @@ private void startLocatorDistributedSystem(Properties props) { public static Integer createFirstLocatorWithDSId(int dsId) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, port, port, -1, true); return port; } @@ -323,7 +322,7 @@ public static Integer createFirstLocatorWithDSId(int dsId) { public static Integer createFirstPeerLocator(int dsId) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, port, port, -1, false); return port; } @@ -331,7 +330,7 @@ public static Integer createFirstPeerLocator(int dsId) { public static Integer createSecondLocator(int dsId, int locatorPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, locatorPort, port, -1, true); return port; } @@ -339,7 +338,7 @@ public static Integer createSecondLocator(int dsId, int locatorPort) { public static Integer createSecondPeerLocator(int dsId, int locatorPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, locatorPort, port, -1, false); return port; } @@ -347,7 +346,7 @@ public static Integer createSecondPeerLocator(int dsId, int locatorPort) { public static Integer createFirstRemoteLocator(int dsId, int remoteLocPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, port, port, remoteLocPort, true); return port; } @@ -361,7 +360,7 @@ public static void bringBackLocatorOnOldPort(int dsId, int remoteLocPort, int ol public static Integer createFirstRemotePeerLocator(int dsId, int remoteLocPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, port, port, remoteLocPort, false); return port; } @@ -369,7 +368,7 @@ public static Integer createFirstRemotePeerLocator(int dsId, int remoteLocPort) public static Integer createSecondRemoteLocator(int dsId, int localPort, int remoteLocPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, localPort, port, remoteLocPort, true); return port; } @@ -391,14 +390,14 @@ public static Integer createSecondRemoteLocatorWithAPI(int dsId, int localPort, public static Integer createSecondRemotePeerLocator(int dsId, int localPort, int remoteLocPort) { stopOldLocator(); WANTestBase test = new WANTestBase(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); test.startLocator(dsId, localPort, port, remoteLocPort, false); return port; } public static int createReceiverInSecuredCache() { GatewayReceiverFactory fact = WANTestBase.cache.createGatewayReceiverFactory(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); fact.setStartPort(port); fact.setEndPort(port); fact.setManualStart(true); @@ -2063,7 +2062,7 @@ public static int createReceiver() { public static int createReceiverWithMaximumTimeBetweenPings(int maximumTimeBetweenPings) { GatewayReceiverFactory fact = cache.createGatewayReceiverFactory(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); fact.setStartPort(port); fact.setEndPort(port); fact.setManualStart(true); @@ -2108,7 +2107,7 @@ public static int createReceiverWithSSL(int locPort) { InternalDistributedSystem ds = test.getSystem(gemFireProps); cache = CacheFactory.create(ds); GatewayReceiverFactory fact = cache.createGatewayReceiverFactory(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); fact.setStartPort(port); fact.setEndPort(port); fact.setManualStart(true); @@ -2131,7 +2130,7 @@ public static void createReceiverAndServer(int locPort) { InternalDistributedSystem ds = test.getSystem(props); cache = CacheFactory.create(ds); GatewayReceiverFactory fact = cache.createGatewayReceiverFactory(); - int receiverPort = AvailablePortHelper.getRandomAvailableTCPPort(); + int receiverPort = getRandomAvailableTCPPort(); fact.setStartPort(receiverPort); fact.setEndPort(receiverPort); fact.setManualStart(true); @@ -2143,7 +2142,7 @@ public static void createReceiverAndServer(int locPort) { fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + receiverPort); } CacheServer server = cache.addCacheServer(); - int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int serverPort = getRandomAvailableTCPPort(); server.setPort(serverPort); server.setHostnameForClients("localhost"); try { @@ -2166,7 +2165,7 @@ public static int createServer(int locPort, int maximumTimeBetweenPings) { cache = CacheFactory.create(ds); CacheServer server = cache.addCacheServer(); - int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); + int port = getRandomAvailableTCPPort(); server.setPort(port); server.setHostnameForClients("localhost"); if (maximumTimeBetweenPings > 0) { @@ -2231,7 +2230,7 @@ public static int createReceiver_PDX(int locPort) { cache.createDiskStoreFactory().setDiskDirs(new File[] {pdxDir}).setMaxOplogSize(1) .create("pdxStore"); GatewayReceiverFactory fact = cache.createGatewayReceiverFactory(); - int port = AvailablePortHelper.getRandomAvailableTCPPort(); + int port = getRandomAvailableTCPPort(); fact.setStartPort(port); fact.setEndPort(port); fact.setManualStart(true);