@Override public List<Instance> apply(com.google.bigtable.admin.v2.ListInstancesResponse proto) { // NOTE: pagination is intentionally ignored. The server does not implement it and never // will. Verify.verify( proto.getNextPageToken().isEmpty(), "Server returned an unexpected paginated response"); ImmutableList.Builder<Instance> instances = ImmutableList.builder(); for (com.google.bigtable.admin.v2.Instance protoInstance : proto.getInstancesList()) { instances.add(Instance.fromProto(protoInstance)); } ImmutableList.Builder<String> failedZones = ImmutableList.builder(); for (String locationStr : proto.getFailedLocationsList()) { failedZones.add(NameUtil.extractZoneIdFromLocationName(locationStr)); } if (!failedZones.build().isEmpty()) { throw new PartialListInstancesException(failedZones.build(), instances.build()); } return instances.build(); } },
@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(); } },
@Override public List<Instance> apply(com.google.bigtable.admin.v2.ListInstancesResponse proto) { // NOTE: pagination is intentionally ignored. The server does not implement it and never // will. Verify.verify( proto.getNextPageToken().isEmpty(), "Server returned an unexpected paginated response"); ImmutableList.Builder<Instance> instances = ImmutableList.builder(); for (com.google.bigtable.admin.v2.Instance protoInstance : proto.getInstancesList()) { instances.add(Instance.fromProto(protoInstance)); } ImmutableList.Builder<String> failedZones = ImmutableList.builder(); for (String locationStr : proto.getFailedLocationsList()) { failedZones.add(NameUtil.extractZoneIdFromLocationName(locationStr)); } if (!failedZones.build().isEmpty()) { throw new PartialListInstancesException(failedZones.build(), instances.build()); } return instances.build(); } },
@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(); } },