@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getClustersCount() > 0) { hash = (37 * hash) + CLUSTERS_FIELD_NUMBER; hash = (53 * hash) + getClustersList().hashCode(); } if (getFailedLocationsCount() > 0) { hash = (37 * hash) + FAILED_LOCATIONS_FIELD_NUMBER; hash = (53 * hash) + getFailedLocationsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * DEPRECATED: This field is unused and ignored. * </pre> * * <code>string next_page_token = 3;</code> */ public Builder clearNextPageToken() { nextPageToken_ = getDefaultInstance().getNextPageToken(); onChanged(); return this; } /**
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.admin.v2.ListClustersResponse)) { return super.equals(obj); } com.google.bigtable.admin.v2.ListClustersResponse other = (com.google.bigtable.admin.v2.ListClustersResponse) obj; boolean result = true; result = result && getClustersList().equals(other.getClustersList()); result = result && getFailedLocationsList().equals(other.getFailedLocationsList()); result = result && getNextPageToken().equals(other.getNextPageToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; for (int i = 0; i < clusters_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, clusters_.get(i)); } { int dataSize = 0; for (int i = 0; i < failedLocations_.size(); i++) { dataSize += computeStringSizeNoTag(failedLocations_.getRaw(i)); } size += dataSize; size += 1 * getFailedLocationsList().size(); } if (!getNextPageTokenBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, nextPageToken_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@Test public void testListClusters() { // 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 + "1")) .addClusters( com.google.bigtable.admin.v2.Cluster.newBuilder().setName(CLUSTER_NAME + "2")) .build(); Mockito.when(mockListClustersCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); // Execute List<Cluster> actualResult = adminClient.listClusters(INSTANCE_ID); // Verify assertThat(actualResult) .containsExactly( Cluster.fromProto(expectedResponse.getClusters(0)), Cluster.fromProto(expectedResponse.getClusters(1))); }
/** * @return a Single Cluster for the project and instance. * @throws IllegalStateException for any project / instance combination that does not return * exactly 1 cluster. */ public Cluster getSingleCluster() { ListClustersResponse response = getClusters(); Preconditions.checkState(response.getClustersCount() != 0, "The instance does not exist."); Preconditions.checkState(response.getClustersCount() == 1, "There can only be one cluster for this method to work."); return response.getClusters(0); }
@java.lang.Override public com.google.bigtable.admin.v2.ListClustersResponse getDefaultInstanceForType() { return com.google.bigtable.admin.v2.ListClustersResponse.getDefaultInstance(); }
/** * Gets the current configuration of the cluster as encapsulated by a {@link Cluster} object. * * @param clusterId * @param zoneId * @return the {@link Cluster} if it was set. If the cluster is not found, throw a {@link * NullPointerException}. */ public Cluster getCluster(String clusterId, String zoneId) { Cluster response = null; for (Cluster cluster : getClusters().getClustersList()) { if (cluster.getName().endsWith("/clusters/" + clusterId) && cluster.getLocation().endsWith("/locations/" + zoneId)) { if (response == null) { response = cluster; } else { throw new IllegalStateException( String.format("Got multiple clusters named %s in zone %z.", clusterId, zoneId)); } } } return Preconditions.checkNotNull(response, String.format("Cluster %s in zone %s was not found.", clusterId, zoneId)); }
@java.lang.Override public com.google.bigtable.admin.v2.ListClustersResponse buildPartial() { com.google.bigtable.admin.v2.ListClustersResponse result = new com.google.bigtable.admin.v2.ListClustersResponse(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (clustersBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001)) { clusters_ = java.util.Collections.unmodifiableList(clusters_); bitField0_ = (bitField0_ & ~0x00000001); } result.clusters_ = clusters_; } else { result.clusters_ = clustersBuilder_.build(); } if (((bitField0_ & 0x00000002) == 0x00000002)) { failedLocations_ = failedLocations_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000002); } result.failedLocations_ = failedLocations_; result.nextPageToken_ = nextPageToken_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
@Override public List<Cluster> apply(com.google.bigtable.admin.v2.ListClustersResponse proto) { // NOTE: serverside pagination is not and will not be implemented, so remaining pages // are not fetched. However, if that assumption turns out to be wrong, fail fast to // avoid returning partial data. Verify.verify( proto.getNextPageToken().isEmpty(), "Server returned an unexpected paginated response"); ImmutableList.Builder<Cluster> clusters = ImmutableList.builder(); for (com.google.bigtable.admin.v2.Cluster cluster : proto.getClustersList()) { clusters.add(Cluster.fromProto(cluster)); } ImmutableList.Builder<String> failedZones = ImmutableList.builder(); for (String locationStr : proto.getFailedLocationsList()) { failedZones.add(NameUtil.extractZoneIdFromLocationName(locationStr)); } if (!failedZones.build().isEmpty()) { throw new PartialListClustersException(failedZones.build(), clusters.build()); } return clusters.build(); } },
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; for (int i = 0; i < clusters_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, clusters_.get(i)); } { int dataSize = 0; for (int i = 0; i < failedLocations_.size(); i++) { dataSize += computeStringSizeNoTag(failedLocations_.getRaw(i)); } size += dataSize; size += 1 * getFailedLocationsList().size(); } if (!getNextPageTokenBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, nextPageToken_); } memoizedSize = size; return size; }
@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"); }
/** * Snapshot operations need various aspects of a {@link BigtableClusterName}. This method gets a * clusterId from either a lookup (projectId and instanceId translate to a single clusterId when * an instance has only one cluster). */ public synchronized BigtableClusterName getClusterName() throws IOException { if (this.clusterName == null) { try (BigtableClusterUtilities util = new BigtableClusterUtilities(options)) { ListClustersResponse clusters = util.getClusters(); Preconditions.checkState(clusters.getClustersCount() == 1, String.format( "Project '%s' / Instance '%s' has %d clusters. There must be exactly 1 for this operation to work.", options.getProjectId(), options.getInstanceId(), clusters.getClustersCount())); clusterName = new BigtableClusterName(clusters.getClusters(0).getName()); } catch (GeneralSecurityException e) { throw new IOException("Could not get cluster Id.", e); } } return clusterName; }
io.grpc.protobuf.ProtoUtils.marshaller( com.google.bigtable.admin.v2.ListClustersResponse .getDefaultInstance())) .setSchemaDescriptor( new BigtableInstanceAdminMethodDescriptorSupplier("ListClusters"))
public com.google.bigtable.admin.v2.ListClustersResponse buildPartial() { com.google.bigtable.admin.v2.ListClustersResponse result = new com.google.bigtable.admin.v2.ListClustersResponse(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (clustersBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001)) { clusters_ = java.util.Collections.unmodifiableList(clusters_); bitField0_ = (bitField0_ & ~0x00000001); } result.clusters_ = clusters_; } else { result.clusters_ = clustersBuilder_.build(); } if (((bitField0_ & 0x00000002) == 0x00000002)) { failedLocations_ = failedLocations_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000002); } result.failedLocations_ = failedLocations_; result.nextPageToken_ = nextPageToken_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getClustersCount() > 0) { hash = (37 * hash) + CLUSTERS_FIELD_NUMBER; hash = (53 * hash) + getClustersList().hashCode(); } if (getFailedLocationsCount() > 0) { hash = (37 * hash) + FAILED_LOCATIONS_FIELD_NUMBER; hash = (53 * hash) + getFailedLocationsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.admin.v2.ListClustersResponse)) { return super.equals(obj); } com.google.bigtable.admin.v2.ListClustersResponse other = (com.google.bigtable.admin.v2.ListClustersResponse) obj; boolean result = true; result = result && getClustersList() .equals(other.getClustersList()); result = result && getFailedLocationsList() .equals(other.getFailedLocationsList()); result = result && getNextPageToken() .equals(other.getNextPageToken()); return result; }
public Builder mergeFrom(com.google.bigtable.admin.v2.ListClustersResponse other) { if (other == com.google.bigtable.admin.v2.ListClustersResponse.getDefaultInstance()) return this; if (clustersBuilder_ == null) { if (!other.getNextPageToken().isEmpty()) { nextPageToken_ = other.nextPageToken_; onChanged();
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; for (int i = 0; i < clusters_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, clusters_.get(i)); } { int dataSize = 0; for (int i = 0; i < failedLocations_.size(); i++) { dataSize += computeStringSizeNoTag(failedLocations_.getRaw(i)); } size += dataSize; size += 1 * getFailedLocationsList().size(); } if (!getNextPageTokenBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, nextPageToken_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }