From e7369a94515d80efaf9502b9ec022941d2500827 Mon Sep 17 00:00:00 2001 From: Heesung Sohn Date: Fri, 1 Nov 2024 16:03:28 -0700 Subject: [PATCH] check style --- pulsar-inttest-client/pom.xml | 6 ++++++ .../integration/messaging/GeoReplication.java | 8 ++++---- .../integration/suites/PulsarTestSuite.java | 8 +++++--- .../integration/topologies/PulsarCluster.java | 17 ++++++++--------- .../topologies/PulsarClusterSpec.java | 11 +++++------ .../topologies/PulsarClusterTestBase.java | 13 ++++++------- .../topologies/PulsarGeoCluster.java | 2 +- 7 files changed, 35 insertions(+), 30 deletions(-) diff --git a/pulsar-inttest-client/pom.xml b/pulsar-inttest-client/pom.xml index 7562f21ccb3b9..e30dd6c84ca0c 100644 --- a/pulsar-inttest-client/pom.xml +++ b/pulsar-inttest-client/pom.xml @@ -53,6 +53,12 @@ pulsar-client-admin-api ${project.version} + + org.awaitility + awaitility + ${awaitility.version} + compile + diff --git a/pulsar-inttest-client/src/main/java/org/apache/pulsar/tests/integration/messaging/GeoReplication.java b/pulsar-inttest-client/src/main/java/org/apache/pulsar/tests/integration/messaging/GeoReplication.java index 545de0db22640..939acfcc00cfa 100644 --- a/pulsar-inttest-client/src/main/java/org/apache/pulsar/tests/integration/messaging/GeoReplication.java +++ b/pulsar-inttest-client/src/main/java/org/apache/pulsar/tests/integration/messaging/GeoReplication.java @@ -18,6 +18,9 @@ */ package org.apache.pulsar.tests.integration.messaging; +import java.nio.charset.StandardCharsets; +import java.util.UUID; +import java.util.concurrent.TimeUnit; import lombok.Cleanup; import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.client.admin.PulsarAdmin; @@ -26,11 +29,8 @@ import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.tests.integration.GeoRepIntegTest; -import org.testcontainers.shaded.org.awaitility.Awaitility; +import org.awaitility.Awaitility; import org.testng.Assert; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import java.util.concurrent.TimeUnit; /** * Geo replication test. diff --git a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/suites/PulsarTestSuite.java b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/suites/PulsarTestSuite.java index 02c4e3c7ec60d..3b88d394bc9d8 100644 --- a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/suites/PulsarTestSuite.java +++ b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/suites/PulsarTestSuite.java @@ -35,11 +35,13 @@ public final void tearDownAfterClass() throws Exception { cleanup(); } - public static void retryStrategically(Predicate predicate, int retryCount, long intSleepTimeInMillis) throws Exception { + public static void retryStrategically(Predicate predicate, int retryCount, long intSleepTimeInMillis) + throws Exception { retryStrategically(predicate, retryCount, intSleepTimeInMillis, false); } - public static void retryStrategically(Predicate predicate, int retryCount, long intSleepTimeInMillis, boolean throwException) + public static void retryStrategically(Predicate predicate, int retryCount, long intSleepTimeInMillis, + boolean throwException) throws Exception { for (int i = 0; i < retryCount; i++) { @@ -56,7 +58,7 @@ public static void retryStrategically(Predicate predicate, int retryCount, } } - Thread.sleep(intSleepTimeInMillis + (intSleepTimeInMillis * i)); + Thread.sleep(intSleepTimeInMillis + (intSleepTimeInMillis * i)); } } } diff --git a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarCluster.java b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarCluster.java index 3506612658ea6..56a4c342fcfb1 100644 --- a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarCluster.java +++ b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarCluster.java @@ -25,8 +25,6 @@ import static org.apache.pulsar.tests.integration.containers.PulsarContainer.CS_PORT; import static org.apache.pulsar.tests.integration.containers.PulsarContainer.PULSAR_CONTAINERS_LEAVE_RUNNING; import static org.apache.pulsar.tests.integration.containers.PulsarContainer.ZK_PORT; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -34,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.TreeMap; import java.util.function.Function; import lombok.Cleanup; import lombok.Getter; @@ -43,13 +42,13 @@ import org.apache.pulsar.tests.integration.containers.BKContainer; import org.apache.pulsar.tests.integration.containers.BrokerContainer; import org.apache.pulsar.tests.integration.containers.CSContainer; +import org.apache.pulsar.tests.integration.containers.OxiaContainer; import org.apache.pulsar.tests.integration.containers.ProxyContainer; import org.apache.pulsar.tests.integration.containers.PulsarContainer; import org.apache.pulsar.tests.integration.containers.PulsarInitMetadataContainer; import org.apache.pulsar.tests.integration.containers.WorkerContainer; import org.apache.pulsar.tests.integration.containers.ZKContainer; import org.apache.pulsar.tests.integration.docker.ContainerExecResult; -import org.apache.pulsar.tests.integration.containers.OxiaContainer; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; @@ -66,7 +65,7 @@ public class PulsarCluster { public static final String CURL = "/usr/bin/curl"; /** - * Pulsar Cluster Spec + * Pulsar Cluster Spec. * * @param spec pulsar cluster spec. * @return the built pulsar cluster @@ -151,9 +150,9 @@ private PulsarCluster(PulsarClusterSpec spec, Network network, CSContainer csCon this.csContainer = csContainer; - this.bookieContainers = Maps.newTreeMap(); - this.brokerContainers = Maps.newTreeMap(); - this.workerContainers = Maps.newTreeMap(); + this.bookieContainers = new TreeMap<>(); + this.brokerContainers = new TreeMap<>(); + this.workerContainers = new TreeMap<>(); this.proxyContainer = new ProxyContainer(clusterName, appendClusterName(ProxyContainer.NAME), spec.enableTls) .withNetwork(network) @@ -440,7 +439,7 @@ public static void stopService(String networkAlias, private static Map runNumContainers(String serviceName, int numContainers, Function containerCreator) { - Map containers = Maps.newTreeMap(); + Map containers = new TreeMap<>(); for (int i = 0; i < numContainers; i++) { String name = "pulsar-" + serviceName + "-" + i; T container = containerCreator.apply(name); @@ -632,7 +631,7 @@ public synchronized WorkerContainer getWorker(String workerName) { } private T getAnyContainer(Map containers, String serviceName) { - List containerList = Lists.newArrayList(); + List containerList = new ArrayList<>(); containerList.addAll(containers.values()); Collections.shuffle(containerList); checkArgument(!containerList.isEmpty(), "No " + serviceName + " is alive"); diff --git a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterSpec.java b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterSpec.java index 9f7e018d369a5..473ae0b458b8b 100644 --- a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterSpec.java +++ b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterSpec.java @@ -80,7 +80,7 @@ public class PulsarClusterSpec { int numFunctionWorkers = 0; /** - * Allow to query the last message + * Allow to query the last message. */ @Default boolean queryLastMessage = false; @@ -94,8 +94,7 @@ public class PulsarClusterSpec { FunctionRuntimeType functionRuntimeType = FunctionRuntimeType.PROCESS; /** - * Returns the list of external services to start with - * this cluster. + * Returns the list of external services to start with this cluster. * * @return the list of external services to start with the cluster. */ @@ -117,19 +116,19 @@ public class PulsarClusterSpec { boolean enableContainerLog = false; /** - * Provide a map of paths (in the classpath) to mount as volumes inside the containers + * Provide a map of paths (in the classpath) to mount as volumes inside the containers. */ @Default Map classPathVolumeMounts = new TreeMap<>(); /** - * Data container + * Data container. */ @Default GenericContainer dataContainer = null; /** - * Pulsar Test Image Name + * Pulsar Test Image Name. * * @return the version of the pulsar test image to use */ diff --git a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterTestBase.java b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterTestBase.java index 0879c737fb58f..56d206538d3a0 100644 --- a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterTestBase.java +++ b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarClusterTestBase.java @@ -37,7 +37,7 @@ @Slf4j public abstract class PulsarClusterTestBase extends PulsarTestBase { - public final static String CLIENT_CONFIG_FILE_PATH_PROPERTY_NAME = "client.config.file.path"; + public static final String CLIENT_CONFIG_FILE_PATH_PROPERTY_NAME = "client.config.file.path"; protected final Map brokerEnvs = new HashMap<>(); protected final Map bookkeeperEnvs = new HashMap<>(); @@ -46,7 +46,6 @@ public abstract class PulsarClusterTestBase extends PulsarTestBase { protected final List bookieAdditionalPorts = new LinkedList<>(); - private Map readClientConfigs(String clientConfFilePath) throws IOException { Properties prop = new Properties(System.getProperties()); try (FileInputStream input = new FileInputStream(clientConfFilePath)) { @@ -91,7 +90,7 @@ protected final void cleanup() throws Exception { @DataProvider(name = "ServiceUrlAndTopics") public Object[][] serviceUrlAndTopics() { - return new Object[][] { + return new Object[][]{ // plain text, persistent topic { stringSupplier(() -> getPulsarCluster().getPlainTextServiceUrl()), @@ -107,7 +106,7 @@ public Object[][] serviceUrlAndTopics() { @DataProvider(name = "ServiceUrls") public Object[][] serviceUrls() { - return new Object[][] { + return new Object[][]{ // plain text { stringSupplier(() -> getPulsarCluster().getPlainTextServiceUrl()) @@ -117,7 +116,7 @@ public Object[][] serviceUrls() { @DataProvider(name = "ServiceAndAdminUrls") public Object[][] serviceAndAdminUrls() { - return new Object[][] { + return new Object[][]{ // plain text { stringSupplier(() -> getPulsarCluster().getPlainTextServiceUrl()), @@ -128,7 +127,7 @@ public Object[][] serviceAndAdminUrls() { @DataProvider public Object[][] serviceUrlAndTopicDomain() { - return new Object[][] { + return new Object[][]{ { stringSupplier(() -> getPulsarCluster().getPlainTextServiceUrl()), TopicDomain.persistent @@ -142,7 +141,7 @@ public Object[][] serviceUrlAndTopicDomain() { @DataProvider(name = "topicDomain") public Object[][] topicDomain() { - return new Object[][] { + return new Object[][]{ { TopicDomain.persistent }, diff --git a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarGeoCluster.java b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarGeoCluster.java index 4099aa06e5ece..fa0b74c7fa516 100644 --- a/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarGeoCluster.java +++ b/pulsar-inttest-lib/src/main/java/org/apache/pulsar/tests/integration/topologies/PulsarGeoCluster.java @@ -36,7 +36,7 @@ public class PulsarGeoCluster { private final PulsarCluster[] clusters; /** - * Pulsar Cluster Spec + * Pulsar Cluster Spec. * * @param specs each pulsar cluster spec. * @return the built a pulsar cluster with geo replication