From 94327fdac529903a8e0fae59172ca7ccee739b1a Mon Sep 17 00:00:00 2001 From: Yi Hu Date: Thu, 21 Sep 2023 13:28:22 -0400 Subject: [PATCH] Fix sync it (#28588) --- .../beam/it/gcp/bigtable/BigtableResourceManager.java | 10 +++++----- .../it/gcp/bigtable/BigtableResourceManagerUtils.java | 5 +++-- .../it/gcp/bigtable/BigtableResourceManagerTest.java | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java index 713880229281..311ce9575c2e 100644 --- a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java +++ b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java @@ -96,7 +96,7 @@ public class BigtableResourceManager implements ResourceManager { private final Set cdcEnabledTables; private boolean hasInstance; - private Iterable clusters; + private List clusters; private final boolean usingStaticInstance; @@ -195,12 +195,12 @@ public String getInstanceId() { /** * Creates a Bigtable instance in which all clusters, nodes and tables will exist. * - * @param clusters Collection of BigtableResourceManagerCluster objects to associate with the - * given Bigtable instance. + * @param clusters List of BigtableResourceManagerCluster objects to associate with the given + * Bigtable instance. * @throws BigtableResourceManagerException if there is an error creating the instance in * Bigtable. */ - public synchronized void createInstance(Iterable clusters) + public synchronized void createInstance(List clusters) throws BigtableResourceManagerException { // Check to see if instance already exists, and throw error if it does @@ -559,7 +559,7 @@ public List getClusterNames() { } private Iterable getClusters() { - if (usingStaticInstance && this.clusters == null) { + if (usingStaticInstance && this.clusters.isEmpty()) { try (BigtableInstanceAdminClient instanceAdminClient = bigtableResourceManagerClientFactory.bigtableInstanceAdminClient()) { List managedClusters = new ArrayList<>(); diff --git a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerUtils.java b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerUtils.java index a893493d766e..28f1f5bf60c5 100644 --- a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerUtils.java +++ b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerUtils.java @@ -21,6 +21,7 @@ import com.google.cloud.bigtable.admin.v2.models.StorageType; import java.time.format.DateTimeFormatter; +import java.util.List; import java.util.regex.Pattern; import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList; @@ -51,9 +52,9 @@ private BigtableResourceManagerUtils() {} * @param zone the zone/region that the cluster will be deployed to. * @param numNodes the number of nodes that the cluster will contain. * @param storageType the type of storage to configure the cluster with (SSD or HDD). - * @return Collection containing a single BigtableResourceManagerCluster object. + * @return List containing a single BigtableResourceManagerCluster object. */ - static Iterable generateDefaultClusters( + static List generateDefaultClusters( String baseString, String zone, int numNodes, StorageType storageType) { String clusterId = diff --git a/it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerTest.java b/it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerTest.java index f8673ed696cc..74b25e84c691 100644 --- a/it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerTest.java +++ b/it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManagerTest.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList; import org.junit.Before; @@ -73,7 +74,7 @@ public class BigtableResourceManagerTest { private static final StorageType CLUSTER_STORAGE_TYPE = StorageType.SSD; private BigtableResourceManager testManager; - private Iterable cluster; + private List cluster; @Before public void setUp() throws IOException {