/** * Creates the request protobuf to be used in {@link CreateInstanceRequest}. This method is * considered an internal implementation detail and not meant to be used by applications. * * <p>This method is considered an internal implementation detail and not meant to be used by * applications. */ @InternalApi com.google.bigtable.admin.v2.Cluster toEmbeddedProto(String projectId) { proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.getClusterBuilder().build(); } }
/** * 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.CreateClusterRequest toProto(String projectId) { proto.setParent(NameUtil.formatInstanceName(projectId, instanceId)); proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.build(); }
@Test public void testListClustersFailedZone() { // Setup com.google.bigtable.admin.v2.ListClustersRequest expectedRequest = com.google.bigtable.admin.v2.ListClustersRequest.newBuilder() .setParent(INSTANCE_NAME) .build(); com.google.bigtable.admin.v2.ListClustersResponse expectedResponse = com.google.bigtable.admin.v2.ListClustersResponse.newBuilder() .addClusters(com.google.bigtable.admin.v2.Cluster.newBuilder().setName(CLUSTER_NAME)) .addFailedLocations(NameUtil.formatLocationName(PROJECT_ID, "us-east1-c")) .build(); Mockito.when(mockListClustersCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); // Execute Exception actualError = null; try { adminClient.listClusters(INSTANCE_ID); } catch (Exception e) { actualError = e; } // Verify assertThat(actualError).isInstanceOf(PartialListClustersException.class); assert actualError != null; PartialListClustersException partialListError = (PartialListClustersException) actualError; assertThat(partialListError.getClusters()) .containsExactly(Cluster.fromProto(expectedResponse.getClusters(0))); assertThat(partialListError.getUnavailableZones()).containsExactly("us-east1-c"); }
.setName(INSTANCE_NAME + "1") .build()) .addFailedLocations(NameUtil.formatLocationName(PROJECT_ID, "us-east1-d")) .build();
@Test public void testResizeCluster() { // Setup com.google.bigtable.admin.v2.Cluster expectedRequest = com.google.bigtable.admin.v2.Cluster.newBuilder() .setName(CLUSTER_NAME) .setServeNodes(30) .build(); com.google.bigtable.admin.v2.Cluster expectedResponse = com.google.bigtable.admin.v2.Cluster.newBuilder() .setName(CLUSTER_NAME) .setLocation(NameUtil.formatLocationName(PROJECT_ID, "us-east1-c")) .setServeNodes(30) .build(); mockOperationResult(mockUpdateClusterCallable, expectedRequest, expectedResponse); // Execute Cluster actualResult = adminClient.resizeCluster(INSTANCE_ID, CLUSTER_ID, 30); // Verify assertThat(actualResult).isEqualTo(Cluster.fromProto(expectedResponse)); }
/** * Creates the request protobuf to be used in {@link CreateInstanceRequest}. This method is * considered an internal implementation detail and not meant to be used by applications. * * <p>This method is considered an internal implementation detail and not meant to be used by * applications. */ @InternalApi com.google.bigtable.admin.v2.Cluster toEmbeddedProto(String projectId) { proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.getClusterBuilder().build(); } }
/** * 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.CreateClusterRequest toProto(String projectId) { proto.setParent(NameUtil.formatInstanceName(projectId, instanceId)); proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.build(); }