From 6f505307a6ffd92c24d01fa7060bb989e3e4688e Mon Sep 17 00:00:00 2001 From: Derek Lee Date: Mon, 16 Oct 2023 20:47:06 +0000 Subject: [PATCH] feat: Add APIs to enable request priorities --- .../bigtable/admin/v2/models/AppProfile.java | 115 ++++++++++++++++++ .../v2/models/CreateAppProfileRequest.java | 17 +++ .../v2/models/UpdateAppProfileRequest.java | 18 +++ .../v2/BigtableInstanceAdminClientTests.java | 94 +++++++++++++- .../admin/v2/models/AppProfileTest.java | 50 ++++++++ .../models/CreateAppProfileRequestTest.java | 13 ++ .../models/UpdateAppProfileRequestTest.java | 35 ++++++ 7 files changed, 341 insertions(+), 1 deletion(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/AppProfile.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/AppProfile.java index 52be2b0d52..9c02a68fbe 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/AppProfile.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/AppProfile.java @@ -17,6 +17,8 @@ import com.google.api.core.InternalApi; import com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny; +import com.google.bigtable.admin.v2.AppProfile.Priority; +import com.google.bigtable.admin.v2.AppProfile.StandardIsolation; import com.google.bigtable.admin.v2.AppProfileName; import com.google.common.base.Objects; import com.google.common.base.Preconditions; @@ -76,6 +78,15 @@ public RoutingPolicy getPolicy() { } } + public IsolationPolicy getIsolationPolicy() { + if (proto.hasStandardIsolation()) { + return new StandardIsolationPolicy(proto.getStandardIsolation()); + } else { + // Should never happen because the constructor verifies that one must exist. + throw new VerifyException(); + } + } + /** Gets the id of this AppProfile. */ @SuppressWarnings("WeakerAccess") public String getId() { @@ -292,4 +303,108 @@ public int hashCode() { return Objects.hashCode(proto); } } + + /** Represents the options for isolating this app profile's traffic from other use cases. */ + @SuppressWarnings("WeakerAccess") + public interface IsolationPolicy {} + + /** + * The possible priorities for an app profile. Note that higher priority writes can sometimes + * queue behind lower priority writes to the same tablet, as writes must be strictly sequenced in + * the durability log. + */ + public static enum Priority { + PRIORITY_LOW(com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_LOW), + PRIORITY_MEDIUM(com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM), + PRIORITY_HIGH(com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_HIGH); + + private final com.google.bigtable.admin.v2.AppProfile.Priority proto; + + /** + * Wraps the protobuf. This method is considered an internal implementation detail and not meant + * to be used by applications. + */ + @InternalApi + public static Priority fromProto(com.google.bigtable.admin.v2.AppProfile.Priority proto) { + Preconditions.checkNotNull(proto); + + for (Priority priority : values()) { + if (priority.proto.equals(proto)) { + return priority; + } + } + + throw new IllegalArgumentException("Unknown priority: " + proto); + } + + Priority(com.google.bigtable.admin.v2.AppProfile.Priority proto) { + this.proto = proto; + } + + /** + * Creates the request protobuf. This method is considered an internal implementation detail and + * not meant to be used by applications. + */ + @InternalApi + public com.google.bigtable.admin.v2.AppProfile.Priority toProto() { + return proto; + } + } + + /** + * A standard {@link IsolationPolicy} for isolating this app profile's traffic from other use + * cases. + */ + public static class StandardIsolationPolicy implements IsolationPolicy { + private final StandardIsolation proto; + + /** Creates a new instance of {@link StandardIsolationPolicy}. */ + public static StandardIsolationPolicy of() { + return new StandardIsolationPolicy(StandardIsolation.getDefaultInstance()); + } + + /** Creates a new instance of {@link StandardIsolationPolicy} with the specified priority. */ + public static StandardIsolationPolicy of(Priority priority) { + return new StandardIsolationPolicy( + StandardIsolation.newBuilder().setPriority(priority.toProto()).build()); + } + + /* + * Returns the priority for this app profile. + */ + public Priority getPriority() { + return Priority.fromProto(proto.getPriority()); + } + + private StandardIsolationPolicy( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation proto) { + this.proto = proto; + } + + /** + * Creates the request protobuf. This method is considered an internal implementation detail and + * not meant to be used by applications. + */ + @InternalApi + com.google.bigtable.admin.v2.AppProfile.StandardIsolation toProto() { + return proto; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StandardIsolationPolicy that = (StandardIsolationPolicy) o; + return Objects.equal(proto, that.proto); + } + + @Override + public int hashCode() { + return Objects.hashCode(proto); + } + } } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequest.java index 35c41208be..b3159c3146 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequest.java @@ -17,9 +17,11 @@ import com.google.api.core.InternalApi; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.IsolationPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.MultiClusterRoutingPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.RoutingPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.SingleClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import com.google.common.base.Preconditions; import javax.annotation.Nonnull; @@ -92,6 +94,21 @@ public CreateAppProfileRequest setRoutingPolicy(RoutingPolicy routingPolicy) { return this; } + /** Sets the isolation policy for all read/write requests that use this app profile. */ + public CreateAppProfileRequest setIsolationPolicy(IsolationPolicy isolationPolicy) { + Preconditions.checkNotNull(isolationPolicy); + + if (isolationPolicy instanceof StandardIsolationPolicy) { + proto + .getAppProfileBuilder() + .setStandardIsolation(((StandardIsolationPolicy) isolationPolicy).toProto()); + } else { + throw new IllegalArgumentException("Unknown policy type: " + isolationPolicy); + } + + return this; + } + /** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java index 49d4c5d702..b9a45a6f78 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequest.java @@ -17,9 +17,11 @@ import com.google.api.core.InternalApi; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.IsolationPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.MultiClusterRoutingPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.RoutingPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.SingleClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.protobuf.FieldMask; @@ -121,6 +123,22 @@ public UpdateAppProfileRequest setRoutingPolicy(@Nonnull RoutingPolicy routingPo return this; } + /** Sets the isolation policy for all read/write requests that use this app profile. */ + public UpdateAppProfileRequest setIsolationPolicy(@Nonnull IsolationPolicy isolationPolicy) { + Preconditions.checkNotNull(isolationPolicy); + + if (isolationPolicy instanceof StandardIsolationPolicy) { + proto + .getAppProfileBuilder() + .setStandardIsolation(((StandardIsolationPolicy) isolationPolicy).toProto()); + updateFieldMask(com.google.bigtable.admin.v2.AppProfile.STANDARD_ISOLATION_FIELD_NUMBER); + } else { + throw new IllegalArgumentException("Unknown policy type: " + isolationPolicy); + } + + return this; + } + private void updateFieldMask(int fieldNumber) { FieldMask newMask = FieldMaskUtil.fromFieldNumbers(com.google.bigtable.admin.v2.AppProfile.class, fieldNumber); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTests.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTests.java index 5a7c955787..e99b64dc71 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTests.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClientTests.java @@ -43,6 +43,8 @@ import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.cloud.bigtable.admin.v2.models.AppProfile; import com.google.cloud.bigtable.admin.v2.models.AppProfile.MultiClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.Priority; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import com.google.cloud.bigtable.admin.v2.models.Cluster; import com.google.cloud.bigtable.admin.v2.models.ClusterAutoscalingConfig; import com.google.cloud.bigtable.admin.v2.models.CreateAppProfileRequest; @@ -82,7 +84,7 @@ @RunWith(JUnit4.class) /** - * Tests for {@link BigtableTableAdminClient}. This test class uses Mockito so it has been + * Tests for {@link BigtableInstanceAdminClient}. This test class uses Mockito so it has been * explicitly excluded from Native Image testing by not following the naming convention of (IT* and * *ClientTest). */ @@ -983,6 +985,55 @@ public void testCreateAppProfileAddMultipleClusterIdsWithList() { assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); } + @Test + public void testCreateAppProfileAddPriority() { + // Setup + Mockito.when(mockStub.createAppProfileCallable()).thenReturn(mockCreateAppProfileCallable); + + com.google.bigtable.admin.v2.CreateAppProfileRequest expectedRequest = + com.google.bigtable.admin.v2.CreateAppProfileRequest.newBuilder() + .setParent(NameUtil.formatInstanceName(PROJECT_ID, INSTANCE_ID)) + .setAppProfileId(APP_PROFILE_ID) + .setAppProfile( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny + .newBuilder() + .addClusterIds("cluster-id-1")) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM))) + .build(); + + com.google.bigtable.admin.v2.AppProfile expectedResponse = + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(APP_PROFILE_NAME) + .setDescription("my description") + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() + .addClusterIds("cluster-id-1")) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority(com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM)) + .build(); + + Mockito.when(mockCreateAppProfileCallable.futureCall(expectedRequest)) + .thenReturn(ApiFutures.immediateFuture(expectedResponse)); + + // Execute + AppProfile actualResult = + adminClient.createAppProfile( + CreateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) + .setDescription("my description") + .setRoutingPolicy(MultiClusterRoutingPolicy.of("cluster-id-1")) + .setIsolationPolicy(StandardIsolationPolicy.of(Priority.PRIORITY_MEDIUM))); + + // Verify + assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); + } + @Test public void testGetAppProfile() { // Setup @@ -1101,6 +1152,47 @@ public void testUpdateAppProfile() { assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); } + @Test + public void testUpdateAppProfileStandardIsolation() { + // Setup + Mockito.when(mockStub.updateAppProfileOperationCallable()) + .thenReturn(mockUpdateAppProfileCallable); + + com.google.bigtable.admin.v2.UpdateAppProfileRequest expectedRequest = + com.google.bigtable.admin.v2.UpdateAppProfileRequest.newBuilder() + .setAppProfile( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(APP_PROFILE_NAME) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_LOW))) + .setUpdateMask(FieldMask.newBuilder().addPaths("standard_isolation")) + .build(); + + com.google.bigtable.admin.v2.AppProfile expectedResponse = + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(APP_PROFILE_NAME) + .setMultiClusterRoutingUseAny( + com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny + .getDefaultInstance()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority(com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_LOW)) + .build(); + + mockOperationResult(mockUpdateAppProfileCallable, expectedRequest, expectedResponse); + + // Execute + AppProfile actualResult = + adminClient.updateAppProfile( + UpdateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) + .setIsolationPolicy(StandardIsolationPolicy.of(Priority.PRIORITY_LOW))); + + // Verify + assertThat(actualResult).isEqualTo(AppProfile.fromProto(expectedResponse)); + } + @Test public void testDeleteAppProfile() throws Exception { // Setup diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java index 64f334bb09..ac94b88571 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/AppProfileTest.java @@ -19,7 +19,9 @@ import com.google.bigtable.admin.v2.AppProfile.SingleClusterRouting; import com.google.bigtable.admin.v2.AppProfileName; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.Priority; import com.google.cloud.bigtable.admin.v2.models.AppProfile.SingleClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import com.google.common.collect.ImmutableList; import org.junit.Test; import org.junit.runner.RunWith; @@ -89,6 +91,34 @@ public void testFromProtoWithMultiClusterWithIds() { .isEqualTo(AppProfile.MultiClusterRoutingPolicy.of("cluster-id-1", "cluster-id-2")); } + @Test + public void testFromProtoWithStandardIsolation() { + AppProfile profile = + AppProfile.fromProto( + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName(AppProfileName.of("my-project", "my-instance", "my-profile").toString()) + .setDescription("my description") + .setSingleClusterRouting( + SingleClusterRouting.newBuilder() + .setClusterId("my-cluster") + .setAllowTransactionalWrites(true) + .build()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM) + .build()) + .setEtag("my-etag") + .build()); + + assertThat(profile.getInstanceId()).isEqualTo("my-instance"); + assertThat(profile.getId()).isEqualTo("my-profile"); + assertThat(profile.getDescription()).isEqualTo("my description"); + assertThat(profile.getPolicy()).isEqualTo(SingleClusterRoutingPolicy.of("my-cluster", true)); + assertThat(profile.getIsolationPolicy()) + .isEqualTo(StandardIsolationPolicy.of(Priority.PRIORITY_MEDIUM)); + } + @Test public void testNoNameError() { Exception actualException = null; @@ -126,6 +156,11 @@ public void testEquals() { com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) .build()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM) + .build()) .setEtag("my-etag") .build()); @@ -143,6 +178,11 @@ public void testEquals() { com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) .build()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM) + .build()) .setEtag("my-etag") .build()); UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2); @@ -161,6 +201,11 @@ public void testHashCode() { com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) .build()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM) + .build()) .setEtag("my-etag") .build()); @@ -178,6 +223,11 @@ public void testHashCode() { com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.newBuilder() .addAllClusterIds(ImmutableList.of("cluster-id-1", "cluster-id-2")) .build()) + .setStandardIsolation( + com.google.bigtable.admin.v2.AppProfile.StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_MEDIUM) + .build()) .setEtag("my-etag") .build()); UpdateAppProfileRequest updateAppProfileRequest3 = UpdateAppProfileRequest.of(profile2); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequestTest.java index 9b7141d3ab..4e5812f774 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateAppProfileRequestTest.java @@ -19,9 +19,11 @@ import com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny; import com.google.bigtable.admin.v2.AppProfile.SingleClusterRouting; +import com.google.bigtable.admin.v2.AppProfile.StandardIsolation; import com.google.bigtable.admin.v2.InstanceName; import com.google.cloud.bigtable.admin.v2.models.AppProfile.MultiClusterRoutingPolicy; import com.google.cloud.bigtable.admin.v2.models.AppProfile.SingleClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -71,4 +73,15 @@ public void testDefaultDescription() { assertThat(wrapper.toProto("my-project").getAppProfile().getDescription()) .isEqualTo("my-profile"); } + + @Test + public void testStandardIsolation() { + CreateAppProfileRequest wrapper = + CreateAppProfileRequest.of("my-instance", "my-profile") + .setRoutingPolicy(MultiClusterRoutingPolicy.of()) + .setIsolationPolicy(StandardIsolationPolicy.of()); + + assertThat(wrapper.toProto("my-project").getAppProfile().getStandardIsolation()) + .isEqualTo(StandardIsolation.getDefaultInstance()); + } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequestTest.java index ae3119b81a..53254ae29c 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateAppProfileRequestTest.java @@ -19,7 +19,10 @@ import com.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny; import com.google.bigtable.admin.v2.AppProfile.SingleClusterRouting; +import com.google.bigtable.admin.v2.AppProfile.StandardIsolation; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.Priority; import com.google.cloud.bigtable.admin.v2.models.AppProfile.SingleClusterRoutingPolicy; +import com.google.cloud.bigtable.admin.v2.models.AppProfile.StandardIsolationPolicy; import com.google.protobuf.FieldMask; import org.junit.Test; import org.junit.runner.RunWith; @@ -76,4 +79,36 @@ public void testUpdateExisting() { .setUpdateMask(FieldMask.newBuilder().addPaths("description")) .build()); } + + @Test + public void testUpdateExistingStandardIsolation() { + com.google.bigtable.admin.v2.AppProfile existingProto = + com.google.bigtable.admin.v2.AppProfile.newBuilder() + .setName("projects/my-project/instances/my-instance/appProfiles/my-profile") + .setEtag("my-etag") + .setDescription("description") + .setMultiClusterRoutingUseAny(MultiClusterRoutingUseAny.getDefaultInstance()) + .setStandardIsolation(StandardIsolation.getDefaultInstance()) + .build(); + + AppProfile existingWrapper = AppProfile.fromProto(existingProto); + + UpdateAppProfileRequest updateWrapper = + UpdateAppProfileRequest.of(existingWrapper) + .setIsolationPolicy(StandardIsolationPolicy.of(Priority.PRIORITY_LOW)); + + assertThat(updateWrapper.toProto("my-project")) + .isEqualTo( + com.google.bigtable.admin.v2.UpdateAppProfileRequest.newBuilder() + .setAppProfile( + existingProto + .toBuilder() + .setStandardIsolation( + StandardIsolation.newBuilder() + .setPriority( + com.google.bigtable.admin.v2.AppProfile.Priority.PRIORITY_LOW) + .build())) + .setUpdateMask(FieldMask.newBuilder().addPaths("standard_isolation")) + .build()); + } }