diff options
author | Volodymyr Vysotskyi <vvovyk@gmail.com> | 2018-12-20 23:39:39 +0200 |
---|---|---|
committer | Arina Ielchiieva <arina.yelchiyeva@gmail.com> | 2018-12-21 19:59:44 +0200 |
commit | af3977a8e6ea2c66a585312bf64463a3d3bd9a6c (patch) | |
tree | 459a8965351e26a2a61ade83e82c67fd90385c18 /contrib | |
parent | 6a9465ab8238ced53f4b899b54e4ea22e3e86f11 (diff) |
DRILL-6919: Fix compilation error in TestGracefulShutdown class for mapr profile
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java index 0c1fb5ef5..bcff4d602 100644 --- a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java +++ b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java @@ -22,17 +22,12 @@ import org.apache.drill.PlanTestBase; import org.apache.drill.common.exceptions.UserRemoteException; import org.apache.drill.exec.store.StoragePluginRegistry; import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePluginConfig; +import org.apache.drill.test.QueryTestUtil; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.BindException; -import java.net.ServerSocket; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; @@ -55,7 +50,6 @@ import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POS import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_REQUEST_WITH_TAGS; public class TestOpenTSDBPlugin extends PlanTestBase { - private static final Logger logger = LoggerFactory.getLogger(TestOpenTSDBPlugin.class); private static int portNumber; @@ -64,7 +58,7 @@ public class TestOpenTSDBPlugin extends PlanTestBase { @BeforeClass public static void setup() throws Exception { - portNumber = getFreePortNumber(10_000, 200); + portNumber = QueryTestUtil.getFreePortNumber(10_000, 200); final StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage(); OpenTSDBStoragePluginConfig storagePluginConfig = new OpenTSDBStoragePluginConfig(String.format("http://localhost:%s", portNumber)); @@ -191,27 +185,4 @@ public class TestOpenTSDBPlugin extends PlanTestBase { test("describe `warp.speed.test`"); Assert.assertEquals(1, testSql("show tables")); } - - /** - * Checks that port with specified number is free and returns it. - * Otherwise, increases port number and checks until free port is found - * or the number of attempts is reached specified numberOfAttempts - * - * @param portNumber initial port number - * @param numberOfAttempts max number of attempts to find port with greater number - * @return free port number - * @throws BindException if free port was not found and all attempts were used. - */ - private static int getFreePortNumber(int portNumber, int numberOfAttempts) throws IOException { - for (int i = portNumber; i <= portNumber + numberOfAttempts; i++) { - try (ServerSocket socket = new ServerSocket(i)) { - return socket.getLocalPort(); - } catch (BindException e) { - logger.warn("Port {} is already in use.", i); - } - } - - throw new BindException(String.format("Free port could not be found in the range [%s-%s].\n" + - "Please release any of used ports in this range.", portNumber, portNumber + numberOfAttempts)); - } } |